1 23 24 29 30 package com.sun.enterprise.deployment.node.connector; 31 32 import java.util.*; 33 import org.w3c.dom.Node ; 34 import org.xml.sax.Attributes ; 35 import java.util.logging.Level ; 36 37 import com.sun.enterprise.deployment.EnvironmentProperty; 38 import com.sun.enterprise.deployment.ConnectorDescriptor; 39 import com.sun.enterprise.deployment.Descriptor; 40 import com.sun.enterprise.deployment.node.DescriptorFactory; 41 import com.sun.enterprise.deployment.AdminObject; 42 import com.sun.enterprise.deployment.node.BundleNode; 43 import com.sun.enterprise.deployment.xml.ConnectorTagNames; 44 import com.sun.enterprise.deployment.xml.TagNames; 45 import com.sun.enterprise.deployment.node.XMLElement; 46 import com.sun.enterprise.deployment.node.RootXMLNode; 47 import com.sun.enterprise.deployment.node.XMLNode; 48 import com.sun.enterprise.deployment.MessageListener; 49 import com.sun.enterprise.deployment.node.connector.MessageListenerNode; 50 import com.sun.enterprise.deployment.util.DOLUtils; 51 52 53 58 public class ConnectorNode extends BundleNode implements RootXMLNode { 59 60 private ConnectorDescriptor descriptor; 62 public static String VERSION_10 = "1.0"; 63 public static String VERSION_15 = "1.5"; 64 private String specVersion; 65 66 public final static String PUBLIC_DTD_ID_10 = "-//Sun Microsystems, Inc.//DTD Connector 1.0//EN"; 68 public final static String SYSTEM_ID_10 = "http://java.sun.com/dtd/connector_1_0.dtd"; 69 70 71 public final static String PUBLIC_DTD_ID = "-//Sun Microsystems, Inc.//DTD Connector 1.5//EN"; 73 public final static String SYSTEM_ID = "http://java.sun.com/dtd/connector_1_5.dtd"; 74 75 public final static String SCHEMA_ID = "connector_1_5.xsd"; 76 public final static String SPEC_VERSION = VERSION_15; 77 private static List<String > systemIDs = null; 78 79 public final static XMLElement tag = new XMLElement(ConnectorTagNames.CONNECTOR); 80 81 87 public static String registerBundle(Map publicIDToDTD) { 88 publicIDToDTD.put(PUBLIC_DTD_ID, SYSTEM_ID); 89 publicIDToDTD.put(PUBLIC_DTD_ID_10, SYSTEM_ID_10); 90 return tag.getQName(); 91 } 92 93 public ConnectorNode() { 94 super(); 95 registerElementHandler(new XMLElement(ConnectorTagNames.LICENSE), 96 LicenseNode.class, "setLicenseDescriptor"); 97 } 98 99 100 103 public Object getDescriptor() { 104 if (descriptor == null) { 105 descriptor = (ConnectorDescriptor) DescriptorFactory.getDescriptor(getXMLPath()); 106 } 107 return descriptor; 108 } 109 110 118 protected boolean setAttributeValue(XMLElement elementName, 119 XMLElement attributeName, String value) { 120 getDescriptor(); 121 if (descriptor==null) { 122 throw new RuntimeException ( 123 "Trying to set values on a null descriptor"); 124 } 125 if (attributeName.getQName().equals(ConnectorTagNames.VERSION)) { 128 descriptor.setSpecVersion(value); 129 specVersion = value; 130 return true; 131 } else if (attributeName.getQName().equals(TagNames.ID)) { 132 return true; 134 } 135 136 return false; 137 } 138 139 145 public void setElementValue(XMLElement element, String value) { 146 getDescriptor(); 147 if (descriptor==null) { 148 throw new RuntimeException ( 149 "Trying to set values on a null descriptor"); 150 } if (ConnectorTagNames.SPEC_VERSION.equals(element.getQName())) { 151 descriptor.setSpecVersion(value); 152 specVersion = value; 153 } else if (ConnectorTagNames.VERSION.equals(element.getQName())) { 156 descriptor.setResourceAdapterVersion(value); 157 } else 158 super.setElementValue(element, value); 159 } 160 161 165 public boolean handlesElement(XMLElement element) { 166 if (ConnectorTagNames.RESOURCE_ADAPTER.equals(element.getQName())) { 167 return false; 168 } 169 return super.handlesElement(element); 170 } 171 172 175 public XMLNode getHandlerFor(XMLElement element) { 176 if (ConnectorTagNames.RESOURCE_ADAPTER.equals(element.getQName())) { 177 180 if (VERSION_10.equals(specVersion)) { 181 OutBoundRANode outboundRANode = new OutBoundRANode(element); 182 outboundRANode.setParentNode(this); 183 outboundRANode.createConDefDescriptorFor10(); 184 return outboundRANode; 185 } else { 186 RANode raNode = new RANode(element); 187 raNode.setParentNode(this); 188 return raNode; 189 } 190 } else { 191 return super.getHandlerFor(element); 192 } 193 } 194 195 198 protected XMLElement getXMLRootTag() { 199 return tag; 200 } 201 202 208 public void addDescriptor(Object newDescriptor) { 209 } 210 211 217 protected Map getDispatchTable() { 218 Map table = super.getDispatchTable(); 220 table.put(ConnectorTagNames.VENDOR_NAME, "setVendorName"); 221 table.put(ConnectorTagNames.EIS_TYPE, "setEisType"); 222 223 table.put(ConnectorTagNames.RESOURCEADAPTER_VERSION, "setResourceAdapterVersion"); 225 226 return table; 227 } 228 229 232 public String getDocType() { 233 return null; 234 } 235 236 239 public String getSystemID() { 240 return SCHEMA_ID; 241 } 242 243 246 public List<String > getSystemIDs() { 247 if (systemIDs != null) { 248 return systemIDs; 249 } 250 251 systemIDs = new ArrayList<String >(); 252 systemIDs.add(SCHEMA_ID); 253 return systemIDs; 254 } 255 256 263 public Node writeDescriptor(Node parent, Descriptor descriptor) { 264 265 if (! (descriptor instanceof ConnectorDescriptor)) { 266 throw new IllegalArgumentException (getClass() + " cannot handle descriptors of type " + descriptor.getClass()); 267 } 268 ConnectorDescriptor conDesc = (ConnectorDescriptor) descriptor; 269 conDesc.setSpecVersion(VERSION_15); 270 Node connectorNode = super.writeDescriptor(parent, conDesc); 271 appendTextChild(connectorNode, ConnectorTagNames.VENDOR_NAME, conDesc.getVendorName()); 272 appendTextChild(connectorNode, ConnectorTagNames.EIS_TYPE, conDesc.getEisType()); 273 appendTextChild(connectorNode, ConnectorTagNames.RESOURCEADAPTER_VERSION, conDesc.getResourceAdapterVersion()); 274 275 LicenseNode licenseNode = new LicenseNode(); 277 connectorNode = licenseNode.writeDescriptor(connectorNode, conDesc); 278 279 RANode raNode = new RANode(); 281 connectorNode = raNode.writeDescriptor(connectorNode, conDesc); 282 return connectorNode; 283 } 284 285 288 public String getSpecVersion() { 289 return SPEC_VERSION; 290 } 291 292 295 protected String getSchemaURL() { 296 return TagNames.J2EE_NAMESPACE + "/" + getSystemID(); 297 } 298 } 299 | Popular Tags |