• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ProxyDirContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.naming.resources.ProxyDirContext的典型用法代码示例。如果您正苦于以下问题:Java ProxyDirContext类的具体用法?Java ProxyDirContext怎么用?Java ProxyDirContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProxyDirContext类属于org.apache.naming.resources包,在下文中一共展示了ProxyDirContext类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:ContainerBase.java


示例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);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:ContainerBase.java


示例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;
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:TomcatResolver.java


示例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);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:22,代码来源:ContainerBase.java


示例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);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:ContainerBase.java


示例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();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:12,代码来源:WebappClassLoaderBase.java


示例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());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:28,代码来源:TestStandardContextResources.java


示例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();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:WebappClassLoaderBase.java


示例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);
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:30,代码来源:WonderlandWebdavServlet.java


示例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);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:70,代码来源:StandardContext.java


示例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);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:StandardContext.java


示例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()));
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:48,代码来源:ManagerServlet.java


示例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()));
  }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:50,代码来源:ManagerServlet.java


示例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);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:60,代码来源:StandardContext.java


示例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);

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:70,代码来源:StandardContext.java


示例16: main

import org.apache.naming.resources.ProxyDirContext; //导入依赖的package包/类
public static void main(String[] args) {

    //invoke: http://localhost:8080/Modern or  http://localhost:8080/Primitive

    System.setProperty("catalina.base", System.getProperty("user.dir"));
    Connector connector = new HttpConnector();
    Wrapper wrapper1 = new SimpleWrapper();
    wrapper1.setName("Primitive");
    wrapper1.setServletClass("PrimitiveServlet");
    Wrapper wrapper2 = new SimpleWrapper();
    wrapper2.setName("Modern");
    wrapper2.setServletClass("ModernServlet");

    Context context = new StandardContext();
    // StandardContext's start method adds a default mapper
    context.setPath("/myApp");
    context.setDocBase("myApp");

    context.addChild(wrapper1);
    context.addChild(wrapper2);

    // context.addServletMapping(pattern, name);
    context.addServletMapping("/Primitive", "Primitive");
    context.addServletMapping("/Modern", "Modern");
    // add ContextConfig. This listener is important because it configures
    // StandardContext (sets configured to true), otherwise StandardContext
    // won't start
    LifecycleListener listener = new SimpleContextConfig();
    ((Lifecycle) context).addLifecycleListener(listener);

    // here is our loader
    Loader loader = new WebappLoader();
    // associate the loader with the Context
    context.setLoader(loader);

    connector.setContainer(context);

    try {
      connector.initialize();
      ((Lifecycle) connector).start();
      ((Lifecycle) context).start();
      // now we want to know some details about WebappLoader
      WebappClassLoader classLoader = (WebappClassLoader) loader.getClassLoader();
      System.out.println("Resources' docBase: " + ((ProxyDirContext)classLoader.getResources()).getDocBase());
      String[] repositories = classLoader.findRepositories();
      for (int i=0; i<repositories.length; i++) {
        System.out.println("  repository: " + repositories[i]);
      }

      // make the application wait until we press a key.
      System.in.read();
      ((Lifecycle) context).stop();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:58,代码来源:Bootstrap.java



注:本文中的org.apache.naming.resources.ProxyDirContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IDynamicStack类代码示例发布时间:2022-05-22
下一篇:
Java ServerEnvironment类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap