* otherwise <code>false</code>
*/
public boolean isResourceOnlyServlet(String servletName);
+
+ /**
+ * Return the base name to use for WARs, directories or context.xml files
+ * for this context.
+ */
+ public String getBaseName();
+
+ /**
+ * Set the version of this web application - used to differentiate
+ * different versions of the same web application when using parallel
+ * deployment.
+ */
+ public void setWebappVersion(String webappVersion);
+
+ /**
+ * Set the version of this web application - used to differentiate
+ * different versions of the same web application when using parallel
+ * deployment. If not specified, defaults to the empty string.
+ */
+ public String getWebappVersion();
}
// Handle dynamically adding wrappers
Wrapper wrapper = (Wrapper) event.getSource();
Context context = (Context) wrapper.getParent();
- String contextName = context.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = context.getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
String hostName = context.getParent().getName();
String wrapperName = wrapper.getName();
String mapping = (String) event.getData();
boolean jspWildCard = ("jsp".equals(wrapperName)
&& mapping.endsWith("/*"));
- mapper.addWrapper(hostName, contextName, mapping, wrapper,
+ mapper.addWrapper(hostName, contextPath, mapping, wrapper,
jspWildCard, context.isResourceOnlyServlet(wrapperName));
} else if (event.getType() == Wrapper.REMOVE_MAPPING_EVENT) {
// Handle dynamically removing wrappers
Wrapper wrapper = (Wrapper) event.getSource();
- String contextName = wrapper.getParent().getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = ((Context) wrapper.getParent()).getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
String hostName = wrapper.getParent().getParent().getName();
String mapping = (String) event.getData();
- mapper.removeWrapper(hostName, contextName, mapping);
+ mapper.removeWrapper(hostName, contextPath, mapping);
} else if (event.getType() == Context.ADD_WELCOME_FILE_EVENT) {
// Handle dynamically adding welcome files
Context context = (Context) event.getSource();
String hostName = context.getParent().getName();
- String contextName = context.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = context.getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
String welcomeFile = (String) event.getData();
- mapper.addWelcomeFile(hostName, contextName, welcomeFile);
+ mapper.addWelcomeFile(hostName, contextPath, welcomeFile);
} else if (event.getType() == Context.REMOVE_WELCOME_FILE_EVENT) {
// Handle dynamically removing welcome files
Context context = (Context) event.getSource();
String hostName = context.getParent().getName();
- String contextName = context.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = context.getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
String welcomeFile = (String) event.getData();
- mapper.removeWelcomeFile(hostName, contextName, welcomeFile);
+ mapper.removeWelcomeFile(hostName, contextPath, welcomeFile);
} else if (event.getType() == Context.CLEAR_WELCOME_FILES_EVENT) {
// Handle dynamically clearing welcome files
Context context = (Context) event.getSource();
String hostName = context.getParent().getName();
- String contextName = context.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = context.getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
- mapper.clearWelcomeFiles(hostName, contextName);
+ mapper.clearWelcomeFiles(hostName, contextPath);
}
}
*/
private void unregisterWrapper(Wrapper wrapper) {
- String contextName = wrapper.getParent().getName();
+ String contextPath = ((Context) wrapper.getParent()).getPath();
String wrapperName = wrapper.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
String hostName = wrapper.getParent().getParent().getName();
String[] mappings = wrapper.findMappings();
for (String mapping : mappings) {
- mapper.removeWrapper(hostName, contextName, mapping);
+ mapper.removeWrapper(hostName, contextPath, mapping);
}
if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.unregisterWrapper",
- wrapperName, contextName, connector));
+ wrapperName, contextPath, connector));
}
}
*/
private void registerContext(Context context) {
- String contextName = context.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = context.getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
Container host = context.getParent();
javax.naming.Context resources = context.getResources();
String[] welcomeFiles = context.findWelcomeFiles();
- mapper.addContext(host.getName(), host, contextName, context,
+ mapper.addContext(host.getName(), host, contextPath, context,
welcomeFiles, resources);
for (Container container : context.findChildren()) {
if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.registerContext",
- contextName, connector));
+ contextPath, connector));
}
}
return;
}
- String contextName = context.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = context.getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
String hostName = context.getParent().getName();
if(log.isDebugEnabled())
log.debug(sm.getString("mapperListener.unregisterContext",
- contextName, connector));
+ contextPath, connector));
- mapper.removeContext(hostName, contextName);
+ mapper.removeContext(hostName, contextPath);
}
String wrapperName = wrapper.getName();
Context context = (Context) wrapper.getParent();
- String contextName = context.getName();
- if ("/".equals(contextName)) {
- contextName = "";
+ String contextPath = context.getPath();
+ if ("/".equals(contextPath)) {
+ contextPath = "";
}
+
String hostName = context.getParent().getName();
String[] mappings = wrapper.findMappings();
for (String mapping : mappings) {
boolean jspWildCard = (wrapperName.equals("jsp")
&& mapping.endsWith("/*"));
- mapper.addWrapper(hostName, contextName, mapping, wrapper,
+ mapper.addWrapper(hostName, contextPath, mapping, wrapper,
jspWildCard,
context.isResourceOnlyServlet(wrapperName));
}
if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.registerWrapper",
- wrapperName, contextName, connector));
+ wrapperName, contextPath, connector));
}
}
private void registerJMX() {
String parentName = context.getName();
- parentName = ("".equals(parentName)) ? "/" : parentName;
+ if (!parentName.startsWith("/")) {
+ parentName = "/" + parentName;
+ }
String hostName = context.getParent().getName();
hostName = (hostName == null) ? "DEFAULT" : hostName;
if (constraint == null) {
throw new IllegalArgumentException(sm.getString(
"applicationServletRegistration.setServletSecurity.iae",
- getName(), context.getPath()));
+ getName(), context.getName()));
}
if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
throw new IllegalStateException(sm.getString(
"applicationServletRegistration.setServletSecurity.ise",
- getName(), context.getPath()));
+ getName(), context.getName()));
}
return context.addServletSecurity(this, constraint);
String name = current.getName();
if ((name == null) || (name.equals(""))) {
name = "/";
+ } else if (name.startsWith("##")) {
+ name = "/" + name;
}
loggerName = "[" + name + "]"
+ ((loggerName != null) ? ("." + loggerName) : "");
applicationRequest.badRequest=Request is not a javax.servlet.ServletRequestWrapper
applicationResponse.badParent=Cannot locate parent Response implementation
applicationResponse.badResponse=Response is not a javax.servlet.ServletResponseWrapper
-applicationServletRegistration.setServletSecurity.iae=Null constraint specified for servlet [{0}] deployed to context with path [{1}]
-applicationServletRegistration.setServletSecurity.ise=Security constraints can't be added to servlet [{0}] deployed to context with path [{1}] as the context has already been initialised
+applicationServletRegistration.setServletSecurity.iae=Null constraint specified for servlet [{0}] deployed to context with name [{1}]
+applicationServletRegistration.setServletSecurity.ise=Security constraints can't be added to servlet [{0}] deployed to context with name [{1}] as the context has already been initialised
aprListener.aprInit=The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: {0}
aprListener.tcnInvalid=An incompatible version {0} of the APR based Apache Tomcat Native library is installed, while Tomcat requires version {1}
aprListener.tcnVersion=An older version {0} of the APR based Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of {1}
standardContext.loginConfig.required=LoginConfig cannot be null
standardContext.manager=Configured a manager of class [{0}]
standardContext.mappingError=MAPPING configuration error for relative URI {0}
-standardContext.noResourceJar=Resource JARs are not supported. The JAR found at [{0}] will no be used to provide static content for context with path [{1}]
+standardContext.noResourceJar=Resource JARs are not supported. The JAR found at [{0}] will not be used to provide static content for context with name [{1}]
standardContext.notFound=The requested resource ({0}) is not available.
standardContext.notReloadable=Reloading is disabled on this Context
standardContext.notStarted=Context has not yet been started
standardContext.notWrapper=Child of a Context must be a Wrapper
standardContext.parameter.duplicate=Duplicate context initialization parameter {0}
standardContext.parameter.required=Both parameter name and parameter value are required
-standardContext.reloadingCompleted=Reloading Context with path [{0}] is completed
+standardContext.reloadingCompleted=Reloading Context with name [{0}] is completed
standardContext.reloadingFailed=Reloading this Context failed due to previous errors
-standardContext.reloadingStarted=Reloading Context with path [{0}] has started
+standardContext.reloadingStarted=Reloading Context with name [{0}] has started
standardContext.resourcesStart=Error starting static Resources
standardContext.securityConstraint.mixHttpMethod=It is not permitted to mix <http-method> and <http-method-omission> in the same web resource collection
standardContext.securityConstraint.pattern=Invalid <url-pattern> {0} in security constraint
standardContext.urlDecode=Cannot URL decode request path {0}
standardContext.urlPattern.patternWarning=WARNING: URL pattern {0} must start with a ''/'' in Servlet 2.4
standardContext.urlValidate=Cannot validate URL decoded request path {0}
+standardContext.workPath=Exception obtaining work path for context [{0}]
standardContext.wrapper.error=JSP file {0} must start with a ''/'
standardContext.wrapper.warning=WARNING: JSP file {0} must start with a ''/'' in Servlet 2.4
standardEngine.alreadyStarted=Engine has already been started
",class=" + resource.getType() +
",name=" + quotedResourceName);
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/"))
+ contextName = "/" + contextName;
Host host = (Host) ((Context)container).getParent();
name = new ObjectName(domain + ":type=DataSource" +
- ",path=" + path +
+ ",context=" + contextName +
",host=" + host.getName() +
",class=" + resource.getType() +
",name=" + quotedResourceName);
import org.apache.catalina.session.StandardManager;
import org.apache.catalina.startup.TldConfig;
import org.apache.catalina.util.CharsetMapper;
+import org.apache.catalina.util.ContextName;
import org.apache.catalina.util.ExtensionValidator;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.URLEncoder;
private Set<String> resourceOnlyServlets = new HashSet<String>();
+ private String webappVersion;
// ----------------------------------------------------- Context Properties
+
+ @Override
+ public void setWebappVersion(String webappVersion) {
+ this.webappVersion = webappVersion;
+ }
+
+
+ @Override
+ public String getWebappVersion() {
+ return webappVersion;
+ }
+
+
+ @Override
+ public String getBaseName() {
+ return new ContextName(path, webappVersion).getBaseName();
+ }
+
+
@Override
public String getResourceOnlyServlets() {
StringBuilder result = new StringBuilder();
((BaseDirContext) webappResources).addResourcesJar(url);
} else {
log.error(sm.getString("standardContext.noResourceJar", url,
- getPath()));
+ getName()));
}
}
return (path);
}
-
+
/**
* Set the context path for this Context.
*
workDir = new File(catalinaHomePath,
getWorkDir());
} catch (IOException e) {
- log.warn("Exception obtaining work path for " + getPath());
+ log.warn(sm.getString("standardContext.workPath", getName()),
+ e);
}
}
return workDir.getAbsolutePath();
throw new IllegalStateException
(sm.getString("containerBase.notStarted", logName()));
- String path = getPath();
- if (path.length() == 0) {
- path = "/";
- }
-
- // Make sure reloading is enabled
- // if (!reloadable)
- // throw new IllegalStateException
- // (sm.getString("standardContext.notReloadable"));
if(log.isInfoEnabled())
- log.info(sm.getString("standardContext.reloadingStarted", path));
+ log.info(sm.getString("standardContext.reloadingStarted",
+ getName()));
// Stop accepting requests temporarily
setPaused(true);
setPaused(false);
if(log.isInfoEnabled())
- log.info(sm.getString("standardContext.reloadingCompleted", path));
+ log.info(sm.getString("standardContext.reloadingCompleted",
+ getName()));
}
}
// Register the cache in JMX
if (isCachingAllowed()) {
+ String contextName = getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
ObjectName resourcesName =
new ObjectName(this.getDomain() + ":type=Cache,host="
- + getHostname() + ",path="
- + (("".equals(getPath()))?"/":getPath()));
+ + getHostname() + ",context=" + contextName);
Registry.getRegistry(null, null).registerComponent
(proxyDirContext.getCache(), resourcesName, null);
}
}
// Unregister the cache in JMX
if (isCachingAllowed()) {
+ String contextName = getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
ObjectName resourcesName =
new ObjectName(this.getDomain()
+ ":type=Cache,host="
- + getHostname() + ",path="
- + (("".equals(getPath()))?"/"
- :getPath()));
+ + getHostname() + ",context="
+ + contextName);
Registry.getRegistry(null, null)
.unregisterComponent(resourcesName);
}
protected synchronized void startInternal() throws LifecycleException {
if(log.isDebugEnabled())
- log.debug("Starting " + ("".equals(getName()) ? "ROOT" : getName()));
+ log.debug("Starting " + getBaseName());
// Send j2ee.state.starting notification
if (this.getObjectName() != null) {
/**
- * Given a context path, get the config file name.
- */
- protected String getDefaultConfigFile() {
- String basename = null;
- String path = getPath();
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename + ".xml");
- }
-
-
- /**
* Get naming context full name.
*/
private String getNamingContextName() {
if ((engineName == null) || (engineName.length() < 1))
engineName = "_";
- String temp = getPath();
+ String temp = getName();
if (temp.startsWith("/"))
temp = temp.substring(1);
temp = temp.replace('/', '_');
result.append(hostname);
}
- String pathName = getName();
- if ("".equals(pathName)) {
+ String contextName = getName();
+ if (!contextName.startsWith("/")) {
result.append('/');
- } else {
- result.append(pathName);
}
+ result.append(contextName);
return result.toString();
}
keyProperties.append(hostName);
}
- String pathName = ((Context) getParent()).getPath();
- if ("".equals(pathName)) {
+ String contextName = ((Context) getParent()).getName();
+ if (!contextName.startsWith("/")) {
keyProperties.append('/');
- } else {
- keyProperties.append(pathName);
}
+ keyProperties.append(contextName);
StandardContext ctx = null;
if (parent instanceof StandardContext) {
description="Take care to not lock resources"
type="boolean" />
+ <attribute name="baseName"
+ description="The base name used for directories, WAR files (with .war appended) and context.xml files (with .xml appended)."
+ type="java.lang.String"
+ writeable="false"/>
+
<attribute name="cacheMaxSize"
description="Maximum cache size in KB"
type="int"/>
description="The default context.xml override flag for this web application"
type="boolean"/>
+ <attribute name="name"
+ description="The name of this Context"
+ type="java.lang.String"/>
+
<attribute name="parentClassLoader"
description="Parent class loader."
type="java.lang.ClassLoader" />
is="true"
type="boolean"/>
+ <attribute name="webappVersion"
+ description="The version of this web application - used in parallel deployment to differentiate different versions of the same web application"
+ type="java.lang.String"
+ writeable="false"/>
+
<attribute name="welcomeFiles"
description="The welcome files for this context"
type="[Ljava.lang.String;"
}
/**
- * Given a context path, get the config file name.
- */
- protected String getConfigFile(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
-
- /**
- * Given a context path, get the config file name.
- */
- protected String getDocBase(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1);
- }
- return (basename);
- }
-
- /**
* Return a File object representing the "application root" directory for
* our associated Host.
*/
if(log.isDebugEnabled())
log.debug("Undeploy local context " +path );
context.stop();
- File war = new File(getAppBase(), getDocBase(path) + ".war");
- File dir = new File(getAppBase(), getDocBase(path));
- File xml = new File(configBase, getConfigFile(path) + ".xml");
+ String baseName = context.getBaseName();
+ File war = new File(getAppBase(), baseName + ".war");
+ File dir = new File(getAppBase(), baseName);
+ File xml = new File(configBase, baseName + ".xml");
if (war.exists()) {
war.delete();
} else if (dir.exists()) {
this.container.getResources());
StandardContext ctx=(StandardContext)container;
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
+ String contextName = ctx.getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
}
ObjectName cloname = new ObjectName
- (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,path="
- + path + ",host=" + ctx.getParent().getName());
+ (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,context="
+ + contextName + ",host=" + ctx.getParent().getName());
Registry.getRegistry(null, null)
.registerComponent(classLoader, cloname, null);
try {
StandardContext ctx=(StandardContext)container;
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
- }
+ String contextName = ctx.getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
ObjectName cloname = new ObjectName
- (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,path="
- + path + ",host=" + ctx.getParent().getName());
+ (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,context="
+ + contextName + ",host=" + ctx.getParent().getName());
Registry.getRegistry(null, null).unregisterComponent(cloname);
} catch (Exception e) {
log.error("LifecycleException ", e);
StringBuilder name = new StringBuilder("type=Loader");
if (container instanceof Context) {
- name.append(",path=");
+ name.append(",context=");
Context context = (Context) container;
- String path = context.getPath();
- if (path.equals("")) {
- path = "/";
+ String contextName = context.getName();
+ if (!contextName.startsWith("/")) {
+ name.append("/");
}
- name.append(path);
+ name.append(contextName);
name.append(",host=");
name.append(context.getParent().getName());
import org.apache.catalina.manager.util.BaseSessionComparator;
import org.apache.catalina.manager.util.ReverseComparator;
import org.apache.catalina.manager.util.SessionUtils;
+import org.apache.catalina.util.ContextName;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.ServerInfo;
import org.apache.catalina.util.URLEncoder;
Part warPart = null;
String filename = null;
- String basename = null;
Collection<Part> parts = request.getParts();
Iterator<Part> iter = parts.iterator();
filename =
filename.substring(filename.lastIndexOf('/') + 1);
}
+
// Identify the appBase of the owning Host of this Context
// (if any)
- basename = filename.substring(0,
- filename.toLowerCase(Locale.ENGLISH).indexOf(".war"));
File file = new File(getAppBase(), filename);
if (file.exists()) {
message = smClient.getString(
filename);
break;
}
- String path = null;
- if (basename.equals("ROOT")) {
- path = "";
- } else {
- path = "/" + basename.replace('#', '/');
- }
+
+ ContextName cn = new ContextName(filename);
+ String name = cn.getName();
- if ((host.findChild(path) != null) && !isDeployed(path)) {
+ if ((host.findChild(name) != null) && !isDeployed(name)) {
message = smClient.getString(
"htmlManagerServlet.deployUploadInServerXml",
filename);
break;
}
- if (!isServiced(path)) {
- addServiced(path);
+ if (!isServiced(name)) {
+ addServiced(name);
try {
warPart.write(file.getAbsolutePath());
// Perform new deployment
- check(path);
+ check(name);
} finally {
- removeServiced(path);
+ removeServiced(name);
}
}
break;
args[12] = smClient.getString("htmlManagerServlet.expire.unit");
args[13] = highlightColor;
- if (ctxt.getPath().equals(this.context.getPath())) {
+ if (ctxt.getName().equals(this.context.getName())) {
writer.print(MessageFormat.format(
MANAGER_APP_ROW_BUTTON_SECTION, args));
} else if (ctxt.getAvailable() && isDeployed) {
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.core.StandardServer;
+import org.apache.catalina.util.ContextName;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.ServerInfo;
import org.apache.tomcat.util.ExceptionUtils;
return;
}
String displayPath = path;
- if( path.equals("/") )
- path = "";
- String basename = getDocBase(path);
+
+ ContextName cn = new ContextName(path, null);
+ String name = cn.getName();
+ String baseName = cn.getBaseName();
// Check if app already exists, or undeploy it if updating
- Context context = (Context) host.findChild(path);
+ Context context = (Context) host.findChild(name);
if (update) {
if (context != null) {
undeploy(writer, displayPath, smClient);
}
- context = (Context) host.findChild(path);
+ context = (Context) host.findChild(name);
}
if (context != null) {
writer.println(smClient.getString("managerServlet.alreadyContext",
}
// Upload the web application archive to a local WAR file
- File localWar = new File(deployedPath, basename + ".war");
+ File localWar = new File(deployedPath, baseName + ".war");
if (debug >= 2) {
log("Uploading WAR file to " + localWar);
}
// Copy WAR to appBase
try {
- if (!isServiced(path)) {
- addServiced(path);
+ if (!isServiced(name)) {
+ addServiced(name);
try {
// Upload WAR
uploadWar(request, localWar);
// Copy WAR and XML to the host app base if needed
if (tag != null) {
deployedPath = deployed;
- File localWarCopy = new File(deployedPath, basename + ".war");
+ File localWarCopy = new File(deployedPath, baseName + ".war");
copy(localWar, localWarCopy);
localWar = localWarCopy;
- copy(localWar, new File(getAppBase(), basename + ".war"));
+ copy(localWar, new File(getAppBase(), baseName + ".war"));
}
// Perform new deployment
- check(path);
+ check(name);
} finally {
- removeServiced(path);
+ removeServiced(name);
}
}
} catch (Exception e) {
return;
}
- context = (Context) host.findChild(path);
+ context = (Context) host.findChild(name);
if (context != null && context.getConfigured()) {
writer.println(smClient.getString(
"managerServlet.deployed", displayPath));
return;
}
String displayPath = path;
- if( path.equals("/") )
- path = "";
-
+ ContextName cn = new ContextName(path, null);
+ String baseName = cn.getBaseName();
+ String name = cn.getName();
+
// Calculate the base path
File deployedPath = versioned;
if (tag != null) {
}
// Find the local WAR file
- File localWar = new File(deployedPath, getDocBase(path) + ".war");
+ File localWar = new File(deployedPath, baseName + ".war");
// Check if app already exists, or undeploy it if updating
- Context context = (Context) host.findChild(path);
+ Context context = (Context) host.findChild(name);
if (context != null) {
undeploy(writer, displayPath, smClient);
}
// Copy WAR to appBase
try {
- if (!isServiced(path)) {
- addServiced(path);
+ if (!isServiced(name)) {
+ addServiced(name);
try {
- copy(localWar, new File(getAppBase(), getDocBase(path) + ".war"));
+ copy(localWar, new File(getAppBase(), baseName + ".war"));
// Perform new deployment
- check(path);
+ check(name);
} finally {
- removeServiced(path);
+ removeServiced(name);
}
}
} catch (Exception e) {
return;
}
- context = (Context) host.findChild(path);
+ context = (Context) host.findChild(name);
if (context != null && context.getConfigured()) {
writer.println(smClient.getString("managerServlet.deployed",
displayPath));
return;
}
String displayPath = path;
- if("/".equals(path)) {
- path = "";
- }
+ ContextName cn = new ContextName(path, null);
+ String name = cn.getName();
+ String baseName = cn.getBaseName();
// Check if app already exists, or undeploy it if updating
- Context context = (Context) host.findChild(path);
+ Context context = (Context) host.findChild(name);
if (update) {
if (context != null) {
undeploy(writer, displayPath, smClient);
}
- context = (Context) host.findChild(path);
+ context = (Context) host.findChild(name);
}
if (context != null) {
writer.println(smClient.getString("managerServlet.alreadyContext",
}
try {
- if (!isServiced(path)) {
- addServiced(path);
+ if (!isServiced(name)) {
+ addServiced(name);
try {
if (config != null) {
configBase.mkdirs();
copy(new File(config),
- new File(configBase, getConfigFile(path) + ".xml"));
+ new File(configBase, baseName + ".xml"));
}
if (war != null) {
if (war.endsWith(".war")) {
copy(new File(war),
- new File(getAppBase(), getDocBase(path) + ".war"));
+ new File(getAppBase(), baseName + ".war"));
} else {
copy(new File(war),
- new File(getAppBase(), getDocBase(path)));
+ new File(getAppBase(), baseName));
}
}
// Perform new deployment
- check(path);
+ check(name);
} finally {
- removeServiced(path);
+ removeServiced(name);
}
}
- context = (Context) host.findChild(path);
+ context = (Context) host.findChild(name);
if (context != null && context.getConfigured() && context.getAvailable()) {
writer.println(smClient.getString(
"managerServlet.deployed", displayPath));
return;
}
// It isn't possible for the manager to reload itself
- if (context.getPath().equals(this.context.getPath())) {
+ if (context.getName().equals(this.context.getName())) {
writer.println(smClient.getString("managerServlet.noSelf"));
return;
}
return;
}
// It isn't possible for the manager to stop itself
- if (context.getPath().equals(this.context.getPath())) {
+ if (context.getName().equals(this.context.getName())) {
writer.println(smClient.getString("managerServlet.noSelf"));
return;
}
return;
}
String displayPath = path;
- if( path.equals("/") )
- path = "";
+ ContextName cn = new ContextName(path, null);
+ String name = cn.getName();
+ String baseName = cn.getBaseName();
try {
// Validate the Context of the specified application
- Context context = (Context) host.findChild(path);
+ Context context = (Context) host.findChild(name);
if (context == null) {
writer.println(smClient.getString("managerServlet.noContext",
RequestUtil.filter(displayPath)));
return;
}
- if (!isDeployed(path)) {
+ if (!isDeployed(name)) {
writer.println(smClient.getString("managerServlet.notDeployed",
RequestUtil.filter(displayPath)));
return;
}
- if (!isServiced(path)) {
- addServiced(path);
+ if (!isServiced(name)) {
+ addServiced(name);
try {
// Try to stop the context first to be nicer
context.stop();
ExceptionUtils.handleThrowable(t);
}
try {
- if (path.lastIndexOf('/') > 0) {
- path = "/" + path.substring(1).replace('/','#');
- }
- File war = new File(getAppBase(), getDocBase(path) + ".war");
- File dir = new File(getAppBase(), getDocBase(path));
- File xml = new File(configBase, getConfigFile(path) + ".xml");
+ File war = new File(getAppBase(), baseName + ".war");
+ File dir = new File(getAppBase(), baseName);
+ File xml = new File(configBase, baseName + ".xml");
if (war.exists()) {
war.delete();
} else if (dir.exists()) {
xml.delete();
}
// Perform new deployment
- check(path.replace('#', '/'));
+ check(name);
} finally {
- removeServiced(path.replace('#','/'));
+ removeServiced(name);
}
}
writer.println(smClient.getString("managerServlet.undeployed",
/**
- * Given a context path, get the config file name.
- */
- protected String getConfigFile(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
-
-
- /**
- * Given a context path, get the doc base.
- */
- protected String getDocBase(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
-
-
- /**
* Return a File object representing the "application root" directory
* for our associated Host.
*/
false, false);
}
- /**
- * Given a context path, get the config file name.
- */
- private String getConfigFile(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
/**
* Create a new StandardContext.
":type=Deployer,host="+
pname.getKeyProperty("host"));
if(mserver.isRegistered(deployer)) {
- String contextPath = context.getPath();
+ String contextName = context.getName();
mserver.invoke(deployer, "addServiced",
- new Object [] {contextPath},
+ new Object [] {contextName},
new String [] {"java.lang.String"});
String configPath = (String)mserver.getAttribute(deployer,
"configBaseName");
- String baseName = getConfigFile(contextPath);
+ String baseName = context.getBaseName();
File configFile = new File(new File(configPath), baseName+".xml");
context.setConfigFile(configFile.toURI().toURL());
mserver.invoke(deployer, "manageApp",
new Object[] {context},
new String[] {"org.apache.catalina.Context"});
mserver.invoke(deployer, "removeServiced",
- new Object [] {contextPath},
+ new Object [] {contextName},
new String [] {"java.lang.String"});
} else {
log.warn("Deployer not found for "+pname.getKeyProperty("host"));
ObjectName name = null;
Host host = (Host)context.getParent();
- String path = context.getPath();
- if (path.length() < 1)
- path = "/";
- // FIXME
+ String contextName = context.getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
name = new ObjectName(domain + ":j2eeType=WebModule,name=//" +
- host.getName()+ path +
+ host.getName()+ contextName +
",J2EEApplication=none,J2EEServer=none");
return (name);
name = new ObjectName(domain + ":type=Environment" +
",resourcetype=Global,name=" + environment.getName());
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
+
Host host = (Host) ((Context)container).getParent();
name = new ObjectName(domain + ":type=Environment" +
- ",resourcetype=Context,path=" + path +
+ ",resourcetype=Context,context=" + contextName +
",host=" + host.getName() +
",name=" + environment.getName());
}
",resourcetype=Global" +
",name=" + quotedResourceLinkName);
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
+
Host host = (Host) ((Context)container).getParent();
name = new ObjectName(domain + ":type=ResourceLink" +
- ",resourcetype=Context,path=" + path +
+ ",resourcetype=Context,context=" + contextName +
",host=" + host.getName() +
",name=" + quotedResourceLinkName);
}
name = new ObjectName(domain + ":type=Loader,host=" +
container.getName());
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
}
Host host = (Host) container.getParent();
- name = new ObjectName(domain + ":type=Loader,path=" + path +
- ",host=" + host.getName());
+ name = new ObjectName(domain + ":type=Loader,context=" +
+ contextName + ",host=" + host.getName());
}
return (name);
name = new ObjectName(domain + ":type=Manager,host=" +
container.getName());
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
}
Host host = (Host) container.getParent();
- name = new ObjectName(domain + ":type=Manager,path=" + path +
- ",host=" + host.getName());
+ name = new ObjectName(domain + ":type=Manager,context=" +
+ contextName + ",host=" + host.getName());
}
return (name);
name = new ObjectName(domain + ":type=NamingResources" +
",resourcetype=Global");
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
Host host = (Host) ((Context)container).getParent();
name = new ObjectName(domain + ":type=NamingResources" +
- ",resourcetype=Context,path=" + path +
+ ",resourcetype=Context,context=" + contextName +
",host=" + host.getName());
}
name = new ObjectName(domain + ":type=Realm,host=" +
container.getName());
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
}
Host host = (Host) container.getParent();
- name = new ObjectName(domain + ":type=Realm,path=" + path +
- ",host=" + host.getName());
+ name = new ObjectName(domain + ":type=Realm,context=" +
+ contextName + ",host=" + host.getName());
}
return (name);
name = new ObjectName(domain + ":type=Valve,name=" + className +
ext + local );
} else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
}
Host host = (Host) container.getParent();
- String local=",path=" + path + ",host=" +
+ String local=",context=" + contextName + ",host=" +
host.getName();
int seq = getSeq(local);
String ext="";
keyProperties.append(",servlet=");
keyProperties.append(c.getName());
} else if (c instanceof Context) {
- String path = ((Context)c).getPath();
- if (path.length() < 1) {
- path = "/";
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
}
- keyProperties.append(",path=");
- keyProperties.append(path);
+ keyProperties.append(",context=");
+ keyProperties.append(contextName);
} else if (c instanceof Host) {
keyProperties.append(",host=");
keyProperties.append(c.getName());
super.setContainer(container);
if( appName==null ) {
- String name=container.getName();
+ String name = container.getName();
+ if (!name.startsWith("/")) {
+ name = "/" + name;
+ }
name = makeLegalForJAAS(name);
appName=name;
if (name == null) {
Container container = manager.getContainer();
String contextName = container.getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
String hostName = "";
String engineName = "";
StringBuilder name = new StringBuilder("type=Manager");
if (container instanceof Context) {
- name.append(",path=");
+ name.append(",context=");
Context context = (Context) container;
- String path = context.getPath();
- if (path.equals("")) {
- path = "/";
- }
- name.append(path);
+ String contextName = ((Context)container).getName();
+ if (!contextName.startsWith("/")) {
+ contextName = "/" + contextName;
+ }
+ name.append(contextName);
name.append(",host=");
name.append(context.getParent().getName());
import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.deploy.ServletDef;
import org.apache.catalina.deploy.WebXml;
+import org.apache.catalina.util.ContextName;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.naming.resources.DirContextURLConnection;
if (path == null) {
return;
}
- if (path.equals("")) {
- docBase = "ROOT";
- } else {
- if (path.startsWith("/")) {
- docBase = path.substring(1).replace('/', '#');
- } else {
- docBase = path.replace('/', '#');
- }
- }
+ ContextName cn = new ContextName(path, context.getWebappVersion());
+ docBase = cn.getBaseName();
}
File file = new File(docBase);
file = new File(docBase);
String origDocBase = docBase;
- String pathName = context.getPath();
- if (pathName.equals("")) {
- pathName = "ROOT";
- } else {
- // Context path must start with '/'
- pathName = pathName.substring(1).replace('/', '#');
- }
+ ContextName cn = new ContextName(context.getPath(),
+ context.getWebappVersion());
+ String pathName = cn.getBaseName();
+
if (docBase.toLowerCase(Locale.ENGLISH).endsWith(".war") && !file.isDirectory() && unpackWARs) {
URL war = new URL("jar:" + (new File(docBase)).toURI().toURL() + "!/");
docBase = ExpandWar.expand(host, war, pathName);
if (path == null) {
return;
}
- if (path.equals("")) {
- docBase = "ROOT";
- } else {
- if (path.startsWith("/")) {
- docBase = path.substring(1);
- } else {
- docBase = path;
- }
- }
+ ContextName cn = new ContextName(path, context.getWebappVersion());
+ docBase = cn.getBaseName();
File file = null;
if (docBase.toLowerCase(Locale.ENGLISH).endsWith(".war")) {
+ // TODO - This is never executed. Bug or code to delete?
file = new File(System.getProperty("java.io.tmpdir"),
deploymentCount++ + "-" + docBase + ".war");
} else {
}
if (log.isDebugEnabled())
- log.debug("Anti locking context[" + context.getPath()
+ log.debug("Anti locking context[" + context.getName()
+ "] setting docBase to " + file);
// Cleanup just in case an old deployment is lying around
fixDocBase();
} catch (IOException e) {
log.error(sm.getString(
- "contextConfig.fixDocBase", context.getPath()), e);
+ "contextConfig.fixDocBase", context.getName()), e);
}
}
} catch (IOException ioe) {
log.error(sm.getString(
"contextConfig.servletContainerInitializerFail", url,
- context.getPath()));
+ context.getName()));
return false;
} finally {
if (is != null) {
}
} catch (IOException ioe) {
log.error(sm.getString("contextConfig.resourceJarFail", url,
- context.getPath()));
+ context.getName()));
} finally {
if (jarFile != null) {
try {
public synchronized void removeContext(Context context) {
if( log.isDebugEnabled() )
- log.debug("Removing context[" + context.getPath() + "]");
+ log.debug("Removing context[" + context.getName() + "]");
// Is this Context actually among those that are defined?
boolean found = false;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.ContainerBase;
import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.util.ContextName;
import org.apache.catalina.util.IOTools;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
return configBase().getAbsolutePath();
}
- /**
- * Given a context path, get the base name for WARs, directories and
- * context.xml files.
- */
- protected String getBaseName(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
-
-
- /**
- * Given the name of a WAR file, directory of context.xml file, determine
- * the context path.
- */
- protected String getContextPath(String filename, boolean stripExtension) {
- String contextPath;
-
- // Remove any file extension
- if (stripExtension) {
- contextPath = filename.substring(0, filename.length() -4);
- } else {
- contextPath = filename;
- }
-
- if ("ROOT".equals(contextPath)) {
- // Handle special case of ROOT
- contextPath = "";
- } else {
- // Prepend / and otherwise # -> / replacement
- contextPath = '/' + contextPath.replace('#', '/');
- }
-
- return contextPath;
- }
-
/**
* Deploy applications for any directories or WAR files that are found
File appBase = appBase();
File configBase = configBase();
- String baseName = getBaseName(name);
+ ContextName cn = new ContextName(name);
+ String baseName = cn.getBaseName();
// Deploy XML descriptors from configBase
File xml = new File(configBase, baseName + ".xml");
if (xml.exists())
- deployDescriptor(name, xml, baseName + ".xml");
+ deployDescriptor(cn, xml, baseName + ".xml");
// Deploy WARs, and loop if additional descriptors are found
File war = new File(appBase, baseName + ".war");
if (war.exists())
- deployWAR(name, war, baseName + ".war");
+ deployWAR(cn, war, baseName + ".war");
// Deploy expanded folders
File dir = new File(appBase, baseName);
if (dir.exists())
- deployDirectory(name, dir, baseName);
+ deployDirectory(cn, dir, baseName);
}
File contextXml = new File(configBase, files[i]);
if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".xml")) {
- String contextPath = getContextPath(files[i], true);
+ ContextName cn = new ContextName(files[i]);
+ String name = cn.getName();
- if (isServiced(contextPath))
+ if (isServiced(name))
continue;
String file = files[i];
- deployDescriptor(contextPath, contextXml, file);
+ deployDescriptor(cn, contextXml, file);
}
}
}
* @param contextXml
* @param file
*/
- protected void deployDescriptor(String contextPath, File contextXml, String file) {
- if (deploymentExists(contextPath)) {
+ protected void deployDescriptor(ContextName cn, File contextXml, String file) {
+ if (deploymentExists(cn.getName())) {
return;
}
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
+ DeployedApplication deployedApp = new DeployedApplication(cn.getName());
// Assume this is a configuration descriptor and deploy it
if(log.isInfoEnabled()) {
context.addLifecycleListener(listener);
context.setConfigFile(contextXml.toURI().toURL());
- context.setPath(contextPath);
+ context.setName(cn.getName());
+ context.setPath(cn.getPath());
+ context.setWebappVersion(cn.getVersion());
// Add the associated docBase to the redeployed list if it's a WAR
boolean isExternalWar = false;
boolean isExternal = false;
}
host.addChild(context);
// Get paths for WAR and expanded WAR in appBase
- String name = null;
- String path = context.getPath();
- if (path.equals("")) {
- name = "ROOT";
- } else {
- if (path.startsWith("/")) {
- name = path.substring(1);
- } else {
- name = path;
- }
- }
+
// default to appBase dir + name
- File expandedDocBase = new File(appBase(), name);
+ File expandedDocBase = new File(appBase(), cn.getBaseName());
if (context.getDocBase() != null) {
// first assume docBase is absolute
expandedDocBase = new File(context.getDocBase());
}
if (context != null && host.findChild(context.getName()) != null) {
- deployed.put(contextPath, deployedApp);
+ deployed.put(context.getName(), deployedApp);
}
}
if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".war") && dir.isFile()
&& !invalidWars.contains(files[i]) ) {
- String contextPath = getContextPath(files[i], true);
+ ContextName cn = new ContextName(files[i]);
// Check for WARs with /../ /./ or similar sequences in the name
- if (!validateContextPath(appBase, contextPath)) {
+ if (!validateContextPath(appBase, cn.getBaseName())) {
log.error(sm.getString(
"hostConfig.illegalWarName", files[i]));
invalidWars.add(files[i]);
continue;
}
- if (isServiced(contextPath))
+ if (isServiced(cn.getName()))
continue;
String file = files[i];
- deployWAR(contextPath, dir, file);
+ deployWAR(cn, dir, file);
}
}
}
* @param war
* @param file
*/
- protected void deployWAR(String contextPath, File war, String file) {
+ protected void deployWAR(ContextName cn, File war, String file) {
- if (deploymentExists(contextPath))
+ if (deploymentExists(cn.getName()))
return;
// Checking for a nested /META-INF/context.xml
}
}
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
+ DeployedApplication deployedApp = new DeployedApplication(cn.getName());
// Deploy the application in this WAR file
if(log.isInfoEnabled())
(LifecycleListener) clazz.newInstance();
context.addLifecycleListener(listener);
- context.setPath(contextPath);
+ context.setName(cn.getName());
+ context.setPath(cn.getPath());
+ context.setWebappVersion(cn.getVersion());
context.setDocBase(file);
host.addChild(context);
// If we're unpacking WARs, the docBase will be mutated after
// starting the context
if (unpackWARs && (context.getDocBase() != null)) {
- String name = getBaseName(context.getPath());
- File docBase = new File(appBase(), name);
+ File docBase = new File(appBase(), cn.getBaseName());
deployedApp.redeployResources.put(docBase.getAbsolutePath(),
new Long(docBase.lastModified()));
addWatchedResources(deployedApp, docBase.getAbsolutePath(),
log.error(sm.getString("hostConfig.deployWar.error", file), t);
}
- deployed.put(contextPath, deployedApp);
+ deployed.put(cn.getName(), deployedApp);
}
continue;
File dir = new File(appBase, files[i]);
if (dir.isDirectory()) {
- String contextPath = getContextPath(files[i], false);
+ ContextName cn = new ContextName(files[i]);
- if (isServiced(contextPath))
+ if (isServiced(cn.getName()))
continue;
- deployDirectory(contextPath, dir, files[i]);
+ deployDirectory(cn, dir, files[i]);
}
}
}
* @param dir
* @param file
*/
- protected void deployDirectory(String contextPath, File dir, String file) {
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
+ protected void deployDirectory(ContextName cn, File dir, String file) {
- if (deploymentExists(contextPath))
+ if (deploymentExists(cn.getName()))
return;
+ DeployedApplication deployedApp = new DeployedApplication(cn.getName());
+
// Deploy the application in this directory
if( log.isInfoEnabled() )
log.info(sm.getString("hostConfig.deployDir", file));
(LifecycleListener) clazz.newInstance();
context.addLifecycleListener(listener);
- context.setPath(contextPath);
+ context.setName(cn.getName());
+ context.setPath(cn.getPath());
+ context.setWebappVersion(cn.getVersion());
context.setDocBase(file);
host.addChild(context);
deployedApp.redeployResources.put(dir.getAbsolutePath(),
log.error(sm.getString("hostConfig.deployDir.error", file), t);
}
- deployed.put(contextPath, deployedApp);
+ deployed.put(cn.getName(), deployedApp);
}
/**
* Check if a webapp is already deployed in this host.
*
- * @param contextPath of the context which will be checked
+ * @param contextName of the context which will be checked
*/
- protected boolean deploymentExists(String contextPath) {
- return (deployed.containsKey(contextPath) ||
- (host.findChild(contextPath) != null));
+ protected boolean deploymentExists(String contextName) {
+ return (deployed.containsKey(contextName) ||
+ (host.findChild(contextName) != null));
}
*/
public void manageApp(Context context) {
- String contextPath = context.getPath();
+ String contextName = context.getName();
- if (deployed.containsKey(contextPath))
+ if (deployed.containsKey(contextName))
return;
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
+ DeployedApplication deployedApp = new DeployedApplication(contextName);
// Add the associated docBase to the redeployed list if it's a WAR
boolean isWar = false;
// Add the eventual unpacked WAR and all the resources which will be
// watched inside it
if (isWar && unpackWARs) {
- String name = null;
- String path = context.getPath();
- if (path.equals("")) {
- name = "ROOT";
- } else {
- if (path.startsWith("/")) {
- name = path.substring(1);
- } else {
- name = path;
- }
- }
- File docBase = new File(name);
- if (!docBase.isAbsolute()) {
- docBase = new File(appBase(), name);
- }
+ File docBase = new File(appBase(), context.getBaseName());
deployedApp.redeployResources.put(docBase.getAbsolutePath(),
new Long(docBase.lastModified()));
addWatchedResources(deployedApp, docBase.getAbsolutePath(), context);
} else {
addWatchedResources(deployedApp, null, context);
}
- deployed.put(contextPath, deployedApp);
+ deployed.put(contextName, deployedApp);
}
/**
* Remove a webapp from our control.
* Entry point for the admin webapp, and other JMX Context controllers.
*/
- public void unmanageApp(String contextPath) {
- if(isServiced(contextPath)) {
- deployed.remove(contextPath);
- host.removeChild(host.findChild(contextPath));
+ public void unmanageApp(String contextName) {
+ if(isServiced(contextName)) {
+ deployed.remove(contextName);
+ host.removeChild(host.findChild(contextName));
}
}
contextConfig.jndiUrl=Unable to process JNDI URL [{0}] for annotations
contextConfig.jndiUrlNotDirContextConn=The connection created for URL [{0}] was not a DirContextURLConnection
contextConfig.missingRealm=No Realm has been configured to authenticate against
-contextConfig.resourceJarFail=Failed to processes JAR found at URL [{0}] for static resources to be included in context with path [{0}]
+contextConfig.resourceJarFail=Failed to processes JAR found at URL [{0}] for static resources to be included in context with name [{0}]
contextConfig.role.auth=WARNING: Security role name {0} used in an <auth-constraint> without being defined in a <security-role>
contextConfig.role.link=WARNING: Security role name {0} used in a <role-link> without being defined in a <security-role>
contextConfig.role.runas=WARNING: Security role name {0} used in a <run-as> without being defined in a <security-role>
+contextConfig.servletContainerInitializerFail=Failed to process JAR found at URL [{0}] for ServletContainerInitializers for context with name [{1}]
contextConfig.start=ContextConfig: Processing START
contextConfig.stop=ContextConfig: Processing STOP
contextConfig.unavailable=Marking this application unavailable due to previous error(s)
tldConfig.cce=Lifecycle event data object {0} is not a Context
tldConfig.dirFail=Failed to process directory [{0}] for TLD files
tldConfig.dirScan=Scanning for TLD files in directory [{0}]
-tldConfig.execute=Error processing TLD files for context path {0}
+tldConfig.execute=Error processing TLD files for context with name [{0}]
tldConfig.jarFail=Failed to process JAR [{0}] for TLD files
tldConfig.webinfFail=Failed to process TLD found at [{0}]
tldConfig.webinfScan=Scanning WEB-INF for TLD files in [{0}]
}
}
+ @Override
public void lifecycleEvent(LifecycleEvent event) {
// Identify the context we are associated with
try {
execute();
} catch (Exception e) {
log.error(sm.getString(
- "tldConfig.execute", context.getPath()), e);
+ "tldConfig.execute", context.getName()), e);
}
} else if (event.getType().equals(Lifecycle.STOP_EVENT)) {
taglibUris.clear();
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.util;
+
+import java.util.Locale;
+
+/**
+ * Utility class to manage context names so there is one place where the
+ * conversions between baseName, path and version take place.
+ */
+public final class ContextName {
+ private final String ROOT_NAME = "ROOT";
+ private final String VERSION_MARKER = "##";
+ private final String FWD_SLASH_REPLACEMENT = "#";
+
+ private final String baseName;
+ private final String path;
+ private final String version;
+ private final String name;
+
+ /**
+ * Creates an instance from a base name, directory name, WAR name or
+ * context.xml name.
+ *
+ * @param name The name to use as the basis for this object
+ */
+ public ContextName(String name) {
+ // Remove file extension, if any
+ if (name.toLowerCase(Locale.ENGLISH).endsWith(".war") ||
+ name.toLowerCase(Locale.ENGLISH).endsWith(".xml")) {
+ baseName = name.substring(0, name.length() -4);
+ } else {
+ baseName = name;
+ }
+
+ // Extract version number
+ int versionIndex = baseName.indexOf(VERSION_MARKER);
+ if (versionIndex > -1) {
+ version = baseName.substring(versionIndex + 2);
+ } else {
+ version = "";
+ }
+
+ if (ROOT_NAME.equals(baseName)) {
+ path = "";
+ } else if (versionIndex > -1) {
+ path = "/" + baseName.substring(0, versionIndex).replaceAll(
+ FWD_SLASH_REPLACEMENT, "/");
+ } else {
+ path = "/" + baseName.replaceAll(FWD_SLASH_REPLACEMENT, "/");
+ }
+
+ if (versionIndex > -1) {
+ this.name = path + VERSION_MARKER + version;
+ } else {
+ this.name = path;
+ }
+ }
+
+ /**
+ * Construct and instance from a path and version.
+ *
+ * @param path Context path to use
+ * @param version Context version to use
+ */
+ public ContextName(String path, String version) {
+ // Path should never be null or '/'
+ if (path == null || "/".equals(path)) {
+ this.path = "";
+ } else {
+ this.path = path;
+ }
+
+ // Version should never be null
+ if (version == null) {
+ this.version = "";
+ } else {
+ this.version = version;
+ }
+
+ // Name is path + version
+ if ("".equals(this.version)) {
+ name = this.path;
+ } else {
+ name = this.path + VERSION_MARKER + this.version;
+ }
+
+ // Base name is converted path + version
+ StringBuilder tmp = new StringBuilder();
+ if ("".equals(path)) {
+ tmp.append(ROOT_NAME);
+ } else {
+ tmp.append(this.path.substring(1).replaceAll("/",
+ FWD_SLASH_REPLACEMENT));
+ }
+ if (this.version.length() > 0) {
+ tmp.append(VERSION_MARKER);
+ tmp.append(this.version);
+ }
+ this.baseName = tmp.toString();
+ }
+
+ public String getBaseName() {
+ return baseName;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
Context context)
throws IOException {
- String appName = context.getPath();
+ String appName = context.getName();
ArrayList<ManifestResource> appManifestResources =
new ArrayList<ManifestResource>();
// If the application context is null it does not exist and