FileDocCategorySizeDatePackage
ServletMappingNode.javaAPI DocGlassfish v2 API4684Fri May 04 22:31:48 BST 2007com.sun.enterprise.deployment.node.web

ServletMappingNode

public class ServletMappingNode extends com.sun.enterprise.deployment.node.DeploymentDescriptorNode
This node is responsible for handling servlet-mapping subtree node
author
Jerome Dochez
version

Fields Summary
private String
servletName
private String
urlPattern
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
Constructors Summary
Methods Summary
public java.lang.ObjectgetDescriptor()

return
the descriptor instance to associate with this XMLNode

        return null;
    
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 (WebTagNames.SERVLET_NAME.equals(element.getQName())) {
            servletName = value;
        } 
        if (WebTagNames.URL_PATTERN.equals(element.getQName())) {
            // If URL Pattern does not start with "/" then 
            // prepend it (for Servlet2.2 Web apps) 
            Object parent = getParentNode().getDescriptor(); 
            if (parent instanceof WebBundleDescriptor &&  
                ((WebBundleDescriptor) parent).getSpecVersion().equals("2.2")) 
            { 
                if(!value.startsWith("/") && !value.startsWith("*.")) { 
                    value = "/" + value; 
                } 
            } 
            urlPattern = value;
            if (!URLPattern.isValid(urlPattern)) {
                throw new IllegalArgumentException(localStrings.getLocalString(
                "enterprise.deployment.invalidurlpattern", 
                "Invalid URL Pattern: [{0}]",
                new Object[] {urlPattern}));
            }

            XMLNode  parentNode = getParentNode();
            if (parentNode instanceof WebBundleNode) {
                ((WebBundleNode) parentNode).addServletMapping(servletName, 
                urlPattern);
            } else {
                DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
                    new Object[]{getXMLRootTag() , "servlet-mapping"});
            }

        }