Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "User:Rick.barkhouse.oracle.com"

Line 57: Line 57:
  
 
<source lang="java">
 
<source lang="java">
 +
...
 
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
 
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
  
Line 68: Line 69:
 
Map<String, Object> props = new HashMap<String, Object>(1);
 
Map<String, Object> props = new HashMap<String, Object>(1);
 
props.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY, metadataDocument);
 
props.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY, metadataDocument);
JAXBContext jc = JAXBContextFactory.createContext(new Class[] { Root.class }, props);
+
JAXBContext context = JAXBContextFactory.createContext(new Class[] { Root.class }, props);
 +
...
 
</source>
 
</source>

Revision as of 11:14, 17 June 2011

bugzilla id: rick.barkhouse (at) oracle.com

committer id: rbarkhous

Location: Ottawa, Canada - Eastern Standard Time

  • Committer on Eclipse Persistence Services project - EclipseLink

Profession: Software Engineer

Currently working for Oracle Corporation on their TopLink product.

Also working with Eclipse Foundation on their EclipseLink product.





Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source

Refreshing Metadata

EclipseLink MOXy 2.3 introduces the ability to refresh your JAXBContext's metadata at runtime. This allows you to make changes to existing mappings in a live application environment and see those changes immediately without having to create a new JAXBContext.

In order to use the Metadata Refresh feature, your metadata information must be provided as either Node(s) or MetadataSource.

Example

Our example will be bootstrapped from the following EclipseLink OXM file:

<?xml version="1.0"?>
<xml-bindings
    xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
    package-name="example">
    <java-types>
        <java-type name="Root">
            <java-attributes>
                <xml-element java-attribute="name" name="orig-name"/>
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>

Our JAXBContext is created in the standard way:

...
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
 
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream metadataStream = classLoader.getResourceAsStream("example/eclipselink-oxm.xml";
Document metadataDocument = db.parse(metadataStream);
metadataStream.close();
 
Map<String, Object> props = new HashMap<String, Object>(1);
props.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY, metadataDocument);
JAXBContext context = JAXBContextFactory.createContext(new Class[] { Root.class }, props);
...

Back to the top