FileDocCategorySizeDatePackage
ServletNode.javaAPI DocGlassfish v2 API5354Fri May 04 22:31:42 BST 2007com.sun.enterprise.deployment.node.runtime

ServletNode

public class ServletNode extends com.sun.enterprise.deployment.node.DeploymentDescriptorNode
This node is handling all runtime deployment descriptors relative to servlets
author
Jerome Dochez
version

Fields Summary
private com.sun.enterprise.deployment.WebComponentDescriptor
descriptor
Constructors Summary
public ServletNode()

        registerElementHandler(new XMLElement
            (WebServicesTagNames.WEB_SERVICE_ENDPOINT), 
                               WebServiceEndpointRuntimeNode.class);
    
Methods Summary
public java.lang.ObjectgetDescriptor()

        return descriptor;
    
public voidsetElementValue(com.sun.enterprise.deployment.node.XMLElement element, java.lang.String value)
receives notiification of the value for a particular tag

param
element the xml element
param
value it's associated value

        if (RuntimeTagNames.SERVLET_NAME.equals(element.getQName())) {
            Object parentDesc = ((WebBundleRuntimeNode) getParentNode()).getWebBundleDescriptor();
            if (parentDesc instanceof WebBundleDescriptor) {
                descriptor = ((WebBundleDescriptor) parentDesc).getWebComponentByCanonicalName(value);
            }
        } else if (RuntimeTagNames.PRINCIPAL_NAME.equals(element.getQName())) {
            if (descriptor!=null && descriptor.getRunAsIdentity()!=null) {
                descriptor.getRunAsIdentity().setPrincipal(value);
            }
        } else super.setElementValue(element, value);
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.WebComponentDescriptor descriptor)
write the descriptor class to a DOM tree and return it

param
parent node for the DOM tree
param
node name
param
the descriptor to write
return
the DOM tree top node

        
        WebServicesDescriptor webServices = 
            descriptor.getWebBundleDescriptor().getWebServices();

        // only write servlet runtime elements if there is a runas identity
        // or the servlet is exposed as a web service
        if ( (descriptor.getRunAsIdentity() != null) ||
             webServices.hasEndpointsImplementedBy(descriptor) ) {
            Node servletNode =  appendChild(parent, nodeName);
            appendTextChild(servletNode, RuntimeTagNames.SERVLET_NAME, descriptor.getCanonicalName());

            if( descriptor.getRunAsIdentity() != null ) {
                appendTextChild(servletNode, RuntimeTagNames.PRINCIPAL_NAME, 
                                descriptor.getRunAsIdentity().getPrincipal());
            }

            WebServiceEndpointRuntimeNode wsRuntime = 
                new WebServiceEndpointRuntimeNode();
            wsRuntime.writeWebServiceEndpointInfo(servletNode, descriptor);

            return servletNode;
        }
        return null;