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

ConnectionDefNode

public class ConnectionDefNode extends com.sun.enterprise.deployment.node.DeploymentDescriptorNode
This node signifies the connection-definition tag in Connector DTD
author
Sheetal Vartak
version

Fields Summary
com.sun.enterprise.deployment.ConnectionDefDescriptor
descriptor
public static final com.sun.enterprise.deployment.node.XMLElement
tag
Constructors Summary
public ConnectionDefNode()

    
    //default constructor...for normal operation in case of 1.5 DTD
      
	register();
    
public ConnectionDefNode(com.sun.enterprise.deployment.node.XMLElement element)

	this.setXMLRootTag(element);
	register();
    
Methods Summary
public voidaddDescriptor(java.lang.Object obj)
Adds a new DOL descriptor instance to the descriptor instance associated with this XMLNode

param
descriptor the new descriptor

	if (obj instanceof EnvironmentProperty) {
	    descriptor.addConfigProperty((EnvironmentProperty)obj);
	}
    
public java.lang.ObjectgetDescriptor()

return
the descriptor instance to associate with this XMLNode

        if (descriptor==null) {
	    // the descriptor associated with the ConnectionDefNode is a ConnectionDefDescriptor 
	    // This descriptor is available with the parent node of the ConnectionDefNode

	    descriptor = (ConnectionDefDescriptor)DescriptorFactory.getDescriptor(getXMLPath());
	    ((OutboundResourceAdapter)(getParentNode().getDescriptor())).addConnectionDefDescriptor(descriptor);

	} 
        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.MANAGED_CONNECTION_FACTORY, "setManagedConnectionFactoryImpl");
	table.put(ConnectorTagNames.CONNECTION_FACTORY_INTF, "setConnectionFactoryIntf");
	table.put(ConnectorTagNames.CONNECTION_FACTORY_IMPL, "setConnectionFactoryImpl");
	table.put(ConnectorTagNames.CONNECTION_INTF, "setConnectionIntf");
	table.put(ConnectorTagNames.CONNECTION_IMPL, "setConnectionImpl");

        return table;
    
private voidregister()
method for registering the handlers with the various tags

	registerElementHandler(new XMLElement(ConnectorTagNames.CONFIG_PROPERTY),
			       ConfigPropertyNode.class); 
    
public voidstartElement(com.sun.enterprise.deployment.node.XMLElement element, org.xml.sax.Attributes attributes)
SAX Parser API implementation, we don't really care for now.

	//FIXME : remove the foll line once connector stuff works properly
	//((ConnectionDefDescriptor)getDescriptor()).setOutBoundDefined(true);
	super.startElement(element, attributes);
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, com.sun.enterprise.deployment.Descriptor desc)
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

  
	//connection definition info
	
	if (!(desc instanceof OutboundResourceAdapter)) {
            throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
        }
	Iterator connectionDefs = null;
	connectionDefs = ((OutboundResourceAdapter)desc).getConnectionDefs().iterator();
	
	//connection-definitions
	for (;connectionDefs.hasNext();) {
	    ConnectionDefDescriptor con = (ConnectionDefDescriptor) connectionDefs.next();
	    Node conNode = appendChild(parent, ConnectorTagNames.CONNECTION_DEFINITION);
	    appendTextChild(conNode, ConnectorTagNames.MANAGED_CONNECTION_FACTORY, con.getManagedConnectionFactoryImpl());
	    
	    ConfigPropertyNode config = new ConfigPropertyNode();
	    conNode = config.writeDescriptor(conNode, con);
	    
	    appendTextChild(conNode, ConnectorTagNames.CONNECTION_FACTORY_INTF, con.getConnectionFactoryIntf());  
	    appendTextChild(conNode, ConnectorTagNames.CONNECTION_FACTORY_IMPL, con.getConnectionFactoryImpl());
	    appendTextChild(conNode, ConnectorTagNames.CONNECTION_INTF, con.getConnectionIntf());
	    appendTextChild(conNode, ConnectorTagNames.CONNECTION_IMPL, con.getConnectionImpl());
	}
	return parent;