1 23 24 package com.sun.enterprise.deployment.runtime.common; 25 26 import java.lang.reflect.Method ; 27 import java.util.ArrayList ; 28 29 import com.sun.enterprise.deployment.MethodDescriptor; 30 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor; 31 import com.sun.enterprise.deployment.ServiceRefPortInfo; 32 import com.sun.enterprise.deployment.WebServiceEndpoint; 33 import com.sun.enterprise.deployment.BundleDescriptor; 34 35 public class MessageDescriptor extends RuntimeDescriptor { 36 public static final String JAVA_METHOD = "JavaMethod"; 37 public static final String OPERATION_NAME = "OperationName"; 38 39 private static final String ALL_METHODS = "*"; 40 41 private String operationName = null; 42 private MethodDescriptor methodDescriptor = null; 43 private ArrayList convertedMethodDescs = new ArrayList (); 44 45 private ServiceRefPortInfo portInfo = null; 47 48 private WebServiceEndpoint endPoint = null; 50 51 private BundleDescriptor bundleDesc = null; 52 53 private boolean isConverted = false; 54 55 public MessageDescriptor() {} 56 57 public void setOperationName(String operationName) { 58 this.operationName = operationName; 59 } 60 61 public String getOperationName() { 62 return operationName; 63 } 64 65 public void setMethodDescriptor(MethodDescriptor methodDescriptor) { 66 this.methodDescriptor = methodDescriptor; 67 } 68 69 public MethodDescriptor getMethodDescriptor() { 70 return methodDescriptor; 71 } 72 73 public void setServiceRefPortInfo(ServiceRefPortInfo portInfo) { 74 this.portInfo = portInfo; 75 } 76 77 public ServiceRefPortInfo getServiceRefPortInfo() { 78 return portInfo; 79 } 80 81 public void setWebServiceEndpoint(WebServiceEndpoint endPoint){ 82 this.endPoint = endPoint; 83 } 84 85 public WebServiceEndpoint getWebServiceEndpoint() { 86 return endPoint; 87 } 88 89 public void setBundleDescriptor(BundleDescriptor bundleDesc){ 90 this.bundleDesc = bundleDesc; 91 } 92 93 public BundleDescriptor getBundleDescriptor() { 94 return bundleDesc; 95 } 96 97 110 public ArrayList getAllDefinedMethodsInMessage() { 111 if (!isConverted) { 113 doStyleConversion(); 114 } 115 return convertedMethodDescs; 116 } 117 118 private void doStyleConversion() { 119 if (operationName == null && methodDescriptor == null) { 120 convertedMethodDescs = getAllSEIMethodsOf(ALL_METHODS); 123 } else if (methodDescriptor != null) { 124 if (methodDescriptor.getName() != null && 125 methodDescriptor.getParameterClassNames() != null) { 126 convertedMethodDescs.add(methodDescriptor); 128 } else if (methodDescriptor.getName() != null && 129 methodDescriptor.getParameterClassNames() == null) { 130 convertedMethodDescs = 132 getAllSEIMethodsOf(methodDescriptor.getName()); 133 } 134 } 135 isConverted = true; 136 } 137 138 private ArrayList getAllSEIMethodsOf(String methodName) { 139 String serviceInterfaceName = null; 140 ArrayList allMethodsInSEI = new ArrayList (); 141 142 if (endPoint != null) { 144 serviceInterfaceName = endPoint.getServiceEndpointInterface(); 145 } else if (portInfo != null) { 147 serviceInterfaceName = portInfo.getServiceEndpointInterface(); 148 } 149 150 if (serviceInterfaceName == null) { 153 return allMethodsInSEI; 154 } 155 156 ClassLoader classLoader = null; 157 if (bundleDesc != null) { 158 classLoader = bundleDesc.getClassLoader(); 159 } 160 161 if (classLoader == null) { 163 return allMethodsInSEI; 164 } 165 166 try { 167 Class c = classLoader.loadClass(serviceInterfaceName); 168 Method [] methods = c.getMethods(); 169 for (int i = 0; i < methods.length; i++) { 170 if (methodName.equals(ALL_METHODS)) { 172 allMethodsInSEI.add(new MethodDescriptor(methods[i])); 173 } else if (methodName.equals(methods[i].getName())) { 175 allMethodsInSEI.add(new MethodDescriptor(methods[i])); 176 } 177 } 178 } catch (Exception e) { 179 e.printStackTrace(); 180 } 183 return allMethodsInSEI; 184 } 185 } 186 | Popular Tags |