An XMLContext is created based on EclipseLink sessions or projects and can then used to create instances of XMLMarshaller, XMLUnmarshaller and XMLValidator.
There are constructors to create an XMLContext with a single EclipseLink project or with a String which is a single EclipseLink session name or a ':' separated list of EclipseLink session names.
Code Sample
XMLContext context = new XMLContext("mySessionName");
XMLMarshaller marshaller = context.createMarshaller();
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
XMLValidator validator = context.createValidator();
The XMLContext is thread-safe. If multiple threads accessing the same XMLContext object request an XMLMarshaller, each will receive their own instance of XMLMarshaller, so any state that the XMLMarshaller maintains will be unique to that process. The same is true of instances of XMLUnmarshaller and XMLValidator.
org.eclipse.persistence.oxm.XMLMarshaller , org.eclipse.persistence.oxm.XMLUnmarshaller , org.eclipse.persistence.oxm.XMLValidator
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| public | XMLContext(String
A single session name or multiple session names separated by a : sessionNames)Create a new XMLContext based on the specified session name or list of session names |
| public | XMLContext(String
A single session name or multiple session names separated by a : sessionNames, ClassLoader classloader for loading sessions.xml classLoader)Create a new XMLContext based on the specified session name or list of session names |
| public | XMLContext(String
A single session name or multiple session names separated by
a: sessionNames, String path to XML file containing session meta data to initialize
and load sessions. xmlResource)Create a new XMLContext based on passed in session names and session meta XML. |
| public | XMLContext(String
A single session name or multiple session names separated by a : sessionNames, ClassLoader classloader for loading sessions.xml classLoader, String path to XML file containing session meta data to initialize
and load sessions. xmlResource)Create a new XMLContext based on passed in session names, classloader and session meta XML. |
| public | XMLContext(Project
An EclipseLink project project)Create a new XMLContext based on the specified project |
| public | XMLContext(Project
An EclipseLink project project, ClassLoader The ClassLoader to be used classLoader)Create a new XMLContext based on the specified Project and ClassLoader. |
| public | XMLContext(Project
An EclipseLink project project, ClassLoader The ClassLoader to be used classLoader, SessionEventListener If non-null, this listener will be registered with the SessionEventManager sessionEventListener)Create a new XMLContext based on the specified Project and ClassLoader. |
| public | XMLContext(Project
An EclipseLink project project, ClassLoader The ClassLoader to be used classLoader, Collection<SessionEventListener> If non-null, these listeners will be registered with the SessionEventManager sessionEventListeners)Create a new XMLContext based on the specified Project and ClassLoader. |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | addSession(DatabaseSession sessionToAdd)
INTERNAL: Add and initialize a new session to the list of sessions associated with this XMLContext. |
| public void | applyORMMetadata(AbstractSession ormSession)
ADVANCED: Adjust the OXM metadata to take into account ORM mapping metadata, |
| public XMLBinder | |
| public XMLBinder | Returns: an XMLBinder based on this XMLContext,Create a new XMLBinder with supplied marshaller and unmarshaller instances. |
| public Object | Returns: An instance of the Java class mapped to the indicated XML type, or null if no result was found.The namespace of the complex type to create a new Java instance of. namespace, String The XML type name to create a new Java instance of. typeName, boolean True if the object to be created represents a global type, false if it
represents a global element. isGlobalType)Create a new object instance for a given XML namespace and name. |
| public < The return type of this method corresponds to the returnType parameter. T> T | Returns: An instance of the Java class mapped to the supplied XML type, or null if no result was found.The XPath will be executed relative to this object. parentObject, String The XPath statement. xPath, NamespaceResolver A NamespaceResolver containing the prefix/URI pairings from the XPath statement. namespaceResolver, Class<T> The return type. returnType)Overrides org. |
| protected XMLField | createField(String path)
Implements abstract org. |
| public XMLMarshaller | Returns: An XMLMarshaller based on this XMLContextImplements abstract org. |
| public XMLUnmarshaller | Returns: An XMLUnmarshaller based on this XMLContextImplements abstract org. |
| public XMLUnmarshaller | Returns: An XMLUnmarshaller based on this XMLContext, the underlying parser will use the passed in parser features.Create a new XMLUnmarshaller
Map<String, Boolean> parserFeatures = new HashMap<String, Boolean>(1);
parserFeatures.put("http://apache.org/xml/features/validation/schema/normalized-value", false);
XMLUnmarshaller unmarshaller = xmlContext.createUnmarshaller(parserFeatures);
|
| public XMLValidator | |
| public XMLDescriptor | getDescriptor(QName qName)
Overrides org. |
| public XMLDescriptor | getDescriptor(XPathQName xpathQName)
Overrides org. |
| public XMLDescriptor | getDescriptorByGlobalType(XPathFragment<XML_FIELD extends Field> xPathFragment)
Overrides org. |
| public Descriptor | Returns: descriptor for given objectReturns descriptor for given object. |
| public List | |
| public DocumentPreservationPolicy | getDocumentPreservationPolicy(AbstractSession session)
INTERNAL: Return the DocumentPreservationPolicy associated with this session |
| public ConversionManager | Returns: conversion managerReturns conversion manager from session datasource platform. |
| public AbstractSession | |
| public AbstractSession | |
| public AbstractSession | getReadSession(XMLDescriptor xmlDescriptor)
INTERNAL: Return the session corresponding to this XMLDescriptor. |
| public DatabaseSession | getSession(int index)
Overrides org.
XMLContext xmlContext = new XMLContext("path0:path1");
DatabaseSession session = xmlContext.getSession(0); // returns session for path0
|
| public AbstractSession | getSession(Object object)
Overrides org. |
| public AbstractSession | getSession(Class<?> clazz)
Overrides org. |
| public AbstractSession | getSession(XMLDescriptor xmlDescriptor)
Overrides org. |
| public List | |
| public < The return type of this method corresponds to the returnType parameter. T> T | Returns: The object corresponding to the XPath or null if no result was found.The XPath will be executed relative to this object. object, String The XPath statement xPath, NamespaceResolver A NamespaceResolver containing the prefix/URI pairings from the XPath statement. namespaceResolver, Class<T> The return type. returnType)Overrides org. Query the object model based on the corresponding XML document. |
| public XMLContext. | getXMLContextState()
INTERNAL: Return the XMLContextState that represents the XMLContexts stateful information. |
| public boolean | hasDocumentPreservation()
Implements abstract org. |
| private static ClassLoader | |
| public void | |
| public void | setValueByXPath(Object
The XPath will be executed relative to this object. object, String The XPath statement xPath, NamespaceResolver A NamespaceResolver containing the prefix/URI pairings from the XPath statement. namespaceResolver, Object The value to be set. value)Overrides org. Set values in the object model based on the corresponding XML document. |
| public void | setXMLContextState(XMLContext.
INTERNAL: Set the stateful information for this XMLContext. |
| public void |