1 23 24 package com.sun.enterprise.deployment.node; 25 26 import java.util.Map ; 27 import org.w3c.dom.Node ; 28 29 import com.sun.enterprise.deployment.Descriptor; 30 import com.sun.enterprise.deployment.MethodDescriptor; 31 import com.sun.enterprise.deployment.xml.EjbTagNames; 32 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 33 34 40 public class MethodNode extends DeploymentDescriptorNode { 41 42 48 protected Map getDispatchTable() { 49 Map table = super.getDispatchTable(); 50 table.put(EjbTagNames.EJB_NAME, "setEjbName"); 51 table.put(EjbTagNames.METHOD_INTF, "setEjbClassSymbol"); 52 table.put(EjbTagNames.METHOD_NAME, "setName"); 53 table.put(EjbTagNames.METHOD_PARAM, "addParameterClass"); 54 return table; 55 } 56 57 65 public Node writeDescriptor(Node parent, String nodeName, MethodDescriptor descriptor, String ejbName) { 66 Node methodNode = super.writeDescriptor(parent, nodeName, descriptor); 67 writeLocalizedDescriptions(methodNode, descriptor); 68 if (ejbName != null && ejbName.length() > 0) { 69 appendTextChild(methodNode, EjbTagNames.EJB_NAME, ejbName); 70 } 71 String methodIntfSymbol = descriptor.getEjbClassSymbol(); 72 if( (methodIntfSymbol != null) && 73 !methodIntfSymbol.equals(MethodDescriptor.EJB_BEAN) ) { 74 appendTextChild(methodNode, EjbTagNames.METHOD_INTF, 75 methodIntfSymbol); 76 } 77 appendTextChild(methodNode, EjbTagNames.METHOD_NAME, descriptor.getName()); 78 if (descriptor.getParameterClassNames()!=null) { 79 Node paramsNode = appendChild(methodNode, EjbTagNames.METHOD_PARAMS); 80 writeMethodParams(paramsNode, descriptor); 81 } 82 return methodNode; 83 } 84 85 93 public Node writeQueryMethodDescriptor(Node parent, String nodeName, MethodDescriptor descriptor) { 94 Node methodNode = super.writeDescriptor(parent, nodeName, descriptor); 95 appendTextChild(methodNode, EjbTagNames.METHOD_NAME, descriptor.getName()); 96 Node paramsNode = appendChild(methodNode, EjbTagNames.METHOD_PARAMS); 97 writeMethodParams(paramsNode, descriptor); 98 return methodNode; 99 } 100 101 109 public Node writeJavaMethodDescriptor(Node parent, String nodeName, 110 MethodDescriptor descriptor) { 111 return writeJavaMethodDescriptor(parent, nodeName, descriptor, false); 114 } 115 116 124 public Node writeJavaMethodDescriptor(Node parent, String nodeName, 125 MethodDescriptor descriptor, 126 boolean writeEmptyMethodParamsElementForVoidMethods) { 127 Node methodNode = super.writeDescriptor(parent, nodeName, descriptor); 128 appendTextChild(methodNode, RuntimeTagNames.METHOD_NAME, 129 descriptor.getName()); 130 if (descriptor.getParameterClassNames() != null) { 131 Node paramsNode = 132 appendChild(methodNode, RuntimeTagNames.METHOD_PARAMS); 133 writeMethodParams(paramsNode, descriptor); 134 } else { 135 if( writeEmptyMethodParamsElementForVoidMethods ) { 136 appendChild(methodNode, RuntimeTagNames.METHOD_PARAMS); 137 } 138 } 139 return methodNode; 140 } 141 142 143 149 private void writeMethodParams(Node paramsNode, MethodDescriptor descriptor) { 150 String [] params = descriptor.getParameterClassNames(); 151 if (params==null) 152 return; 153 for (int i=0; i<params.length;i++) { 154 appendTextChild(paramsNode, RuntimeTagNames.METHOD_PARAM, params[i]); 155 } 156 } 157 } 158 159 | Popular Tags |