EclipseLink 2.1.0, build 'v20100311-r6779' API Reference

org.eclipse.persistence.jaxb
Class DynamicJAXBContextFactory

java.lang.Object
  extended by org.eclipse.persistence.jaxb.DynamicJAXBContextFactory

public class DynamicJAXBContextFactory
extends java.lang.Object

DynamicJAXBContextFactory allows the user to create a DynamicJAXBContext without having realized Java classes available on the classpath. During context creation, the user's metadata will be analyzed, and in-memory classes will be generated.

Objects that are returned by EclipseLink unmarshal methods will be subclasses of DynamicEntity. DynamicEntities offer a simple get(propertyName) / set(propertyName, propertyValue) API to manipulate their data.

Example:

String sessionName = "mynamespace.Employee";
ClassLoader loader = Thread.currentThread().getContextClassLoader();

DynamicJAXBContext dContext = DynamicJAXBContextFactory.createContext(sessionName, null);

DynamicEntity employee = dContext.newDynamicEntity("mynamespace.Employee");
employee.set("firstName", "Bob");
employee.set("lastName", "Barker");
dContext.createMarshaller().(employee, System.out);

See Also:
JAXBContext, DynamicJAXBContext, DynamicEntity, DynamicType
Author:
rbarkhouse
Since:
EclipseLink 2.1

Constructor Summary
DynamicJAXBContextFactory()
           
 
Method Summary
static DynamicJAXBContext createContext(java.lang.Class[] classes, java.util.Map props)
          Unsupported Operation.
static DynamicJAXBContext createContext(java.lang.String sessionNames, java.lang.ClassLoader classLoader, java.util.Map<java.lang.String,?> props)
          Create a DynamicJAXBContext, using an EclipseLink sessions.xml as the metadata source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicJAXBContextFactory

public DynamicJAXBContextFactory()
Method Detail

createContext

public static DynamicJAXBContext createContext(java.lang.String sessionNames,
                                               java.lang.ClassLoader classLoader,
                                               java.util.Map<java.lang.String,?> props)
                                        throws JAXBException
Create a DynamicJAXBContext, using an EclipseLink sessions.xml as the metadata source. The sessionNames parameter is a colon-delimited list of session names within the sessions.xml file. Descriptors in this session's Project must not have javaClass set, but must have javaClassName set.

Parameters:
sessionNames - A colon-delimited String specifying the session names from the sessions.xml file.
classLoader - The application's current class loader, which will be used to first lookup classes to see if they exist before new DynamicTypes are generated. Can be null, in which case Thread.currentThread().getContextClassLoader() will be used.
Returns:
A new instance of DynamicJAXBContext.
Throws:
JAXBException - if an error was encountered while creating the DynamicJAXBContext.

createContext

public static DynamicJAXBContext createContext(java.lang.Class[] classes,
                                               java.util.Map props)
                                        throws JAXBException
Unsupported Operation. DynamicJAXBConexts can not be created from concrete classes. Use the standard JAXBContext to create a context from existing Classes.

Throws:
JAXBException
See Also:
JAXBContext

EclipseLink 2.1.0, build 'v20100311-r6779' API Reference