1 23 24 package com.sun.enterprise.deployment.node.runtime; 25 26 import java.util.Map ; 27 import java.util.Iterator ; 28 import java.util.Properties ; 29 import java.util.logging.Level ; 30 import org.w3c.dom.Node ; 31 32 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 33 import com.sun.enterprise.deployment.NameValuePairDescriptor; 34 import com.sun.enterprise.deployment.EjbBundleDescriptor; 35 import com.sun.enterprise.deployment.node.XMLElement; 36 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 37 import com.sun.enterprise.deployment.node.runtime.common.RuntimeNameValuePairNode; 38 import com.sun.enterprise.deployment.node.PropertiesNode; 39 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 40 import com.sun.enterprise.deployment.util.DOLUtils; 41 42 48 public class CmpResourceNode extends RuntimeDescriptorNode { 49 50 ResourceReferenceDescriptor descriptor= new ResourceReferenceDescriptor(); 51 52 53 public CmpResourceNode() { 54 registerElementHandler(new XMLElement(RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL), 55 DefaultResourcePrincipalNode.class, "setResourcePrincipal"); 56 registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY), 57 RuntimeNameValuePairNode.class, "addProperty"); 58 registerElementHandler(new XMLElement(RuntimeTagNames.SCHEMA_GENERATOR_PROPERTIES), 59 PropertiesNode.class, "setSchemaGeneratorProperties"); 60 } 61 62 65 public Object getDescriptor() { 66 return descriptor; 67 } 68 69 75 protected Map getDispatchTable() { 76 Map table = super.getDispatchTable(); 77 table.put(RuntimeTagNames.JNDI_NAME, "setJndiName"); 78 table.put(RuntimeTagNames.CREATE_TABLES_AT_DEPLOY, "setCreateTablesAtDeploy"); 79 table.put(RuntimeTagNames.DROP_TABLES_AT_UNDEPLOY, "setDropTablesAtUndeploy"); 80 table.put(RuntimeTagNames.DATABASE_VENDOR_NAME, "setDatabaseVendorName"); 81 return table; 82 } 83 84 87 public void postParsing() { 88 EjbBundleDescriptor bd = (EjbBundleDescriptor) getParentNode().getDescriptor(); 89 if (bd==null) { 90 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", 91 new Object []{descriptor}); 92 return; 93 } 94 bd.setCMPResourceReference(descriptor); 95 } 96 97 104 public Node writeDescriptor(Node parent, String nodeName, 105 ResourceReferenceDescriptor descriptor) { 106 Node cmp = super.writeDescriptor(parent, nodeName, descriptor); 107 appendTextChild(cmp, RuntimeTagNames.JNDI_NAME, descriptor.getJndiName()); 108 if (descriptor.getResourcePrincipal() != null) { 109 DefaultResourcePrincipalNode drpNode = new DefaultResourcePrincipalNode(); 110 drpNode.writeDescriptor(cmp, RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL, 111 descriptor.getResourcePrincipal()); 112 } 113 Iterator properties = descriptor.getProperties(); 115 if (properties!=null) { 116 RuntimeNameValuePairNode propNode = new RuntimeNameValuePairNode(); 117 while (properties.hasNext()) { 118 NameValuePairDescriptor aProp = (NameValuePairDescriptor) properties.next(); 119 propNode.writeDescriptor(cmp, RuntimeTagNames.PROPERTY, aProp); 120 } 121 } 122 123 if (descriptor.isCreateTablesAtDeploy()) { 125 appendTextChild(cmp, RuntimeTagNames.CREATE_TABLES_AT_DEPLOY, RuntimeTagNames.TRUE); 126 } 127 if (descriptor.isDropTablesAtUndeploy()) { 128 appendTextChild(cmp, RuntimeTagNames.DROP_TABLES_AT_UNDEPLOY, RuntimeTagNames.TRUE); 129 } 130 appendTextChild(cmp, RuntimeTagNames.DATABASE_VENDOR_NAME, descriptor.getDatabaseVendorName()); 132 133 Properties schemaGeneratorProps = descriptor.getSchemaGeneratorProperties(); 135 if (schemaGeneratorProps!=null) { 136 PropertiesNode pn = new PropertiesNode(); 137 pn.writeDescriptor(cmp, RuntimeTagNames.SCHEMA_GENERATOR_PROPERTIES, schemaGeneratorProps); 138 } 139 140 return cmp; 141 } 142 } 143 | Popular Tags |