当前位置: 首页>>代码示例>>Java>>正文


Java Wrapper.addInitParameter方法代码示例

本文整理汇总了Java中org.apache.catalina.Wrapper.addInitParameter方法的典型用法代码示例。如果您正苦于以下问题:Java Wrapper.addInitParameter方法的具体用法?Java Wrapper.addInitParameter怎么用?Java Wrapper.addInitParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.Wrapper的用法示例。


在下文中一共展示了Wrapper.addInitParameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doClassUnloadingPrep

import org.apache.catalina.Wrapper; //导入方法依赖的package包/类
private DefaultInstanceManager doClassUnloadingPrep() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Create the context (don't use addWebapp as we want to modify the
    // JSP Servlet settings).
    File appDir = new File("test/webapp-3.0");
    StandardContext ctxt = (StandardContext) tomcat.addContext(
            null, "/test", appDir.getAbsolutePath());

    // Configure the defaults and then tweak the JSP servlet settings
    // Note: Min value for maxLoadedJsps is 2
    Tomcat.initWebappDefaults(ctxt);
    Wrapper w = (Wrapper) ctxt.findChild("jsp");
    w.addInitParameter("maxLoadedJsps", "2");

    tomcat.start();

    return (DefaultInstanceManager) ctxt.getInstanceManager();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:TestDefaultInstanceManager.java

示例2: initWebappDefaults

import org.apache.catalina.Wrapper; //导入方法依赖的package包/类
/**
 * Static version of {@link #initWebappDefaults(String)}
 * @param ctx   The context to set the defaults for
 */
public static void initWebappDefaults(Context ctx) {
    // Default servlet 
    Wrapper servlet = addServlet(
            ctx, "default", "org.apache.catalina.servlets.DefaultServlet");
    servlet.setLoadOnStartup(1);
    servlet.setOverridable(true);

    // JSP servlet (by class name - to avoid loading all deps)
    servlet = addServlet(
            ctx, "jsp", "org.apache.jasper.servlet.JspServlet");
    servlet.addInitParameter("fork", "false");
    servlet.setLoadOnStartup(3);
    servlet.setOverridable(true);

    // Servlet mappings
    ctx.addServletMapping("/", "default");
    ctx.addServletMapping("*.jsp", "jsp");
    ctx.addServletMapping("*.jspx", "jsp");

    // Sessions
    ctx.setSessionTimeout(30);
    
    // MIME mappings
    for (int i = 0; i < DEFAULT_MIME_MAPPINGS.length;) {
        ctx.addMimeMapping(DEFAULT_MIME_MAPPINGS[i++],
                DEFAULT_MIME_MAPPINGS[i++]);
    }
    
    // Welcome files
    ctx.addWelcomeFile("index.html");
    ctx.addWelcomeFile("index.htm");
    ctx.addWelcomeFile("index.jsp");
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:Tomcat.java

示例3: doTestELMisc

import org.apache.catalina.Wrapper; //导入方法依赖的package包/类
private void doTestELMisc(boolean quoteAttributeEL) throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // Create the context (don't use addWebapp as we want to modify the
    // JSP Servlet settings).
    File appDir = new File("test/webapp-3.0");
    StandardContext ctxt = (StandardContext) tomcat.addContext(
            null, "/test", appDir.getAbsolutePath());

    // Configure the defaults and then tweak the JSP servlet settings
    // Note: Min value for maxLoadedJsps is 2
    Tomcat.initWebappDefaults(ctxt);
    Wrapper w = (Wrapper) ctxt.findChild("jsp");

    String jspName;
    if (quoteAttributeEL) {
        jspName = "/test/el-misc-with-quote-attribute-el.jsp";
        w.addInitParameter("quoteAttributeEL", "true");
    } else {
        jspName = "/test/el-misc-no-quote-attribute-el.jsp";
        w.addInitParameter("quoteAttributeEL", "false");
    }

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() + jspName);
    String result = res.toString();
    assertEcho(result, "00-\\\\\\\"${'hello world'}");
    assertEcho(result, "01-\\\\\\\"\\${'hello world'}");
    assertEcho(result, "02-\\\"${'hello world'}");
    assertEcho(result, "03-\\\"\\hello world");
    assertEcho(result, "2az-04");
    assertEcho(result, "05-a2z");
    assertEcho(result, "06-az2");
    assertEcho(result, "2az-07");
    assertEcho(result, "08-a2z");
    assertEcho(result, "09-az2");
    assertEcho(result, "10-${'foo'}bar");
    assertEcho(result, "11-\\\"}");
    assertEcho(result, "12-foo\\bar\\baz");
    assertEcho(result, "13-foo\\bar\\baz");
    assertEcho(result, "14-foo\\bar\\baz");
    assertEcho(result, "15-foo\\bar\\baz");
    assertEcho(result, "16-foo\\bar\\baz");
    assertEcho(result, "17-foo\\&apos;bar&apos;\\&quot;baz&quot;");
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:47,代码来源:TestELInJsp.java

示例4: makeContext

import org.apache.catalina.Wrapper; //导入方法依赖的package包/类
private void makeContext(Tomcat tomcat, Path noSuchBaseDir) throws IOException {
  Path contextPath = noSuchBaseDir.resolve("context");
  Files.createDirectories(contextPath);

  context = tomcat.addContext(contextPathURIBase, contextPath.toAbsolutePath().toString());

  context.setWebappVersion("3.1");
  context.setName("Oryx");

  context.addWelcomeFile("index.html");
  addErrorPages(context);

  // OryxApplication only needs one config value, so just pass it
  context.addParameter(OryxApplication.class.getName() + ".packages", appResourcesPackages);
  // ModelManagerListener will need whole config
  String serializedConfig = ConfigUtils.serialize(config);
  context.addParameter(ConfigUtils.class.getName() + ".serialized", serializedConfig);

  Wrapper wrapper =
      Tomcat.addServlet(context, "Jersey", "org.glassfish.jersey.servlet.ServletContainer");
  wrapper.addInitParameter("javax.ws.rs.Application", OryxApplication.class.getName());
  //wrapper.addInitParameter(OryxApplication.class.getName() + ".packages", appResourcesPackage);
  wrapper.addMapping("/*");
  wrapper.setLoadOnStartup(1);
  wrapper.setMultipartConfigElement(new MultipartConfigElement(""));

  if (!doNotInitTopics) { // Only for tests
    context.addApplicationListener(ModelManagerListener.class.getName());
  }

  // Better way to configure JASPIC?
  AuthConfigFactory.setFactory(new AuthConfigFactoryImpl());

  boolean needHTTPS = keystoreFile != null;
  boolean needAuthentication = userName != null;

  if (needHTTPS || needAuthentication) {

    SecurityCollection securityCollection = new SecurityCollection();
    securityCollection.addPattern("/*");
    SecurityConstraint securityConstraint = new SecurityConstraint();
    securityConstraint.addCollection(securityCollection);

    if (needHTTPS) {
      securityConstraint.setUserConstraint("CONFIDENTIAL");
    }

    if (needAuthentication) {

      LoginConfig loginConfig = new LoginConfig();
      loginConfig.setAuthMethod("DIGEST");
      loginConfig.setRealmName(InMemoryRealm.NAME);
      context.setLoginConfig(loginConfig);

      securityConstraint.addAuthRole(InMemoryRealm.AUTH_ROLE);

      context.addSecurityRole(InMemoryRealm.AUTH_ROLE);
      DigestAuthenticator authenticator = new DigestAuthenticator();
      authenticator.setNonceValidity(10 * 1000L); // Shorten from 5 minutes to 10 seconds
      authenticator.setNonceCacheSize(20000); // Increase from 1000 to 20000
      context.getPipeline().addValve(authenticator);
    }

    context.addConstraint(securityConstraint);
  }

  context.setCookies(false);
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:69,代码来源:ServingLayer.java


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