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.OutboundResourceAdapter; 31 import com.sun.enterprise.deployment.AdminObject; 32 import com.sun.enterprise.deployment.ConnectionDefDescriptor; 33 import com.sun.enterprise.deployment.xml.ConnectorTagNames; 34 import com.sun.enterprise.deployment.xml.TagNames; 35 import com.sun.enterprise.deployment.EnvironmentProperty; 36 import com.sun.enterprise.deployment.node.DescriptorFactory; 37 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 38 import com.sun.enterprise.deployment.node.ConfigurableNode; 39 import com.sun.enterprise.deployment.node.XMLElement; 40 41 import org.xml.sax.Attributes ; 42 import org.w3c.dom.Node ; 43 44 50 public class ConfigPropertyNode extends DeploymentDescriptorNode { 51 52 private EnvironmentProperty config = null; 53 54 60 protected Map getDispatchTable() { 61 Map table = super.getDispatchTable(); 62 table.put(ConnectorTagNames.CONFIG_PROPERTY_NAME, "setName"); 63 table.put(ConnectorTagNames.CONFIG_PROPERTY_VALUE, "setValue"); 64 table.put(ConnectorTagNames.CONFIG_PROPERTY_TYPE, "setType"); 65 return table; 66 } 67 68 71 public Object getDescriptor() { 72 if (config == null) { 73 config = (EnvironmentProperty) DescriptorFactory.getDescriptor(getXMLPath()); 74 } 75 return config; 76 } 77 78 85 public Node writeDescriptor(Node parent, Descriptor descriptor) { 86 87 if (! (descriptor instanceof ConnectorDescriptor) && 88 ! (descriptor instanceof AdminObject) && 89 ! (descriptor instanceof ConnectionDefDescriptor) && 90 ! (descriptor instanceof OutboundResourceAdapter)) { 91 throw new IllegalArgumentException (getClass() + " cannot handle descriptors of type " + descriptor.getClass()); 92 } 93 Iterator configProps = null; 94 if (descriptor instanceof ConnectorDescriptor) { 95 configProps = ((ConnectorDescriptor)descriptor).getConfigProperties().iterator(); 96 } else if (descriptor instanceof ConnectionDefDescriptor) { 97 configProps = ((ConnectionDefDescriptor)descriptor).getConfigProperties().iterator(); 98 } else if (descriptor instanceof AdminObject) { 99 configProps = ((AdminObject)descriptor).getConfigProperties().iterator(); 100 } else if (descriptor instanceof OutboundResourceAdapter) { 101 configProps = ((OutboundResourceAdapter)descriptor).getConfigProperties().iterator(); 102 } 103 for (;configProps.hasNext();) { 105 EnvironmentProperty config = (EnvironmentProperty) configProps.next(); 106 Node configNode = appendChild(parent, ConnectorTagNames.CONFIG_PROPERTY); 107 writeLocalizedDescriptions(configNode, config); 108 appendTextChild(configNode, ConnectorTagNames.CONFIG_PROPERTY_NAME, config.getName()); 109 appendTextChild(configNode, ConnectorTagNames.CONFIG_PROPERTY_TYPE, config.getType()); 110 appendTextChild(configNode, ConnectorTagNames.CONFIG_PROPERTY_VALUE, config.getValue()); 111 } 112 return parent; 113 } 114 } 115 | Popular Tags |