FileDocCategorySizeDatePackage
PersistenceUnitNode.javaAPI DocGlassfish v2 API6084Fri May 04 22:31:38 BST 2007com.sun.enterprise.deployment.node

PersistenceUnitNode

public class PersistenceUnitNode extends DeploymentDescriptorNode
This node is responsible for reading details about one
author
Sanjeeb.Sahoo@Sun.COM

Fields Summary
private Map
dispatchTable
map of element names to method names in {@link PersistenceUnitDescriptor}
Constructors Summary
public PersistenceUnitNode()
This is the default constructor which is also called from other constructors of this class. Inside this constructor, we clear the handlers set up by super classes' constructors because they are not applicable in the context of PersistenceNode because unlike standard Java EE schemas, persistence.xsd does not include javaee_5.xsd for things like description, version etc.

        // clear all the handlers set up by super classes
        // because that sets up a handler for description which we are not
        // interested in.
        if (handlers != null) handlers.clear();
        initDispatchTable();
    
Methods Summary
protected java.util.MapgetDispatchTable()
This returns the dispatch table for this node. Please note, unlike Java EE schemas persistence.xsd does not include standard elements or attributes (e.g. version, descriptionGroupRef etc.) from javaee_5.xsd, we don't use super classes' dispatch table.

return
map of element names to method names in PersistenceUnitDescriptor
see
super#getDispatchTable()
see
#initDispatchTable()

        return dispatchTable;
    
private voidinitDispatchTable()
Please note, unlike Java EE schemas persistence.xsd does not include standard elements or attributes (e.g. version, descriptionGroupRef etc.) from javaee_5.xsd, we don't use super classes' dispatch table.

        assert(dispatchTable == null);

        // we don't do super.getDispatchTable() because we are not
        // interested in any of super classes' disptcah table entries.
        Map<String, String> table = new HashMap<String, String>();

        // the values being put into the map represent method names
        // in PersistenceUnitDescriptor class.
        table.put(PersistenceTagNames.NAME, "setName");
        table.put(PersistenceTagNames.TRANSACTION_TYPE, "setTransactionType");
        table.put(PersistenceTagNames.DESCRIPTION, "setDescription");
        table.put(PersistenceTagNames.PROVIDER, "setProvider");
        table.put(PersistenceTagNames.JTA_DATA_SOURCE, "setJtaDataSource");
        table.put(PersistenceTagNames.NON_JTA_DATA_SOURCE,
                "setNonJtaDataSource");
        table.put(PersistenceTagNames.MAPPING_FILE, "addMappingFile");
        table.put(PersistenceTagNames.JAR_FILE, "addJarFile");
        table.put(PersistenceTagNames.EXCLUDE_UNLISTED_CLASSES, "setExcludeUnlistedClasses");
        table.put(PersistenceTagNames.CLASS, "addClass");
        this.dispatchTable = table;
    
public voidstartElement(XMLElement element, org.xml.sax.Attributes attributes)

        if (PersistenceTagNames.PROPERTY.equals(element.getQName())) {
            assert(attributes.getLength() == 2);
            assert(attributes.getIndex(PersistenceTagNames.PROPERTY_NAME) !=
                    -1);
            assert(attributes.getIndex(PersistenceTagNames.PROPERTY_VALUE) !=
                    -1);
            PersistenceUnitDescriptor persistenceUnitDescriptor = (PersistenceUnitDescriptor) getDescriptor();
            String propName = attributes.getValue(
                    PersistenceTagNames.PROPERTY_NAME);
            String propValue = attributes.getValue(
                    PersistenceTagNames.PROPERTY_VALUE);
            persistenceUnitDescriptor.addProperty(propName, propValue);
            return;
        }
        super.startElement(element, attributes);