1 23 package com.sun.enterprise.deployment.node.runtime; 24 25 import com.sun.enterprise.deployment.BundleDescriptor; 26 import com.sun.enterprise.deployment.Descriptor; 27 import com.sun.enterprise.deployment.EjbBundleDescriptor; 28 import com.sun.enterprise.deployment.EjbDescriptor; 29 import com.sun.enterprise.deployment.NameValuePairDescriptor; 30 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 31 import com.sun.enterprise.deployment.node.runtime.common.MessageSecurityBindingNode; 32 import com.sun.enterprise.deployment.node.runtime.common.RuntimeNameValuePairNode; 33 import com.sun.enterprise.deployment.node.runtime.web.WebBundleRuntimeNode; 34 import com.sun.enterprise.deployment.node.XMLElement; 35 import com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor; 36 import com.sun.enterprise.deployment.runtime.web.Servlet; 37 import com.sun.enterprise.deployment.util.DOLUtils; 38 import com.sun.enterprise.deployment.WebBundleDescriptor; 39 import com.sun.enterprise.deployment.WebComponentDescriptor; 40 import com.sun.enterprise.deployment.WebServiceEndpoint; 41 import com.sun.enterprise.deployment.WebServicesDescriptor; 42 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 43 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 44 import java.util.*; 45 import java.util.logging.Level ; 46 import javax.xml.namespace.QName ; 47 import org.w3c.dom.Node ; 48 49 56 public class WebServiceEndpointRuntimeNode extends DeploymentDescriptorNode { 57 58 private Descriptor descriptor; 59 60 public WebServiceEndpointRuntimeNode() { 61 registerElementHandler( 62 new XMLElement(WebServicesTagNames.MESSAGE_SECURITY_BINDING), 63 MessageSecurityBindingNode.class, "setMessageSecurityBinding"); 64 65 registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY), 66 RuntimeNameValuePairNode.class, "addProperty"); 67 } 68 69 public Object getDescriptor() { 70 return descriptor; 71 } 72 73 79 protected Map getDispatchTable() { 80 Map table = super.getDispatchTable(); 81 table.put(WebServicesTagNames.ENDPOINT_ADDRESS_URI, 82 "setEndpointAddressUri"); 83 table.put(WebServicesTagNames.TIE_CLASS, "setTieClassName"); 84 table.put(WebServicesTagNames.SERVLET_IMPL_CLASS, 85 "setServletImplClass"); 86 table.put(WebServicesTagNames.DEBUGGING_ENABLED, "setDebugging"); 87 table.put(WebServicesTagNames.NAMESPACE_URI, "setServiceNamespaceUri"); 88 table.put(WebServicesTagNames.LOCAL_PART, "setServiceLocalPart"); 89 table.put(RuntimeTagNames.AUTH_METHOD, "setAuthMethod"); 90 table.put(RuntimeTagNames.REALM, "setRealm"); 91 table.put(WebServicesTagNames.TRANSPORT_GUARANTEE, 92 "setTransportGuarantee"); 93 94 return table; 95 } 96 97 103 104 public void setElementValue(XMLElement element, String value) { 105 if (WebServicesTagNames.PORT_COMPONENT_NAME.equals 106 (element.getQName())) { 107 Object parentDesc = getParentNode().getDescriptor(); 108 if (parentDesc instanceof EjbDescriptor) { 109 EjbBundleDescriptor bundle = 110 ((EjbDescriptor) parentDesc).getEjbBundleDescriptor(); 111 WebServicesDescriptor webServices = bundle.getWebServices(); 112 descriptor = webServices.getEndpointByName(value); 113 } else if( parentDesc instanceof WebComponentDescriptor) { 114 WebBundleDescriptor bundle = ((WebComponentDescriptor) parentDesc).getWebBundleDescriptor(); 115 WebServicesDescriptor webServices = bundle.getWebServices(); 116 descriptor = webServices.getEndpointByName(value); 117 } 118 if (descriptor==null) { 119 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.port_component_name_unknown", 120 new Object [] { value }); 121 } 122 } else super.setElementValue(element, value); 123 } 124 125 133 public Node writeDescriptor(Node parent, String nodeName, 134 WebServiceEndpoint endpoint) { 135 Node endpointNode = 136 super.writeDescriptor(parent, nodeName, endpoint); 137 138 appendTextChild(endpointNode, WebServicesTagNames.PORT_COMPONENT_NAME, 139 endpoint.getEndpointName()); 140 appendTextChild(endpointNode, WebServicesTagNames.ENDPOINT_ADDRESS_URI, 141 endpoint.getEndpointAddressUri()); 142 143 if( endpoint.implementedByEjbComponent() && 146 endpoint.hasAuthMethod() ) { 147 Node loginConfigNode = appendChild(endpointNode, 148 RuntimeTagNames.LOGIN_CONFIG); 149 150 appendTextChild(loginConfigNode, RuntimeTagNames.AUTH_METHOD, 151 endpoint.getAuthMethod()); 152 appendTextChild(loginConfigNode, RuntimeTagNames.REALM, 153 endpoint.getRealm()); 154 } 155 156 MessageSecurityBindingDescriptor messageSecBindingDesc = 158 endpoint.getMessageSecurityBinding(); 159 if (messageSecBindingDesc != null) { 160 MessageSecurityBindingNode messageSecBindingNode = 161 new MessageSecurityBindingNode(); 162 messageSecBindingNode.writeDescriptor(endpointNode, WebServicesTagNames.MESSAGE_SECURITY_BINDING, messageSecBindingDesc); 163 } 164 165 appendTextChild(endpointNode, WebServicesTagNames.TRANSPORT_GUARANTEE, 166 endpoint.getTransportGuarantee()); 167 168 QName serviceName = endpoint.getServiceName(); 169 if( serviceName != null ) { 170 Node serviceQnameNode = appendChild 171 (endpointNode, WebServicesTagNames.SERVICE_QNAME); 172 173 appendTextChild(serviceQnameNode, WebServicesTagNames.NAMESPACE_URI, 174 serviceName.getNamespaceURI()); 175 appendTextChild(serviceQnameNode, WebServicesTagNames.LOCAL_PART, 176 serviceName.getLocalPart()); 177 } 178 179 appendTextChild(endpointNode, WebServicesTagNames.TIE_CLASS, 180 endpoint.getTieClassName()); 181 182 if( endpoint.implementedByWebComponent() && 183 (endpoint.getServletImplClass() != null) ) { 184 appendTextChild(endpointNode, 185 WebServicesTagNames.SERVLET_IMPL_CLASS, 186 endpoint.getServletImplClass()); 187 } 188 189 appendTextChild(endpointNode, WebServicesTagNames.DEBUGGING_ENABLED, 191 endpoint.getDebugging()); 192 193 Iterator properties = endpoint.getProperties(); 195 if (properties!=null) { 196 RuntimeNameValuePairNode propNode = new RuntimeNameValuePairNode(); 197 while (properties.hasNext()) { 198 NameValuePairDescriptor aProp = (NameValuePairDescriptor) properties.next(); 199 propNode.writeDescriptor(endpointNode, RuntimeTagNames.PROPERTY, aProp); 200 } 201 } 202 203 return endpointNode; 204 } 205 206 213 public void writeWebServiceEndpointInfo(Node parent, EjbDescriptor ejb) { 214 215 EjbBundleDescriptor bundle = ejb.getEjbBundleDescriptor(); 216 WebServicesDescriptor webServices = bundle.getWebServices(); 217 Collection endpoints = webServices.getEndpointsImplementedBy(ejb); 218 for(Iterator iter = endpoints.iterator(); iter.hasNext();) { 219 WebServiceEndpoint next = (WebServiceEndpoint) iter.next(); 220 writeDescriptor(parent, WebServicesTagNames.WEB_SERVICE_ENDPOINT, 221 next); 222 } 223 } 224 225 232 public void writeWebServiceEndpointInfo 233 (Node parent, WebComponentDescriptor webComp) { 234 235 WebBundleDescriptor bundle = webComp.getWebBundleDescriptor(); 236 WebServicesDescriptor webServices = bundle.getWebServices(); 237 Collection endpoints = webServices.getEndpointsImplementedBy(webComp); 238 for(Iterator iter = endpoints.iterator(); iter.hasNext();) { 239 WebServiceEndpoint next = (WebServiceEndpoint) iter.next(); 240 writeDescriptor(parent, WebServicesTagNames.WEB_SERVICE_ENDPOINT, 241 next); 242 } 243 } 244 245 } 246 | Popular Tags |