本文整理汇总了Java中org.apache.naming.resources.ProxyDirContext类的典型用法代码示例。如果您正苦于以下问题:Java ProxyDirContext类的具体用法?Java ProxyDirContext怎么用?Java ProxyDirContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProxyDirContext类属于org.apache.naming.resources包,在下文中一共展示了ProxyDirContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setResources
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Set the resources DirContext object with which this Container is
* associated.
*
* @param resources The newly associated DirContext
*/
@Override
public synchronized void setResources(DirContext resources) {
// Called from StandardContext.setResources()
// <- StandardContext.start()
// <- ContainerBase.addChildInternal()
// Change components if necessary
DirContext oldResources = this.resources;
if (oldResources == resources)
return;
Hashtable<String, String> env = new Hashtable<String, String>();
if (getParent() != null)
env.put(ProxyDirContext.HOST, getParent().getName());
env.put(ProxyDirContext.CONTEXT, getName());
this.resources = new ProxyDirContext(env, resources);
// Report this property change to interested listeners
support.firePropertyChange("resources", oldResources, this.resources);
}
示例2: setResources
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Set the resources DirContext object with which this Container is
* associated.
*
* @param resources The newly associated DirContext
*/
public synchronized void setResources(DirContext resources) {
// Called from StandardContext.setResources()
// <- StandardContext.start()
// <- ContainerBase.addChildInternal()
// Change components if necessary
DirContext oldResources = this.resources;
if (oldResources == resources)
return;
Hashtable env = new Hashtable();
if (getParent() != null)
env.put(ProxyDirContext.HOST, getParent().getName());
env.put(ProxyDirContext.CONTEXT, getName());
this.resources = new ProxyDirContext(env, resources);
// Report this property change to interested listeners
support.firePropertyChange("resources", oldResources, this.resources);
}
示例3: resolveResource
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
public boolean resolveResource(int type, String name) {
ProxyDirContext resources = (ProxyDirContext) request.getContext().getResources();
CacheEntry cacheEntry = resources.lookupCache(name);
if (!cacheEntry.exists) {
return false;
} else {
switch (type) {
case 0:
return (cacheEntry.resource == null);
case 1:
return (cacheEntry.resource != null);
case 2:
return (cacheEntry.resource != null
&& cacheEntry.attributes.getContentLength() > 0);
default:
return false;
}
}
}
示例4: setResources
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Set the resources DirContext object with which this Container is
* associated.
*
* @param resources The newly associated DirContext
*/
public synchronized void setResources(DirContext resources) {
// Change components if necessary
DirContext oldResources = this.resources;
if (oldResources == resources)
return;
Hashtable env = new Hashtable();
if (getParent() != null)
env.put(ProxyDirContext.HOST, getParent().getName());
env.put(ProxyDirContext.CONTEXT, getName());
this.resources = new ProxyDirContext(env, resources);
// Report this property change to interested listeners
support.firePropertyChange("resources", oldResources, this.resources);
}
示例5: setResources
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Set the resources DirContext object with which this Container is
* associated.
*
* @param resources
* The newly associated DirContext
*/
@Override
public synchronized void setResources(DirContext resources) {
// Called from StandardContext.setResources()
// <- StandardContext.start()
// <- ContainerBase.addChildInternal()
// Change components if necessary
DirContext oldResources = this.resources;
if (oldResources == resources)
return;
Hashtable<String, String> env = new Hashtable<String, String>();
if (getParent() != null)
env.put(ProxyDirContext.HOST, getParent().getName());
env.put(ProxyDirContext.CONTEXT, getName());
this.resources = new ProxyDirContext(env, resources);
// Report this property change to interested listeners
support.firePropertyChange("resources", oldResources, this.resources);
}
示例6: setResources
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Set associated resources.
*/
public void setResources(DirContext resources) {
this.resources = resources;
if (resources instanceof ProxyDirContext) {
contextName = ((ProxyDirContext) resources).getContextName();
}
}
示例7: testResourceCaching
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
@Test
public void testResourceCaching() throws Exception {
Tomcat tomcat = getTomcatInstance();
File appDir = new File("test/webapp-3.0-fragments");
// app dir is relative to server home
StandardContext ctx = (StandardContext) tomcat.addWebapp(
null, "/test", appDir.getAbsolutePath());
ctx.setCachingAllowed(false);
tomcat.start();
DirContext resources = ctx.getResources();
Assert.assertTrue(resources instanceof ProxyDirContext);
ProxyDirContext proxyResources = (ProxyDirContext) resources;
// Caching should be disabled
Assert.assertNull(proxyResources.getCache());
ctx.stop();
ctx.start();
// Caching should still be disabled
Assert.assertNull(proxyResources.getCache());
}
示例8: setResources
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Set associated resources.
*/
public void setResources(DirContext resources) {
this.resources = resources;
if (resources instanceof ProxyDirContext) {
contextName = ((ProxyDirContext) resources).getContextName();
}
}
示例9: init
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
@Override
public void init() throws ServletException {
super.init();
File contentDir = RunUtil.getContentDir();
try {
FileDirContext fdc = new PermissionsDirContext(contentDir);
resources = new ProxyDirContext(new Hashtable(), fdc);
/*{
// workaround for issue where cache entries have null
// attributes when permissions checks fail
@Override
public CacheEntry lookupCache(String name) {
CacheEntry ce = super.lookupCache(name);
if (ce != null && ce.attributes == null) {
ce.attributes = new ResourceAttributes();
ce.exists = false;
}
return ce;
}
};*/
} catch (Exception ex) {
throw new ServletException("Unable to initialize webdav servlet",
ex);
}
}
示例10: resourcesStart
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* 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);
}
this.resources = proxyDirContext;
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.error(sm.getString("standardContext.resourcesStart"), t);
ok = false;
}
return (ok);
}
示例11: resourcesStart
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Allocate resources, including proxy.
* Return <code>true</code> if initialization was successfull,
* or <code>false</code> otherwise.
*/
public boolean resourcesStart() {
boolean ok = true;
Hashtable env = new Hashtable();
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).setCaseSensitive
(isCaseSensitive());
((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();
}
// Register the cache in JMX
if (isCachingAllowed()) {
ObjectName resourcesName =
new ObjectName(this.getDomain() + ":type=Cache,host="
+ getHostname() + ",path="
+ (("".equals(getPath()))?"/":getPath()));
Registry.getRegistry(null, null).registerComponent
(proxyDirContext.getCache(), resourcesName, null);
}
this.resources = proxyDirContext;
} catch (Throwable t) {
log.error(sm.getString("standardContext.resourcesStart"), t);
ok = false;
}
return (ok);
}
示例12: reload
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Reload the web application at the specified context path.
*
* @param writer Writer to render to
* @param path Context path of the application to be restarted
*/
protected void reload(PrintWriter writer, String path) {
if (debug >= 1)
log("restart: Reloading web application at '" + path + "'");
if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
writer.println(sm.getString("managerServlet.invalidPath", path));
return;
}
String displayPath = path;
if( path.equals("/") )
path = "";
try {
Context context = deployer.findDeployedApp(path);
if (context == null) {
writer.println(sm.getString("managerServlet.noContext", displayPath));
return;
}
DirContext resources = context.getResources();
if (resources instanceof ProxyDirContext) {
resources = ((ProxyDirContext) resources).getDirContext();
}
if (resources instanceof WARDirContext) {
writer.println(sm.getString("managerServlet.noReload", displayPath));
return;
}
// It isn't possible for the manager to reload itself
if (context.getPath().equals(this.context.getPath())) {
writer.println(sm.getString("managerServlet.noSelf"));
return;
}
context.reload();
writer.println(sm.getString("managerServlet.reloaded", displayPath));
} catch (Throwable t) {
log("ManagerServlet.reload[" + displayPath + "]", t);
writer.println(sm.getString("managerServlet.exception",
t.toString()));
}
}
示例13: reload
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* Reload the web application at the specified context path.
*
* @param writer Writer to render to
* @param path Context path of the application to be restarted
*/
protected void reload(final PrintWriter writer, String path) {
if (debug >= 1) {
log("restart: Reloading web application at '" + path + '\'');
}
if (path == null || !path.startsWith("/") && path.length() == 0) {
writer.println(sm.getString("managerServlet.invalidPath", path));
return;
}
final String displayPath = path;
if (path.equals("/")) {
path = "";
}
try {
final Context context = deployer.findDeployedApp(path);
if (context == null) {
writer.println(sm.getString("managerServlet.noContext", displayPath));
return;
}
DirContext resources = context.getResources();
if (resources instanceof ProxyDirContext) {
resources = ((ProxyDirContext) resources).getDirContext();
}
if (resources instanceof WARDirContext) {
writer.println(sm.getString("managerServlet.noReload", displayPath));
return;
}
// It isn't possible for the manager to reload itself
if (context.getPath().equals(this.context.getPath())) {
writer.println(sm.getString("managerServlet.noSelf"));
return;
}
context.reload();
writer.println(sm.getString("managerServlet.reloaded", displayPath));
} catch (Throwable t) {
log("ManagerServlet.reload[" + displayPath + ']', t);
writer.println(sm.getString("managerServlet.exception",
t.toString()));
}
}
示例14: resourcesStart
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* 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);
}
this.resources = proxyDirContext;
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.error(sm.getString("standardContext.resourcesStart"), t);
ok = false;
}
return (ok);
}
示例15: resourcesStart
import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
/**
* 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()) {
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);
}
this.resources = proxyDirContext;
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.error(sm.getString("standardContext.resourcesStart"), t);
ok = false;
}
return (ok);
}