1 23 24 29 30 package com.sun.enterprise.deployment.node.runtime; 31 32 import org.w3c.dom.Node ; 33 34 import com.sun.enterprise.deployment.WebBundleDescriptor; 35 import com.sun.enterprise.deployment.WebComponentDescriptor; 36 import com.sun.enterprise.deployment.WebServicesDescriptor; 37 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 38 import com.sun.enterprise.deployment.node.XMLElement; 39 import com.sun.enterprise.deployment.node.runtime.web.WebBundleRuntimeNode; 40 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 41 import com.sun.enterprise.deployment.xml.WebServicesTagNames; 42 43 50 public class ServletNode extends DeploymentDescriptorNode { 51 52 private WebComponentDescriptor descriptor; 53 54 public ServletNode() { 55 registerElementHandler(new XMLElement 56 (WebServicesTagNames.WEB_SERVICE_ENDPOINT), 57 WebServiceEndpointRuntimeNode.class); 58 } 59 60 public Object getDescriptor() { 61 return descriptor; 62 } 63 64 70 public void setElementValue(XMLElement element, String value) { 71 if (RuntimeTagNames.SERVLET_NAME.equals(element.getQName())) { 72 Object parentDesc = ((WebBundleRuntimeNode) getParentNode()).getWebBundleDescriptor(); 73 if (parentDesc instanceof WebBundleDescriptor) { 74 descriptor = ((WebBundleDescriptor) parentDesc).getWebComponentByCanonicalName(value); 75 } 76 } else if (RuntimeTagNames.PRINCIPAL_NAME.equals(element.getQName())) { 77 if (descriptor!=null && descriptor.getRunAsIdentity()!=null) { 78 descriptor.getRunAsIdentity().setPrincipal(value); 79 } 80 } else super.setElementValue(element, value); 81 } 82 83 84 92 public Node writeDescriptor(Node parent, String nodeName, WebComponentDescriptor descriptor) { 93 WebServicesDescriptor webServices = 94 descriptor.getWebBundleDescriptor().getWebServices(); 95 96 if ( (descriptor.getRunAsIdentity() != null) || 99 webServices.hasEndpointsImplementedBy(descriptor) ) { 100 Node servletNode = appendChild(parent, nodeName); 101 appendTextChild(servletNode, RuntimeTagNames.SERVLET_NAME, descriptor.getCanonicalName()); 102 103 if( descriptor.getRunAsIdentity() != null ) { 104 appendTextChild(servletNode, RuntimeTagNames.PRINCIPAL_NAME, 105 descriptor.getRunAsIdentity().getPrincipal()); 106 } 107 108 WebServiceEndpointRuntimeNode wsRuntime = 109 new WebServiceEndpointRuntimeNode(); 110 wsRuntime.writeWebServiceEndpointInfo(servletNode, descriptor); 111 112 return servletNode; 113 } 114 return null; 115 } 116 } 117 | Popular Tags |