Class XmlServiceImpl

java.lang.Object
org.glassfish.hk2.xml.internal.XmlServiceImpl
All Implemented Interfaces:
XmlService

@Singleton @Visibility(LOCAL) public class XmlServiceImpl extends Object implements XmlService
Author:
jwells
  • Field Details

    • DEBUG_PARSING

      public static final boolean DEBUG_PARSING
  • Constructor Details

    • XmlServiceImpl

      public XmlServiceImpl()
  • Method Details

    • unmarshal

      public <T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedClassOrInterface)
      Description copied from interface: XmlService
      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 of XmlServiceParser to parse the file.
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      uri - The non-null URI whereby to find the xml corresponding to the class
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      public <T> XmlRootHandle<T> unmarshal(InputStream input, Class<T> jaxbAnnotatedInterface)
      Description copied from interface: XmlService
      Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file. The beans will be included in the service registry and the configuration hub as appropriate
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      input - The non-null input stream to read. Will not close this stream
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      public <T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      Description copied from interface: XmlService
      Unmarshalls the given URI using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      uri - The non-null URI whereby to find the xml corresponding to the class
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - 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

      public <T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
      Description copied from interface: XmlService
      Unmarshalls the given URI using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      uri - The non-null URI whereby to find the xml corresponding to the class
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - 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

      public <T> XmlRootHandle<T> unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      Description copied from interface: XmlService
      Unmarshals an XML stream using the jaxb annotated interface. Will use a built-in algorithm to read the stream
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      reader - The non-null XMLStreamReader representing the XML to be read
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - 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

      public <T> XmlRootHandle<T> unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
      Description copied from interface: XmlService
      Unmarshals an XML stream using the jaxb annotated interface. Will use a built-in algorithm to read the stream
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      reader - The non-null XMLStreamReader representing the XML to be read
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - 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

      public <T> XmlRootHandle<T> unmarshal(InputStream input, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      Description copied from interface: XmlService
      Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      input - The non-null input stream to read. Will not close this stream
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - 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

      public <T> XmlRootHandle<T> unmarshal(InputStream input, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
      Description copied from interface: XmlService
      Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Specified by:
      unmarshal in interface XmlService
      Parameters:
      input - The non-null input stream to read. Will not close this stream
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - 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

      public <T> XmlRootHandle<T> createEmptyHandle(Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      Description copied from interface: XmlService
      This creates an empty handle (root will initially be null) corresponding to the given interface class
      Specified by:
      createEmptyHandle in interface XmlService
      Parameters:
      jaxbAnnotatedInterface - The non-null interface class corresponding to the XML to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - 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

      public <T> XmlRootHandle<T> createEmptyHandle(Class<T> jaxbAnnotationInterface)
      Description copied from interface: XmlService
      This creates an empty handle (root will initially be null) corresponding to the given interface class
      Specified by:
      createEmptyHandle in interface XmlService
      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

      public <T> T createBean(Class<T> beanInterface)
      Description copied from interface: XmlService
      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)
      Specified by:
      createBean in interface XmlService
      Returns:
      An instance of the bean with no properties set
    • marshal

      public <T> void marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle) throws IOException
      Description copied from interface: XmlService
      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
      Specified by:
      marshal in interface XmlService
      Parameters:
      outputStream - A non-closed output stream. This method will not close the output stream
      rootHandle - 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

      public <T> void marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle, Map<String,Object> options) throws IOException
      Description copied from interface: XmlService
      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
      Specified by:
      marshal in interface XmlService
      Parameters:
      outputStream - A non-closed output stream. This method will not close the output stream
      rootHandle - A non-null root handle that may or may not have been created with this XmlService implementation
      options - optional (possibly null) options from the caller
      Throws:
      IOException - On any exception that might happen
    • getClassReflectionHelper

      public ClassReflectionHelper getClassReflectionHelper()
    • getServiceLocator

      public ServiceLocator getServiceLocator()
    • getParser

      public XmlServiceParser getParser()
    • getPackageNamespace

      public Map<String,String> getPackageNamespace(Class<?> clazz)