1 23 24 29 30 package com.sun.enterprise.deployment.node.connector; 31 32 import java.util.*; 33 import org.xml.sax.Attributes ; 34 import com.sun.enterprise.deployment.Descriptor; 35 import com.sun.enterprise.deployment.OutboundResourceAdapter; 36 import com.sun.enterprise.deployment.ConnectionDefDescriptor; 37 import com.sun.enterprise.deployment.xml.ConnectorTagNames; 38 import com.sun.enterprise.deployment.xml.TagNames; 39 import com.sun.enterprise.deployment.EnvironmentProperty; 40 import com.sun.enterprise.deployment.node.DescriptorFactory; 41 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 42 import com.sun.enterprise.deployment.node.ConfigurableNode; 43 import com.sun.enterprise.deployment.node.XMLElement; 44 import com.sun.enterprise.deployment.util.DOLUtils; 45 import com.sun.enterprise.deployment.ConnectorDescriptor; 46 import com.sun.enterprise.deployment.node.XMLElement; 47 48 import org.xml.sax.Attributes ; 49 import org.w3c.dom.Node ; 50 51 57 public class ConnectionDefNode extends DeploymentDescriptorNode { 58 59 ConnectionDefDescriptor descriptor = null; 60 61 public final static XMLElement tag = new XMLElement(ConnectorTagNames.CONNECTION_DEFINITION); 62 63 public ConnectionDefNode() { 65 register(); 66 } 67 68 public ConnectionDefNode(XMLElement element) { 69 this.setXMLRootTag(element); 70 register(); 71 } 72 73 76 private void register() { 77 registerElementHandler(new XMLElement(ConnectorTagNames.CONFIG_PROPERTY), 78 ConfigPropertyNode.class); 79 } 80 81 84 public Object getDescriptor() { 85 if (descriptor==null) { 86 89 descriptor = (ConnectionDefDescriptor)DescriptorFactory.getDescriptor(getXMLPath()); 90 ((OutboundResourceAdapter)(getParentNode().getDescriptor())).addConnectionDefDescriptor(descriptor); 91 92 } 93 return descriptor; 94 } 95 96 102 public void addDescriptor(Object obj) { 103 if (obj instanceof EnvironmentProperty) { 104 descriptor.addConfigProperty((EnvironmentProperty)obj); 105 } 106 } 107 108 114 protected Map getDispatchTable() { 115 Map table = super.getDispatchTable(); 117 118 table.put(ConnectorTagNames.MANAGED_CONNECTION_FACTORY, "setManagedConnectionFactoryImpl"); 119 table.put(ConnectorTagNames.CONNECTION_FACTORY_INTF, "setConnectionFactoryIntf"); 120 table.put(ConnectorTagNames.CONNECTION_FACTORY_IMPL, "setConnectionFactoryImpl"); 121 table.put(ConnectorTagNames.CONNECTION_INTF, "setConnectionIntf"); 122 table.put(ConnectorTagNames.CONNECTION_IMPL, "setConnectionImpl"); 123 124 return table; 125 } 126 127 128 129 132 public void startElement(XMLElement element, Attributes attributes) { 133 super.startElement(element, attributes); 136 } 137 138 145 public Node writeDescriptor(Node parent, Descriptor desc) { 146 148 if (!(desc instanceof OutboundResourceAdapter)) { 149 throw new IllegalArgumentException (getClass() + " cannot handle descriptors of type " + descriptor.getClass()); 150 } 151 Iterator connectionDefs = null; 152 connectionDefs = ((OutboundResourceAdapter)desc).getConnectionDefs().iterator(); 153 154 for (;connectionDefs.hasNext();) { 156 ConnectionDefDescriptor con = (ConnectionDefDescriptor) connectionDefs.next(); 157 Node conNode = appendChild(parent, ConnectorTagNames.CONNECTION_DEFINITION); 158 appendTextChild(conNode, ConnectorTagNames.MANAGED_CONNECTION_FACTORY, con.getManagedConnectionFactoryImpl()); 159 160 ConfigPropertyNode config = new ConfigPropertyNode(); 161 conNode = config.writeDescriptor(conNode, con); 162 163 appendTextChild(conNode, ConnectorTagNames.CONNECTION_FACTORY_INTF, con.getConnectionFactoryIntf()); 164 appendTextChild(conNode, ConnectorTagNames.CONNECTION_FACTORY_IMPL, con.getConnectionFactoryImpl()); 165 appendTextChild(conNode, ConnectorTagNames.CONNECTION_INTF, con.getConnectionIntf()); 166 appendTextChild(conNode, ConnectorTagNames.CONNECTION_IMPL, con.getConnectionImpl()); 167 } 168 return parent; 169 } 170 } 171 | Popular Tags |