1 23 24 package com.sun.enterprise.deployment.node.web; 25 26 import com.sun.enterprise.deployment.xml.WebTagNames; 27 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 28 import com.sun.enterprise.deployment.node.XMLNode; 29 import com.sun.enterprise.deployment.node.XMLElement; 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 32 33 import com.sun.enterprise.deployment.util.DOLUtils; 34 import com.sun.enterprise.util.web.URLPattern; 35 import com.sun.enterprise.util.LocalStringManagerImpl; 36 import java.util.logging.Level ; 37 38 44 public class ServletMappingNode extends DeploymentDescriptorNode { 45 46 private String servletName; 47 private String urlPattern; 48 49 private static LocalStringManagerImpl localStrings = 50 new LocalStringManagerImpl(ServletMappingNode.class); 51 52 58 public void setElementValue(XMLElement element, String value) { 59 if (WebTagNames.SERVLET_NAME.equals(element.getQName())) { 60 servletName = value; 61 } 62 if (WebTagNames.URL_PATTERN.equals(element.getQName())) { 63 Object parent = getParentNode().getDescriptor(); 66 if (parent instanceof WebBundleDescriptor && 67 ((WebBundleDescriptor) parent).getSpecVersion().equals("2.2")) 68 { 69 if(!value.startsWith("/") && !value.startsWith("*.")) { 70 value = "/" + value; 71 } 72 } 73 urlPattern = value; 74 if (!URLPattern.isValid(urlPattern)) { 75 throw new IllegalArgumentException (localStrings.getLocalString( 76 "enterprise.deployment.invalidurlpattern", 77 "Invalid URL Pattern: [{0}]", 78 new Object [] {urlPattern})); 79 } 80 81 XMLNode parentNode = getParentNode(); 82 if (parentNode instanceof WebBundleNode) { 83 ((WebBundleNode) parentNode).addServletMapping(servletName, 84 urlPattern); 85 } else { 86 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", 87 new Object []{getXMLRootTag() , "servlet-mapping"}); 88 } 89 90 } 91 } 92 93 94 97 public Object getDescriptor() { 98 return null; 99 } 100 } 101 | Popular Tags |