1 23 package com.sun.enterprise.deployment.node.runtime.connector; 24 25 import java.util.Map ; 26 import org.w3c.dom.Node ; 27 import org.w3c.dom.Element ; 28 29 import com.sun.enterprise.deployment.NameValuePairDescriptor; 30 import com.sun.enterprise.deployment.node.XMLElement; 31 import com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode; 32 import com.sun.enterprise.deployment.node.runtime.common.RuntimeNameValuePairNode; 33 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor; 34 import com.sun.enterprise.deployment.runtime.connector.ResourceAdapter; 35 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 36 37 43 public class ResourceAdapterNode extends RuntimeDescriptorNode { 44 45 protected RuntimeDescriptor descriptor=null; 46 47 50 public ResourceAdapterNode() { 51 52 handlers = null; 54 55 registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY), 56 RuntimeNameValuePairNode.class, "addPropertyElement"); 57 } 58 59 62 public Object getDescriptor() { 63 if (descriptor==null) { 64 descriptor = (RuntimeDescriptor) super.getDescriptor(); 65 descriptor.setValue(ResourceAdapter.MAX_POOL_SIZE, "32"); 66 descriptor.setValue(ResourceAdapter.STEADY_POOL_SIZE, "4"); 67 descriptor.setValue(ResourceAdapter.MAX_WAIT_TIME_IN_MILLIS, "10000"); 68 descriptor.setValue(ResourceAdapter.IDLE_TIMEOUT_IN_SECONDS, "1000"); 69 70 } 71 return descriptor; 72 } 73 74 82 protected boolean setAttributeValue(XMLElement elementName, XMLElement attributeName, String value) { 83 getDescriptor(); 84 if (descriptor==null) { 85 throw new RuntimeException ("Trying to set values on a null descriptor"); 86 } 87 if (attributeName.getQName().equals(RuntimeTagNames.JNDI_NAME)) { 88 descriptor.setAttributeValue(ResourceAdapter.JNDI_NAME, value); 89 return true; 90 } 91 if (attributeName.getQName().equals(RuntimeTagNames.MAX_POOL_SIZE)) { 92 descriptor.setAttributeValue(ResourceAdapter.MAX_POOL_SIZE, value); 93 return true; 94 } 95 if (attributeName.getQName().equals(RuntimeTagNames.STEADY_POOL_SIZE)) { 96 descriptor.setAttributeValue(ResourceAdapter.STEADY_POOL_SIZE, value); 97 return true; 98 } 99 if (attributeName.getQName().equals(RuntimeTagNames.MAX_WAIT_TIME_IN_MILLIS)) { 100 descriptor.setAttributeValue(ResourceAdapter.MAX_WAIT_TIME_IN_MILLIS, value); 101 return true; 102 } 103 if (attributeName.getQName().equals(RuntimeTagNames.IDLE_TIMEOUT_IN_SECONDS)) { 104 descriptor.setAttributeValue(ResourceAdapter.IDLE_TIMEOUT_IN_SECONDS, value); 105 return true; 106 } 107 return false; 108 } 109 110 118 public Node writeDescriptor(Node parent, String nodeName, ResourceAdapter descriptor) { 119 Element raNode = (Element ) super.writeDescriptor(parent, nodeName, descriptor); 120 appendTextChild(raNode, RuntimeTagNames.DESCRIPTION, descriptor.getDescription()); 121 setAttribute(raNode, RuntimeTagNames.JNDI_NAME, (String ) descriptor.getValue(ResourceAdapter.JNDI_NAME)); 122 setAttribute(raNode, RuntimeTagNames.MAX_POOL_SIZE, (String ) descriptor.getValue(ResourceAdapter.MAX_POOL_SIZE)); 123 setAttribute(raNode, RuntimeTagNames.STEADY_POOL_SIZE, (String ) descriptor.getValue(ResourceAdapter.STEADY_POOL_SIZE)); 124 setAttribute(raNode, RuntimeTagNames.MAX_WAIT_TIME_IN_MILLIS, (String ) descriptor.getValue(ResourceAdapter.MAX_WAIT_TIME_IN_MILLIS)); 125 setAttribute(raNode, RuntimeTagNames.IDLE_TIMEOUT_IN_SECONDS, (String ) descriptor.getValue(ResourceAdapter.IDLE_TIMEOUT_IN_SECONDS)); 126 127 NameValuePairDescriptor[] properties = descriptor.getPropertyElement(); 129 if (properties!=null && properties.length>0) { 130 RuntimeNameValuePairNode subNode = new RuntimeNameValuePairNode(); 131 for (int i=0;i<properties.length;i++) { 132 subNode.writeDescriptor(raNode, RuntimeTagNames.PROPERTY, properties[i]); 133 } 134 } 135 136 return raNode; 137 } 138 } 139 | Popular Tags |