1 23 24 package com.sun.enterprise.deployment.node.connector; 25 26 import java.util.*; 27 import org.xml.sax.Attributes ; 28 import com.sun.enterprise.deployment.Descriptor; 29 import com.sun.enterprise.deployment.ConnectorDescriptor; 30 import com.sun.enterprise.deployment.AdminObject; 31 import com.sun.enterprise.deployment.xml.ConnectorTagNames; 32 import com.sun.enterprise.deployment.xml.TagNames; 33 import com.sun.enterprise.deployment.EnvironmentProperty; 34 import com.sun.enterprise.deployment.node.DescriptorFactory; 35 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 36 import com.sun.enterprise.deployment.node.ConfigurableNode; 37 import com.sun.enterprise.deployment.node.XMLElement; 38 39 import org.xml.sax.Attributes ; 40 import org.w3c.dom.Node ; 41 42 48 public class AdminObjectNode extends DeploymentDescriptorNode { 49 50 private AdminObject adminObject = null; 51 52 public AdminObjectNode() { 53 register(); 54 } 55 56 59 private void register() { 60 registerElementHandler(new XMLElement(ConnectorTagNames.CONFIG_PROPERTY), 61 ConfigPropertyNode.class); 62 } 63 64 70 71 protected Map getDispatchTable() { 72 Map table = super.getDispatchTable(); 73 table.put(ConnectorTagNames.ADMIN_OBJECT_INTERFACE, "setAdminObjectInterface"); 74 table.put(ConnectorTagNames.ADMIN_OBJECT_CLASS, "setAdminObjectClass"); 75 return table; 76 } 77 78 84 public void addDescriptor(Object obj) { 85 if (obj instanceof EnvironmentProperty) { 86 adminObject.addConfigProperty((EnvironmentProperty)obj); 87 } 88 } 89 90 93 public Object getDescriptor() { 94 if (adminObject == null) { 95 adminObject = (AdminObject) DescriptorFactory.getDescriptor(getXMLPath()); 96 } 97 return adminObject; 98 } 99 100 107 public Node writeDescriptor(Node parent, Descriptor descriptor) { 108 109 if (! (descriptor instanceof ConnectorDescriptor)) { 110 throw new IllegalArgumentException (getClass() + " cannot handle descriptors of type " + descriptor.getClass()); 111 } 112 113 for (Iterator adminObjects = ((ConnectorDescriptor)descriptor).getAdminObjects().iterator(); adminObjects.hasNext();) { 115 AdminObject adminObject = (AdminObject) adminObjects.next(); 116 Node adminObjectNode = appendChild(parent, ConnectorTagNames.ADMIN_OBJECT); 117 appendTextChild(adminObjectNode, ConnectorTagNames.ADMIN_OBJECT_INTERFACE, adminObject.getAdminObjectInterface()); 118 appendTextChild(adminObjectNode, ConnectorTagNames.ADMIN_OBJECT_CLASS, adminObject.getAdminObjectClass()); 119 120 ConfigPropertyNode config = new ConfigPropertyNode(); 121 adminObjectNode = config.writeDescriptor(adminObjectNode, adminObject); 122 } 123 124 return parent; 125 } 126 } 127 | Popular Tags |