1 23 24 package com.sun.enterprise.deployment.node.runtime.common; 25 26 import java.util.Iterator ; 27 import java.util.ArrayList ; 28 29 import org.w3c.dom.Node ; 30 31 import com.sun.enterprise.deployment.node.XMLElement; 32 import com.sun.enterprise.deployment.node.XMLNode; 33 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 34 import com.sun.enterprise.deployment.node.MethodNode; 35 import com.sun.enterprise.deployment.node.runtime.web.WebBundleRuntimeNode; 36 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 37 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 38 import com.sun.enterprise.deployment.MethodDescriptor; 39 import com.sun.enterprise.deployment.runtime.common.MessageDescriptor; 40 import com.sun.enterprise.deployment.ServiceRefPortInfo; 41 import com.sun.enterprise.deployment.WebServiceEndpoint; 42 import com.sun.enterprise.deployment.BundleDescriptor; 43 import com.sun.enterprise.deployment.WebBundleDescriptor; 44 import com.sun.enterprise.deployment.EjbDescriptor; 45 import com.sun.enterprise.deployment.EjbBundleDescriptor; 46 47 51 public class MessageNode extends DeploymentDescriptorNode { 52 53 MessageDescriptor descriptor = null; 54 private static final String ALL_METHODS = "*"; 55 56 public MessageNode() { 57 registerElementHandler(new XMLElement( 58 RuntimeTagNames.JAVA_METHOD), MethodNode.class, 59 "setMethodDescriptor"); 60 } 61 62 65 public Object getDescriptor() { 66 if (descriptor == null) { 67 descriptor = new MessageDescriptor(); 68 setMiscDescriptors(); 69 } 70 return descriptor; 71 } 72 73 74 80 public void setElementValue(XMLElement element, String value) { 81 if (WebServicesTagNames.OPERATION_NAME.equals(element.getQName())) { 82 descriptor.setOperationName(value); 83 } else { 84 super.setElementValue(element, value); 85 } 86 } 87 88 96 public Node writeDescriptor(Node parent, String nodeName, 97 MessageDescriptor messageDesc) { 98 Node messageNode = super.writeDescriptor(parent, nodeName, 99 messageDesc); 100 101 if (messageDesc.getOperationName() == null && 104 messageDesc.getMethodDescriptor() == null) { 105 MethodDescriptor allMethodDesc = new MethodDescriptor(); 106 allMethodDesc.setName(ALL_METHODS); 107 messageDesc.setMethodDescriptor(allMethodDesc); 108 } 109 110 MethodDescriptor methodDesc = messageDesc.getMethodDescriptor(); 112 if (methodDesc != null) { 113 MethodNode methodNode = new MethodNode(); 114 methodNode.writeJavaMethodDescriptor(messageNode, 115 RuntimeTagNames.JAVA_METHOD, methodDesc); 116 } 117 118 appendTextChild(messageNode, WebServicesTagNames.OPERATION_NAME, 120 messageDesc.getOperationName()); 121 122 return messageNode; 123 } 124 125 private void setMiscDescriptors() { 126 XMLNode parentNode = 127 getParentNode().getParentNode().getParentNode(); 128 129 Object parentDesc = parentNode.getDescriptor(); 131 132 if (parentDesc instanceof ServiceRefPortInfo) { 133 descriptor.setServiceRefPortInfo((ServiceRefPortInfo)parentDesc); 134 } else if(parentDesc instanceof WebServiceEndpoint) { 135 descriptor.setWebServiceEndpoint((WebServiceEndpoint)parentDesc); 136 } 137 138 BundleDescriptor bundleDesc = null; 140 parentNode = parentNode.getParentNode().getParentNode(); 141 if (parentNode instanceof WebBundleRuntimeNode) { 142 bundleDesc = 146 ((WebBundleRuntimeNode)parentNode).getWebBundleDescriptor(); 147 } else if (parentNode.getDescriptor() instanceof BundleDescriptor) { 148 bundleDesc = (BundleDescriptor)parentNode.getDescriptor(); 150 } else { 151 if (parentNode.getDescriptor() instanceof EjbDescriptor) { 153 EjbDescriptor ejbDesc = 154 (EjbDescriptor)parentNode.getDescriptor(); 155 bundleDesc = ejbDesc.getEjbBundleDescriptor(); 156 } else { 157 parentNode = parentNode.getParentNode(); 159 if (parentNode.getDescriptor() instanceof EjbDescriptor) { 160 EjbDescriptor ejbDesc = 161 (EjbDescriptor)parentNode.getDescriptor(); 162 bundleDesc = ejbDesc.getEjbBundleDescriptor(); 163 } 164 } 165 } 166 descriptor.setBundleDescriptor(bundleDesc); 167 } 168 } 169 | Popular Tags |