use of org.apache.naming.resources.BaseDirContext in project tomcat70 by apache.
the class StandardContext method resourcesStart.
/**
* Allocate resources, including proxy.
* Return <code>true</code> if initialization was successfull,
* or <code>false</code> otherwise.
*/
public boolean resourcesStart() {
boolean ok = true;
Hashtable<String, String> env = new Hashtable<String, String>();
if (getParent() != null)
env.put(ProxyDirContext.HOST, getParent().getName());
env.put(ProxyDirContext.CONTEXT, getName());
try {
ProxyDirContext proxyDirContext = new ProxyDirContext(env, webappResources);
if (webappResources instanceof FileDirContext) {
filesystemBased = true;
((FileDirContext) webappResources).setAllowLinking(isAllowLinking());
}
if (webappResources instanceof BaseDirContext) {
((BaseDirContext) webappResources).setDocBase(getBasePath());
((BaseDirContext) webappResources).setCached(isCachingAllowed());
((BaseDirContext) webappResources).setCacheTTL(getCacheTTL());
((BaseDirContext) webappResources).setCacheMaxSize(getCacheMaxSize());
((BaseDirContext) webappResources).allocate();
// Alias support
((BaseDirContext) webappResources).setAliases(getAliases());
if (effectiveMajorVersion >= 3 && addWebinfClassesResources) {
try {
DirContext webInfCtx = (DirContext) webappResources.lookup("/WEB-INF/classes");
// Do the lookup to make sure it exists
webInfCtx.lookup("META-INF/resources");
((BaseDirContext) webappResources).addAltDirContext(webInfCtx);
} catch (NamingException e) {
// Doesn't exist - ignore and carry on
}
}
}
// Register the cache in JMX
if (isCachingAllowed() && proxyDirContext.getCache() != null) {
String contextName = getName();
if (!contextName.startsWith("/")) {
contextName = "/" + contextName;
}
ObjectName resourcesName = new ObjectName(this.getDomain() + ":type=Cache,host=" + getHostname() + ",context=" + contextName);
Registry.getRegistry(null, null).registerComponent(proxyDirContext.getCache(), resourcesName, null);
}
super.setResources(proxyDirContext);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.error(sm.getString("standardContext.resourcesStart"), t);
ok = false;
}
return (ok);
}
use of org.apache.naming.resources.BaseDirContext in project tomcat70 by apache.
the class StandardContext method setResources.
/**
* Set the resources DirContext object with which this Container is
* associated.
*
* @param resources The newly associated DirContext
*/
@Override
public synchronized void setResources(DirContext resources) {
if (getState().isAvailable()) {
throw new IllegalStateException(sm.getString("standardContext.resourcesStart"));
}
DirContext oldResources = this.webappResources;
if (oldResources == resources)
return;
if (resources instanceof BaseDirContext) {
// Caching
((BaseDirContext) resources).setCached(isCachingAllowed());
((BaseDirContext) resources).setCacheTTL(getCacheTTL());
((BaseDirContext) resources).setCacheMaxSize(getCacheMaxSize());
((BaseDirContext) resources).setCacheObjectMaxSize(getCacheObjectMaxSize());
// Alias support
((BaseDirContext) resources).setAliases(getAliases());
}
if (resources instanceof FileDirContext) {
filesystemBased = true;
((FileDirContext) resources).setAllowLinking(isAllowLinking());
}
this.webappResources = resources;
// The proxied resources will be refreshed on start
super.setResources(null);
support.firePropertyChange("resources", oldResources, this.webappResources);
}
use of org.apache.naming.resources.BaseDirContext in project Payara by payara.
the class StandardContext method setAlternateResources.
private synchronized void setAlternateResources(AlternateDocBase alternateDocBase, DirContext resources) {
if (started) {
throw new IllegalStateException(rb.getString(LogFacade.RESOURCES_STARTED));
}
final DirContext oldResources = ContextsAdapterUtility.unwrap(alternateDocBase.getWebappResources());
if (oldResources == resources)
return;
if (resources instanceof BaseDirContext) {
((BaseDirContext) resources).setCached(isCachingAllowed());
((BaseDirContext) resources).setCacheTTL(getCacheTTL());
((BaseDirContext) resources).setCacheMaxSize(getCacheMaxSize());
}
if (resources instanceof FileDirContext) {
filesystemBased = true;
((FileDirContext) resources).setCaseSensitive(isCaseSensitive());
((FileDirContext) resources).setAllowLinking(isAllowLinking());
}
alternateDocBase.setWebappResources(ContextsAdapterUtility.wrap(resources));
// The proxied resources will be refreshed on start
alternateDocBase.setResources(null);
}
Aggregations