Package org.glassfish.hk2.xml.api
Interface XmlService
- All Known Implementing Classes:
XmlServiceImpl
This is the main service for parsing your XML files using some
pluggable parsing technology.
- Author:
- jwells
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T> TcreateBean(Class<T> beanInterface) This creates an instance of the given bean type of with no fields of the bean filled in.<T> XmlRootHandle<T>createEmptyHandle(Class<T> jaxbAnnotationInterface) This creates an empty handle (root will initially be null) corresponding to the given interface class<T> XmlRootHandle<T>createEmptyHandle(Class<T> jaxbAnnotationInterface, boolean advertiseInRegistry, boolean advertiseInHub) This creates an empty handle (root will initially be null) corresponding to the given interface class<T> voidmarshal(OutputStream outputStream, XmlRootHandle<T> rootHandle) Will marshal the given tree into the given stream.<T> voidmarshal(OutputStream outputStream, XmlRootHandle<T> rootHandle, Map<String, Object> options) Will marshal the given tree into the given stream.<T> XmlRootHandle<T>unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface) Unmarshals an XML stream using the jaxb annotated interface.<T> XmlRootHandle<T>unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub) Unmarshals an XML stream using the jaxb annotated interface.<T> XmlRootHandle<T>unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String, Object> options) Unmarshals an XML stream using the jaxb annotated interface.<T> XmlRootHandle<T>Unmarshalls the given URI using the jaxb annotated interface.<T> XmlRootHandle<T>unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub) Unmarshalls the given URI using the jaxb annotated interface.<T> XmlRootHandle<T>unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String, Object> options) Unmarshalls the given URI using the jaxb annotated interface.<T> XmlRootHandle<T>unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub) Unmarshals an XML stream using the jaxb annotated interface.<T> XmlRootHandle<T>unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String, Object> options) Unmarshals an XML stream using the jaxb annotated interface.
-
Field Details
-
DEFAULT_NAMESPACE
The default namespace of the document- See Also:
-
-
Method Details
-
unmarshal
Unmarshalls the given URI using the jaxb annotated interface. The resulting JavaBean tree will be advertised in the ServiceLocator and in the Hub. Will use the registered implementation ofXmlServiceParserto parse the file.- Parameters:
uri- The non-null URI whereby to find the xml corresponding to the classjaxbAnnotatedClassOrInterface- The non-null class corresonding to the Xml to be parsed- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
unmarshal
<T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub) Unmarshalls the given URI using the jaxb annotated interface. Will use the registered implementation ofXmlServiceParserto parse the file.- Parameters:
uri- The non-null URI whereby to find the xml corresponding to the classjaxbAnnotatedClassOrInterface- The non-null interface corresponding to the Xml to be parsedadvertiseInRegistry- if true the entire tree of parsed xml will be added to the ServiceLocatoradvertiseInHub- if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
unmarshal
<T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String, Object> options) Unmarshalls the given URI using the jaxb annotated interface. Will use the registered implementation ofXmlServiceParserto parse the file.- Parameters:
uri- The non-null URI whereby to find the xml corresponding to the classjaxbAnnotatedClassOrInterface- The non-null interface corresponding to the Xml to be parsedadvertiseInRegistry- if true the entire tree of parsed xml will be added to the ServiceLocatoradvertiseInHub- if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)options- optional (possibly null) options from the caller- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
unmarshal
<T> XmlRootHandle<T> unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub) Unmarshals an XML stream using the jaxb annotated interface. Will use a built-in algorithm to read the stream- Parameters:
reader- The non-null XMLStreamReader representing the XML to be readjaxbAnnotatedClassOrInterface- The non-null interface corresponding to the Xml to be parsedadvertiseInRegistry- if true the entire tree of parsed xml will be added to the ServiceLocatoradvertiseInHub- if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
unmarshal
<T> XmlRootHandle<T> unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String, Object> options) Unmarshals an XML stream using the jaxb annotated interface. Will use a built-in algorithm to read the stream- Parameters:
reader- The non-null XMLStreamReader representing the XML to be readjaxbAnnotatedClassOrInterface- The non-null interface corresponding to the Xml to be parsedadvertiseInRegistry- if true the entire tree of parsed xml will be added to the ServiceLocatoradvertiseInHub- if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)options- optional (possibly null) options from the caller- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
unmarshal
Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation ofXmlServiceParserto parse the file. The beans will be included in the service registry and the configuration hub as appropriate- Parameters:
inputStream- The non-null input stream to read. Will not close this streamjaxbAnnotatedClassOrInterface- The non-null interface corresponding to the Xml to be parsed- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
unmarshal
<T> XmlRootHandle<T> unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub) Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation ofXmlServiceParserto parse the file.- Parameters:
inputStream- The non-null input stream to read. Will not close this streamjaxbAnnotatedClassOrInterface- The non-null interface corresponding to the Xml to be parsedadvertiseInRegistry- if true the entire tree of parsed xml will be added to the ServiceLocatoradvertiseInHub- if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
unmarshal
<T> XmlRootHandle<T> unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String, Object> options) Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation ofXmlServiceParserto parse the file.- Parameters:
inputStream- The non-null input stream to read. Will not close this streamjaxbAnnotatedClassOrInterface- The non-null interface corresponding to the Xml to be parsedadvertiseInRegistry- if true the entire tree of parsed xml will be added to the ServiceLocatoradvertiseInHub- if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)options- optional (possibly null) options from the caller- Returns:
- A non-null handle that can be used to get the unmarshalled data or perform other tasks
-
createEmptyHandle
<T> XmlRootHandle<T> createEmptyHandle(Class<T> jaxbAnnotationInterface, boolean advertiseInRegistry, boolean advertiseInHub) This creates an empty handle (root will initially be null) corresponding to the given interface class- Parameters:
jaxbAnnotationInterface- The non-null interface class corresponding to the XML to be parsedadvertiseInRegistry- if true the entire tree of parsed xml will be added to the ServiceLocatoradvertiseInHub- if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)- Returns:
- A non-null handle that can be used to create a new root bean, but which is not initially tied to any backing file or other input stream
-
createEmptyHandle
This creates an empty handle (root will initially be null) corresponding to the given interface class- Parameters:
jaxbAnnotationInterface- The non-null interface class corresponding to the XML to be parsed- Returns:
- A non-null handle that can be used to create a new root bean, but which is not initially tied to any backing file or other input stream
-
createBean
This creates an instance of the given bean type of with no fields of the bean filled in. Objects created with this API can be used in the adder methods of the beans, and will not be validated (but all setters and getters and lookups will work properly)- Returns:
- An instance of the bean with no properties set
-
marshal
Will marshal the given tree into the given stream. This can be called with a rootHandle that was NOT created with this XmlService implementation. In that way different parsing formats can potentially be converted into each other. For example an XML document can be converted to equivalent JSON. Not all transformations may be possible. This method will hold the read lock of the rootHandle so it cannot be modified while being written to the output stream- Parameters:
outputStream- A non-closed output stream. This method will not close the output streamrootHandle- A non-null root handle that may or may not have been created with this XmlService implementation- Throws:
IOException- On any exception that might happen
-
marshal
<T> void marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle, Map<String, Object> options) throws IOExceptionWill marshal the given tree into the given stream. This can be called with a rootHandle that was NOT created with this XmlService implementation. In that way different parsing formats can potentially be converted into each other. For example an XML document can be converted to equivalent JSON. Not all transformations may be possible. This method will hold the read lock of the rootHandle so it cannot be modified while being written to the output stream- Parameters:
outputStream- A non-closed output stream. This method will not close the output streamrootHandle- A non-null root handle that may or may not have been created with this XmlService implementationoptions- optional (possibly null) options from the caller- Throws:
IOException- On any exception that might happen
-