Version 11

    Unmarshalling and Object Model Factory





    The Java class hierarchy to which XML content is unmarshalled can be absolutely arbitrary. Only you as an application developer know how to build an object graph using the class hierarchy (i.e. what constructors to use, which method adds a child object to its parent, how to set values, etc). Therefore, JBossXB does not expect Java classes to follow any design convention. Even the JavaBean one.


    On the other hand, parsing XML content only the framework knows with what data and in which order the object model should be populated with the data.


    Now, some third party is needed that would make the "know how" (i.e. the application developer) and "know what" (i.e. the framework) work together. This third party is the Object Model Factory (org.jboss.xml.binding.ObjectModelFactory). An implementation of ObjectModelFactory interface is provided by the user. There is also an implementation of the ObjectModelFactory distributed with the framework which provides an API to map XML elements to Java classes and its fields.


    There are two approaches to implement object model factories:

    • by implementing ObjectModelFactory interface

    • by implementing GenericObjectModelFactory interface