FileDocCategorySizeDatePackage
CmpResourceNode.javaAPI DocGlassfish v2 API6943Fri May 04 22:31:42 BST 2007com.sun.enterprise.deployment.node.runtime

CmpResourceNode

public class CmpResourceNode extends RuntimeDescriptorNode
This node handles the cmp-resource runtime xml tag
author
Jerome Dochez
version

Fields Summary
com.sun.enterprise.deployment.ResourceReferenceDescriptor
descriptor
Constructors Summary
public CmpResourceNode()
Creates new CmpResourceNode

    
        
      
        registerElementHandler(new XMLElement(RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL), 
                               DefaultResourcePrincipalNode.class, "setResourcePrincipal"); 
	registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY), 
				RuntimeNameValuePairNode.class, "addProperty");		
        registerElementHandler(new XMLElement(RuntimeTagNames.SCHEMA_GENERATOR_PROPERTIES), 
                                PropertiesNode.class, "setSchemaGeneratorProperties");
    
Methods Summary
public java.lang.ObjectgetDescriptor()

return
the descriptor instance to associate with this XMLNode

        return descriptor;
    
protected java.util.MapgetDispatchTable()
all sub-implementation of this class can use a dispatch table to map xml element to method name on the descriptor class for setting the element value.

return
the map with the element name as a key, the setter method as a value

    
        Map table = super.getDispatchTable();
        table.put(RuntimeTagNames.JNDI_NAME, "setJndiName");
        table.put(RuntimeTagNames.CREATE_TABLES_AT_DEPLOY, "setCreateTablesAtDeploy");
        table.put(RuntimeTagNames.DROP_TABLES_AT_UNDEPLOY, "setDropTablesAtUndeploy");
        table.put(RuntimeTagNames.DATABASE_VENDOR_NAME, "setDatabaseVendorName");
        return table;
    
public voidpostParsing()
notification of the end of XML parsing for this node

        EjbBundleDescriptor bd = (EjbBundleDescriptor) getParentNode().getDescriptor();
        if (bd==null) {
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
                    new Object[]{descriptor});
            return;
        }
        bd.setCMPResourceReference(descriptor);
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.ResourceReferenceDescriptor descriptor)
write the descriptor class to a DOM tree and return it

param
parent node for the DOM tree
param
the descriptor to write
return
the DOM tree top node

     
        Node cmp = super.writeDescriptor(parent, nodeName, descriptor);
        appendTextChild(cmp, RuntimeTagNames.JNDI_NAME, descriptor.getJndiName());
        if (descriptor.getResourcePrincipal() != null) {
            DefaultResourcePrincipalNode drpNode = new DefaultResourcePrincipalNode();
            drpNode.writeDescriptor(cmp, RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL, 
                descriptor.getResourcePrincipal());
        }
        // properties*
        Iterator properties = descriptor.getProperties();
	if (properties!=null) {
	    RuntimeNameValuePairNode propNode = new RuntimeNameValuePairNode();        
	    while (properties.hasNext()) {
		NameValuePairDescriptor aProp = (NameValuePairDescriptor) properties.next();
		propNode.writeDescriptor(cmp, RuntimeTagNames.PROPERTY, aProp);
	    }
	}
        
        // createTableAtDeploy, dropTableAtUndeploy
        if (descriptor.isCreateTablesAtDeploy()) {
            appendTextChild(cmp, RuntimeTagNames.CREATE_TABLES_AT_DEPLOY, RuntimeTagNames.TRUE);
        }
        if (descriptor.isDropTablesAtUndeploy()) {
            appendTextChild(cmp, RuntimeTagNames.DROP_TABLES_AT_UNDEPLOY, RuntimeTagNames.TRUE);
        }        
        // database vendor name
        appendTextChild(cmp, RuntimeTagNames.DATABASE_VENDOR_NAME, descriptor.getDatabaseVendorName());
        
        // schema-generator-properties?
        Properties schemaGeneratorProps = descriptor.getSchemaGeneratorProperties();
        if (schemaGeneratorProps!=null) {
            PropertiesNode pn = new PropertiesNode();
            pn.writeDescriptor(cmp, RuntimeTagNames.SCHEMA_GENERATOR_PROPERTIES, schemaGeneratorProps);
        }
        
        return cmp;