1 23 package com.sun.enterprise.deployment.node.runtime; 24 25 import java.util.Map ; 26 import java.util.Iterator ; 27 import org.w3c.dom.Node ; 28 29 import com.sun.enterprise.deployment.node.XMLElement; 30 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 31 import com.sun.enterprise.deployment.types.ResourceEnvReferenceContainer; 32 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor; 33 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 34 35 42 public class ResourceEnvRefNode extends DeploymentDescriptorNode { 43 44 private JmsDestinationReferenceDescriptor descriptor; 45 46 49 public Object getDescriptor() { 50 return descriptor; 51 } 52 53 59 protected Map getDispatchTable() { 60 Map table = super.getDispatchTable(); 61 table.put(RuntimeTagNames.JNDI_NAME, "setJndiName"); 62 return table; 63 } 64 65 71 public void setElementValue(XMLElement element, String value) { 72 if (RuntimeTagNames.RESOURCE_ENV_REFERENCE_NAME.equals(element.getQName())) { 73 Object parentDesc = getParentNode().getDescriptor(); 74 if (parentDesc instanceof ResourceEnvReferenceContainer) { 75 descriptor = ((ResourceEnvReferenceContainer) parentDesc).getJmsDestinationReferenceByName(value); 76 } 77 } else super.setElementValue(element, value); 78 } 79 80 88 public Node writeDescriptor(Node parent, String nodeName, JmsDestinationReferenceDescriptor ejbRef) { 89 Node resRefNode = super.writeDescriptor(parent, nodeName, ejbRef); 90 appendTextChild(resRefNode, RuntimeTagNames.RESOURCE_ENV_REFERENCE_NAME, ejbRef.getName()); 91 appendTextChild(resRefNode, RuntimeTagNames.JNDI_NAME, ejbRef.getJndiName()); 92 return resRefNode; 93 } 94 95 101 public static void writeResoureEnvReferences(Node parent, ResourceEnvReferenceContainer descriptor) { 102 Iterator resRefs = descriptor.getJmsDestinationReferenceDescriptors().iterator(); 104 if (resRefs.hasNext()) { 105 ResourceEnvRefNode resourceEnvRefNode = new ResourceEnvRefNode(); 106 while (resRefs.hasNext()) { 107 resourceEnvRefNode.writeDescriptor(parent, RuntimeTagNames.RESOURCE_ENV_REFERENCE, 108 (JmsDestinationReferenceDescriptor) resRefs.next()); 109 } 110 } 111 } 112 113 } 114 | Popular Tags |