FileDocCategorySizeDatePackage
ConnectorNode.javaAPI DocGlassfish v2 API11247Fri May 04 22:31:40 BST 2007com.sun.enterprise.deployment.node.connector

ConnectorNode

public class ConnectorNode extends com.sun.enterprise.deployment.node.BundleNode implements com.sun.enterprise.deployment.node.RootXMLNode
The top connector node class
author
Sheetal Vartak
version

Fields Summary
private com.sun.enterprise.deployment.ConnectorDescriptor
descriptor
public static final String
VERSION_10
public static final String
VERSION_15
private String
specVersion
public static final String
PUBLIC_DTD_ID_10
public static final String
SYSTEM_ID_10
public static final String
PUBLIC_DTD_ID
public static final String
SYSTEM_ID
public static final String
SCHEMA_ID
public static final String
SPEC_VERSION
private static final List
systemIDs
public static final com.sun.enterprise.deployment.node.XMLElement
tag
Constructors Summary
public ConnectorNode()

        super();
        registerElementHandler(new XMLElement(ConnectorTagNames.LICENSE), 
            LicenseNode.class, "setLicenseDescriptor");
    
Methods Summary
public voidaddDescriptor(java.lang.Object newDescriptor)
Adds a new DOL descriptor instance to the descriptor instance associated with this XMLNode

param
descriptor the new descriptor

    
public java.lang.ObjectgetDescriptor()

return
the descriptor instance to associate with this XMLNode

        if (descriptor == null) {
            descriptor = (ConnectorDescriptor) DescriptorFactory.getDescriptor(getXMLPath());
        } 
        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

        // no need to be synchronized for now
        Map table = super.getDispatchTable();
        table.put(ConnectorTagNames.VENDOR_NAME, "setVendorName");
	table.put(ConnectorTagNames.EIS_TYPE, "setEisType");

	// support for 1.0 DTD and 1.5 schema and not 1.5 DTD
	table.put(ConnectorTagNames.RESOURCEADAPTER_VERSION, "setResourceAdapterVersion");

        return table;
    
public java.lang.StringgetDocType()

return
the DOCTYPE of the XML file

	return null;
    
public com.sun.enterprise.deployment.node.XMLNodegetHandlerFor(com.sun.enterprise.deployment.node.XMLElement element)

return
the handler registered for the subtag element of the curent XMLNode

	if (ConnectorTagNames.RESOURCE_ADAPTER.equals(element.getQName())) {
	    /** For resourceadapter tag, we need to find out what version of DTD we are handling 
	    * in order to correctly read/write the XML file
	    */
	    if (VERSION_10.equals(specVersion)) {
		OutBoundRANode outboundRANode = new OutBoundRANode(element);
		outboundRANode.setParentNode(this);
		outboundRANode.createConDefDescriptorFor10();
		return outboundRANode;
	    } else  {
		RANode raNode = new RANode(element);
		raNode.setParentNode(this);
		return raNode;
	    } 
	} else {
	    return super.getHandlerFor(element);
	}
    
protected java.lang.StringgetSchemaURL()

return
the schema URL

        return TagNames.J2EE_NAMESPACE + "/" + getSystemID();
    
public java.lang.StringgetSpecVersion()

return
the default spec version level this node complies to

        return SPEC_VERSION;
    
public java.lang.StringgetSystemID()

return
the SystemID of the XML file

	    return SCHEMA_ID;
    
public java.util.ListgetSystemIDs()

return
the list of SystemID of the XML schema supported

        return systemIDs;
    
protected com.sun.enterprise.deployment.node.XMLElementgetXMLRootTag()

return
the XML tag associated with this XMLNode

        return tag;
    
public booleanhandlesElement(com.sun.enterprise.deployment.node.XMLElement element)

return
true if the element tag can be handled by any registered sub nodes of the current XMLNode

	if (ConnectorTagNames.RESOURCE_ADAPTER.equals(element.getQName())) {
            return false;
	} 
	return super.handlesElement(element);
    
private static java.util.ListinitSystemIDs()


        
        List<String> systemIDs = new ArrayList<String>();
        systemIDs.add(SCHEMA_ID);
        return Collections.unmodifiableList(systemIDs);
    
public static java.lang.StringregisterBundle(java.util.Map publicIDToDTD)
register this node as a root node capable of loading entire DD files

param
publicIDToDTD is a mapping between xml Public-ID to DTD
return
the doctype tag name

        publicIDToDTD.put(PUBLIC_DTD_ID, SYSTEM_ID);
        publicIDToDTD.put(PUBLIC_DTD_ID_10, SYSTEM_ID_10);
        return tag.getQName();
   
protected booleansetAttributeValue(com.sun.enterprise.deployment.node.XMLElement elementName, com.sun.enterprise.deployment.node.XMLElement attributeName, java.lang.String value)
parsed an attribute of an element

param
the element name
param
the attribute name
param
the attribute value
return
true if the attribute was processed

        getDescriptor();
        if (descriptor==null) {
            throw new RuntimeException(
                "Trying to set values on a null descriptor");
        }
        // the version attribute value is the spec version we use
        // and it's only available from schema based xml
        if (attributeName.getQName().equals(ConnectorTagNames.VERSION)) {
	    descriptor.setSpecVersion(value);
            specVersion = value;
            return true;
        } else if (attributeName.getQName().equals(TagNames.ID)) {
            // we do not support id attribute for the moment
            return true;
        }

        return false;
    
public voidsetElementValue(com.sun.enterprise.deployment.node.XMLElement element, java.lang.String value)
receives notification of the value for a particular tag

param
element the xml element
param
value it's associated value

        
        getDescriptor();
        if (descriptor==null) {
            throw new RuntimeException(
                "Trying to set values on a null descriptor");
        } if (ConnectorTagNames.SPEC_VERSION.equals(element.getQName())) {
	    descriptor.setSpecVersion(value);
            specVersion = value;
        // the version element value is the resourve adapter version
        // and it's only available from dtd based xml
        } else if (ConnectorTagNames.VERSION.equals(element.getQName())) {
            descriptor.setResourceAdapterVersion(value);
        } else
	super.setElementValue(element, value);
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, com.sun.enterprise.deployment.Descriptor 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


        if (! (descriptor instanceof ConnectorDescriptor)) {
            throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
        }
        ConnectorDescriptor conDesc = (ConnectorDescriptor) descriptor;
	conDesc.setSpecVersion(VERSION_15);
        Node connectorNode = super.writeDescriptor(parent, conDesc);      
	appendTextChild(connectorNode, ConnectorTagNames.VENDOR_NAME, conDesc.getVendorName());  
	appendTextChild(connectorNode, ConnectorTagNames.EIS_TYPE, conDesc.getEisType()); 
	appendTextChild(connectorNode, ConnectorTagNames.RESOURCEADAPTER_VERSION, conDesc.getResourceAdapterVersion());   

	//license info
        LicenseNode licenseNode = new LicenseNode();
        connectorNode = licenseNode.writeDescriptor(connectorNode, conDesc);

	// resource adapter node
	RANode raNode = new RANode();
	connectorNode = raNode.writeDescriptor(connectorNode, conDesc);  
	return connectorNode;