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.node.runtime.web.WebBundleRuntimeNode; 32 import com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer; 33 import com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor; 34 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 35 36 41 public class MessageDestinationRefNode extends DeploymentDescriptorNode { 42 43 private MessageDestinationReferenceDescriptor descriptor; 44 45 48 public Object getDescriptor() { 49 return descriptor; 50 } 51 52 60 protected Map getDispatchTable() { 61 Map table = super.getDispatchTable(); 62 table.put(RuntimeTagNames.JNDI_NAME, "setJndiName"); 63 return table; 64 } 65 66 72 public void setElementValue(XMLElement element, String value) { 73 if (RuntimeTagNames.MESSAGE_DESTINATION_REFERENCE_NAME.equals( 74 element.getQName())) { 75 Object parentNode = getParentNode(); 76 Object parentDesc = null; 77 if (parentNode instanceof WebBundleRuntimeNode) { 79 parentDesc = ((WebBundleRuntimeNode) parentNode).getWebBundleDescriptor(); 80 } else { 82 parentDesc = getParentNode().getDescriptor(); 83 } 84 85 if (parentDesc instanceof MessageDestinationReferenceContainer) { 86 descriptor = ((MessageDestinationReferenceContainer) parentDesc).getMessageDestinationReferenceByName(value); 87 } 88 } else super.setElementValue(element, value); 89 } 90 91 99 public Node writeDescriptor(Node parent, String nodeName, 100 MessageDestinationReferenceDescriptor msgDestRef) { 101 Node msgDestRefNode = super.writeDescriptor(parent, nodeName, 102 msgDestRef); 103 appendTextChild(msgDestRefNode, 104 RuntimeTagNames.MESSAGE_DESTINATION_REFERENCE_NAME, 105 msgDestRef.getName()); 106 appendTextChild(msgDestRefNode, RuntimeTagNames.JNDI_NAME, 107 msgDestRef.getJndiName()); 108 return msgDestRefNode; 109 } 110 111 117 public static void writeMessageDestinationReferences(Node parent, 118 MessageDestinationReferenceContainer descriptor) { 119 Iterator msgDestRefs = 121 descriptor.getMessageDestinationReferenceDescriptors().iterator(); 122 if (msgDestRefs.hasNext()) { 123 MessageDestinationRefNode messageDestinationRefNode = 124 new MessageDestinationRefNode(); 125 while (msgDestRefs.hasNext()) { 126 messageDestinationRefNode.writeDescriptor(parent, 127 RuntimeTagNames.MESSAGE_DESTINATION_REFERENCE, 128 (MessageDestinationReferenceDescriptor) msgDestRefs.next()); 129 } 130 } 131 } 132 } 133 | Popular Tags |