本文整理汇总了Java中org.apache.naming.resources.FileDirContext类的典型用法代码示例。如果您正苦于以下问题:Java FileDirContext类的具体用法?Java FileDirContext怎么用?Java FileDirContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileDirContext类属于org.apache.naming.resources包,在下文中一共展示了FileDirContext类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testStartInternal
import org.apache.naming.resources.FileDirContext; //导入依赖的package包/类
@Test
public void testStartInternal() throws Exception {
Tomcat tomcat = getTomcatInstance();
File appDir = new File("test/webapp-3.0");
// Must have a real docBase - just use temp
StandardContext ctx =
(StandardContext)tomcat.addContext("", appDir.getAbsolutePath());
VirtualWebappLoader loader = new VirtualWebappLoader();
loader.setContainer(ctx);
ctx.setLoader(loader);
ctx.setResources(new FileDirContext());
ctx.resourcesStart();
File dir = new File("test/webapp-3.0-fragments/WEB-INF/lib");
loader.setVirtualClasspath(dir.getAbsolutePath() + "/*.jar");
loader.start();
String[] repos = loader.getRepositories();
assertEquals(2,repos.length);
loader.stop();
// ToDo: Why doesn't remove repositories?
repos = loader.getRepositories();
assertEquals(2, repos.length);
// no leak
loader.start();
repos = loader.getRepositories();
assertEquals(2,repos.length);
// clear loader
ctx.setLoader(null);
// see tearDown()!
tomcat.start();
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:35,代码来源:TestVirtualWebappLoader.java
示例2: setResources
import org.apache.naming.resources.FileDirContext; //导入依赖的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) {
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
this.resources = null;
support.firePropertyChange("resources", oldResources,
this.webappResources);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:StandardContext.java
示例3: setResources
import org.apache.naming.resources.FileDirContext; //导入依赖的package包/类
/**
* Set the resources DirContext object with which this Container is
* associated.
*
* @param resources The newly associated DirContext
*/
public synchronized void setResources(DirContext resources) {
if (started) {
throw new IllegalStateException
(sm.getString("standardContext.resources.started"));
}
DirContext oldResources = this.webappResources;
if (oldResources == resources)
return;
if (resources instanceof BaseDirContext) {
((BaseDirContext) resources).setCached(isCachingAllowed());
((BaseDirContext) resources).setCacheTTL(getCacheTTL());
((BaseDirContext) resources).setCacheMaxSize(getCacheMaxSize());
((BaseDirContext) resources).setCacheObjectMaxSize(getCacheObjectMaxSize());
}
if (resources instanceof FileDirContext) {
filesystemBased = true;
((FileDirContext) resources).setCaseSensitive(isCaseSensitive());
((FileDirContext) resources).setAllowLinking(isAllowLinking());
}
this.webappResources = resources;
// The proxied resources will be refreshed on start
this.resources = null;
support.firePropertyChange("resources", oldResources,
this.webappResources);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:StandardContext.java
示例4: setResources
import org.apache.naming.resources.FileDirContext; //导入依赖的package包/类
/**
* Set the resources DirContext object with which this Container is
* associated.
*
* @param resources The newly associated DirContext
*/
public synchronized void setResources(DirContext resources) {
if (resources instanceof BaseDirContext) {
((BaseDirContext) resources).setCached(isCachingAllowed());
}
if (resources instanceof FileDirContext) {
filesystemBased = true;
}
super.setResources(resources);
if (started)
postResources(); // As a servlet context attribute
}
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:20,代码来源:StandardContext.java
示例5: setResources
import org.apache.naming.resources.FileDirContext; //导入依赖的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) {
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
this.resources = null;
support.firePropertyChange("resources", oldResources, this.webappResources);
}
开发者ID:how2j,项目名称:lazycat,代码行数:40,代码来源:StandardContext.java
示例6: init
import org.apache.naming.resources.FileDirContext; //导入依赖的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);
}
}
开发者ID:josmas,项目名称:openwonderland,代码行数:30,代码来源:WonderlandWebdavServlet.java
示例7: setResources
import org.apache.naming.resources.FileDirContext; //导入依赖的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) {
if (getState().isAvailable()) {
throw new IllegalStateException
(sm.getString("standardContext.resources.started"));
}
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
this.resources = null;
support.firePropertyChange("resources", oldResources,
this.webappResources);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:42,代码来源:StandardContext.java
示例8: testStartInternal
import org.apache.naming.resources.FileDirContext; //导入依赖的package包/类
@Test
public void testStartInternal() throws Exception {
Tomcat tomcat = getTomcatInstance();
File appDir = new File("test/webapp-3.0");
// Must have a real docBase - just use temp
StandardContext ctx =
(StandardContext)tomcat.addContext("", appDir.getAbsolutePath());
VirtualWebappLoader loader = new VirtualWebappLoader();
loader.setContainer(ctx);
ctx.setLoader(loader);
ctx.setResources(new FileDirContext());
ctx.resourcesStart();
File dir = new File("test/webapp-3.0-fragments/WEB-INF/lib");
loader.setVirtualClasspath(dir.getAbsolutePath() + "/*.jar");
loader.start();
String[] repos = loader.getRepositories();
assertEquals(2,repos.length);
loader.stop();
// ToDo: Why doesn't remove repositories?
repos = loader.getRepositories();
assertEquals(2, repos.length);
// no leak
loader.start();
repos = loader.getRepositories();
assertEquals(2,repos.length);
// clear loader
ctx.setLoader(null);
// see tearDown()!
tomcat.start();
}
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:35,代码来源:TestVirtualWebappLoader.java
示例9: resourcesStart
import org.apache.naming.resources.FileDirContext; //导入依赖的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);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:70,代码来源:StandardContext.java
示例10: resourcesStart
import org.apache.naming.resources.FileDirContext; //导入依赖的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);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:StandardContext.java
示例11: resourcesStart
import org.apache.naming.resources.FileDirContext; //导入依赖的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);
}
开发者ID:how2j,项目名称:lazycat,代码行数:60,代码来源:StandardContext.java
示例12: resourcesStart
import org.apache.naming.resources.FileDirContext; //导入依赖的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);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:70,代码来源:StandardContext.java
注:本文中的org.apache.naming.resources.FileDirContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论