Extensions : MetaData Entity Resolver


DataNucleus provides a pluggable framework whereby you can plug in your own DTD or XSD schema support. You can extend DataNucleuss capabilities using the plugin extension org.datanucleus.metadata_entityresolver.

An Entity Resolver extension point configuration is a list of XSDs schemas or DTDs. For XSD schemas, it needs only the schema location (URL in classpath), since the XML parser will take care of association of XML elements and namespaces to the schemas types. For DTDs, its a little less obvious since DTDs are not namespace aware, so the configuration must contain the URL location (location in classpath), DTD DOCTYPE (PUBLIC or SYSTEM), and the DTD identity.

An Entity Resolver has close relationship to the MetaData Handler extension point, since the MetaData Handler uses the Entity Resolvers to validate XML files. However, the Entity Resolvers configured via this plugin are only applicable to the org.datanucleus.metadata.xml.PluginEntityResolver instances, so the MetaData Handler must use the PluginEntityResolver Entity Resolver if it wants to use the schemas configured in this extension point.


The Entity Resolver implementation must extend the org.datanucleus.util.AbstractXMLEntityResolver class and must have a public constructor that takes the org.datanucleus.plugin.PluginManager class.

import org.datanucleus.plugin.PluginManager;
import org.datanucleus.util.AbstractXMLEntityResolver;

 * Implementation of an entity resolver for DTD/XSD files.
 * Handles entity resolution for files configured via plugins.
public class PluginEntityResolver extends AbstractXMLEntityResolver
    public PluginEntityResolver(PluginManager pm)
       publicIdEntities.put("identity...", "url....");
       systemIdEntities.put("identity...", "url....");