package org.apache.catalina.core;
-import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
*
* @param context The associated Context instance
*/
- public ApplicationContext(String basePath, StandardContext context) {
+ public ApplicationContext(StandardContext context) {
super();
this.context = context;
- this.basePath = basePath;
// Populate session tracking modes
populateSessionTrackingModes();
/**
- * Base path.
- */
- private String basePath = null;
-
-
- /**
* Thread local data used during request dispatch.
*/
private ThreadLocal<DispatchData> dispatchData =
throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
- path = RequestUtil.normalize(path);
- if (path == null)
+ String normPath = RequestUtil.normalize(path);
+ if (normPath == null)
return (null);
- String libPath = "/WEB-INF/lib/";
- if ((path.startsWith(libPath)) && (path.endsWith(".jar"))) {
- File jarFile = null;
- if (context.isFilesystemBased()) {
- jarFile = new File(basePath, path);
- } else {
- jarFile = new File(context.getWorkPath(), path);
- }
- if (jarFile.exists()) {
- return jarFile.toURI().toURL();
- } else {
- return null;
- }
- } else {
-
- DirContext resources = context.getResources();
- if (resources != null) {
- String fullPath = context.getName() + path;
- String hostName = context.getParent().getName();
- try {
- resources.lookup(path);
- return new URL
- ("jndi", "", 0, getJNDIUri(hostName, fullPath),
- new DirContextURLStreamHandler(resources));
- } catch (Exception e) {
- // Ignore
- }
+ DirContext resources = context.getResources();
+ if (resources != null) {
+ String fullPath = context.getName() + normPath;
+ String hostName = context.getParent().getName();
+ try {
+ resources.lookup(path);
+ return new URL
+ ("jndi", "", 0, getJNDIUri(hostName, fullPath),
+ new DirContextURLStreamHandler(resources));
+ } catch (Exception e) {
+ // Ignore
}
}
super.addLifecycleListener(this);
try {
CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
- if (this.context == null) this.context = new ReplApplContext(this.getBasePath(), this);
+ if (this.context == null) this.context = new ReplApplContext(this);
if ( catclust != null ) {
ReplicatedMap map = new ReplicatedMap(this,catclust.getChannel(),DEFAULT_REPL_TIMEOUT,
getName(),getClassLoaders());
@Override
public ServletContext getServletContext() {
if (context == null) {
- context = new ReplApplContext(getBasePath(), this);
+ context = new ReplApplContext(this);
if (getAltDDName() != null)
context.setAttribute(Globals.ALT_DD_ATTR,getAltDDName());
}
protected ConcurrentHashMap<String, Object> tomcatAttributes =
new ConcurrentHashMap<String, Object>();
- public ReplApplContext(String basePath, ReplicatedContext context) {
- super(basePath,context);
+ public ReplApplContext(ReplicatedContext context) {
+ super(context);
}
protected ReplicatedContext getParent() {