當前位置: 首頁>>代碼示例>>Java>>正文


Java Connector.setAttribute方法代碼示例

本文整理匯總了Java中org.apache.catalina.connector.Connector.setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java Connector.setAttribute方法的具體用法?Java Connector.setAttribute怎麽用?Java Connector.setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.catalina.connector.Connector的用法示例。


在下文中一共展示了Connector.setAttribute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private void setConnector(Connector connector)
{
    if( maxThreads != -2 )
    {
        connector.setAttribute("maxThreads", maxThreads);
    }
    connector.setURIEncoding("UTF-8");
    connector.setUseBodyEncodingForURI(true);
    tomcat.getService().addConnector(connector);
    tomcat.setConnector(connector);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:12,代碼來源:TomcatServiceImpl.java

示例2: testCustomSslImplementation

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
@Test
public void testCustomSslImplementation() throws Exception {

    TesterSupport.configureClientSsl();

    Tomcat tomcat = getTomcatInstance();
    Connector connector = tomcat.getConnector();

    Assume.assumeFalse("This test is only for JSSE based SSL connectors",
            connector.getProtocolHandlerClassName().contains("Apr"));

    connector.setProperty("sslImplementationName",
            "org.apache.tomcat.util.net.jsse.TesterBug50640SslImpl");
    connector.setProperty(TesterBug50640SslImpl.PROPERTY_NAME,
            TesterBug50640SslImpl.PROPERTY_VALUE);

    connector.setProperty("sslProtocol", "tls");

    File keystoreFile =
        new File("test/org/apache/tomcat/util/net/localhost.jks");
    connector.setAttribute(
            "keystoreFile", keystoreFile.getAbsolutePath());

    connector.setSecure(true);
    connector.setProperty("SSLEnabled", "true");

    File appDir = new File(getBuildDirectory(), "webapps/examples");
    tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());

    tomcat.start();
    ByteChunk res = getUrl("https://localhost:" + getPort() +
        "/examples/servlets/servlet/HelloWorldExample");
    assertTrue(res.toString().indexOf("<a href=\"../helloworld.html\">") > 0);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:35,代碼來源:TestCustomSsl.java

示例3: makeConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private Connector makeConnector() {
  Connector connector = new Connector(Http11Nio2Protocol.class.getName());

  if (keystoreFile == null) {

    // HTTP connector
    connector.setPort(port);
    connector.setSecure(false);
    connector.setScheme("http");

  } else {

    // HTTPS connector
    connector.setPort(securePort);
    connector.setSecure(true);
    connector.setScheme("https");
    connector.setAttribute("SSLEnabled", "true");
    SSLHostConfig sslHostConfig = new SSLHostConfig();
    SSLHostConfigCertificate cert =
        new SSLHostConfigCertificate(sslHostConfig, SSLHostConfigCertificate.Type.RSA);
    cert.setCertificateKeystoreFile(keystoreFile.toAbsolutePath().toString());
    cert.setCertificateKeystorePassword(keystorePassword);
    cert.setCertificateKeyAlias(keyAlias);
    sslHostConfig.addCertificate(cert);
    connector.addSslHostConfig(sslHostConfig);
  }

  connector.addUpgradeProtocol(new Http2Protocol());

  // Keep quiet about the server type
  connector.setXpoweredBy(false);

  // Basic tuning params:
  connector.setAttribute("maxThreads", 400);
  connector.setAttribute("acceptCount", 50);
  //connector.setAttribute("connectionTimeout", 2000);
  connector.setAttribute("maxKeepAliveRequests", 100);

  // Avoid running out of ephemeral ports under heavy load?
  connector.setAttribute("socket.soReuseAddress", true);

  connector.setMaxPostSize(0);
  connector.setAttribute("disableUploadTimeout", false);

  // Allow long URLs
  connector.setAttribute("maxHttpHeaderSize", 65536);

  // Enable response compression
  connector.setAttribute("compression", "on");
  // Defaults are text/html,text/xml,text/plain,text/css
  connector.setAttribute("compressableMimeType", "text/html,text/xml,text/plain,text/css,text/csv,application/json");

  return connector;
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:55,代碼來源:ServingLayer.java

示例4: start

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
/**
 * Starts the Tomcat server.
 */
public void start() {
    try {
        System.out.println("(EmbeddedTomcat) Creating the embedded Tomcat servlet container");

        System.out.println("(EmbeddedTomcat) Catalina home: " + tomcatHome);
        System.setProperty("catalina.home", tomcatHome);
        System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
        
        // Create an embedded server
        System.out.println("(EmbeddedTomcat) Creating a new instance of EmbeddedTomcat");
        embedded = new Tomcat();
        embedded.enableNaming();
        
        // Assemble and install a default HTTP connector
        int httpConnectorPort = 8080;

        // We must load the engine properties first 
        EnginePropertiesManager.loadProperties();

        String convertigoServer = com.twinsoft.convertigo.engine.EnginePropertiesManager.getProperty(
                com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL);
        System.out.println("(EmbeddedTomcat) Convertigo server property: " + convertigoServer);
        
        int i = convertigoServer.indexOf(':', 6);
        if (i != -1) {
            int j = convertigoServer.indexOf("/convertigo");
            httpConnectorPort = Integer.parseInt(convertigoServer.substring(i+1, j));
        }

        embedded.setPort(httpPort = httpConnectorPort);
        
        int httpsConnectorPort = httpConnectorPort + 1;
        System.out.println("(EmbeddedTomcat) Installing the embedded HTTPS connector listening on port " + httpsConnectorPort);
        
        Connector connector = new Connector();
        connector.setPort(httpsConnectorPort);
        connector.setSecure(true);
        connector.setScheme("https");
        connector.setAttribute("keystorePass", "password"); 
        connector.setAttribute("keystoreFile", tomcatHome + "/conf/.keystore"); 
        connector.setAttribute("clientAuth", false);
        connector.setAttribute("sslProtocol", "TLS");
        connector.setAttribute("SSLEnabled", true);
        embedded.getService().addConnector(connector);
        
        Context context = embedded.addWebapp("", tomcatHome + "webapps/ROOT");
        context.setParentClassLoader(this.getClass().getClassLoader());
        
        context = embedded.addWebapp("/convertigo", com.twinsoft.convertigo.engine.Engine.WEBAPP_PATH);
        context.setParentClassLoader(this.getClass().getClassLoader());
        
        File configFile = new File(com.twinsoft.convertigo.engine.Engine.USER_WORKSPACE_PATH + "/studio/context.xml");
        if (configFile.exists()) {
            System.out.println("(EmbeddedTomcat) Set convertigo webapp config file to " + configFile.getAbsolutePath());
            context.setConfigFile(configFile.toURI().toURL());
        }
    
        // Start the embedded server
        System.out.println("(EmbeddedTomcat) Starting the server");
        embedded.start();

        System.out.println("(EmbeddedTomcat) Server successfully started!");
    }
    catch(Throwable e) {
        String stackTrace = Log.getStackTrace(e);
        System.out.println("(EmbeddedTomcat) Unexpected exception while launching Tomcat:\n" + stackTrace);
        Engine.isStartFailed = true;			
    }
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:73,代碼來源:EmbeddedTomcat.java

示例5: setUp

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
@Before
@Override
public void setUp() throws Exception {
    super.setUp();

    // Trigger loading of catalina.properties
    CatalinaProperties.getProperty("foo");

    File appBase = new File(getTemporaryDirectory(), "webapps");
    if (!appBase.exists() && !appBase.mkdir()) {
        fail("Unable to create appBase for test");
    }

    tomcat = new TomcatWithFastSessionIDs();

    String protocol = getProtocol();
    Connector connector = new Connector(protocol);
    // Listen only on localhost
    connector.setAttribute("address",
            InetAddress.getByName("localhost").getHostAddress());
    // Use random free port
    connector.setPort(0);
    // Mainly set to reduce timeouts during async tests
    connector.setAttribute("connectionTimeout", "3000");
    tomcat.getService().addConnector(connector);
    tomcat.setConnector(connector);

    // Add AprLifecycleListener if we are using the Apr connector
    if (protocol.contains("Apr")) {
        StandardServer server = (StandardServer) tomcat.getServer();
        AprLifecycleListener listener = new AprLifecycleListener();
        listener.setSSLRandomSeed("/dev/urandom");
        server.addLifecycleListener(listener);
        connector.setAttribute("pollerThreadCount", Integer.valueOf(1));
    }

    File catalinaBase = getTemporaryDirectory();
    tomcat.setBaseDir(catalinaBase.getAbsolutePath());
    tomcat.getHost().setAppBase(appBase.getAbsolutePath());

    accessLogEnabled = Boolean.parseBoolean(
        System.getProperty("tomcat.test.accesslog", "false"));
    if (accessLogEnabled) {
        String accessLogDirectory = System
                .getProperty("tomcat.test.reports");
        if (accessLogDirectory == null) {
            accessLogDirectory = new File(getBuildDirectory(), "logs")
                    .toString();
        }
        AccessLogValve alv = new AccessLogValve();
        alv.setDirectory(accessLogDirectory);
        alv.setPattern("%h %l %u %t \"%r\" %s %b %I %D");
        tomcat.getHost().getPipeline().addValve(alv);
    }

    // Cannot delete the whole tempDir, because logs are there,
    // but delete known subdirectories of it.
    addDeleteOnTearDown(new File(catalinaBase, "webapps"));
    addDeleteOnTearDown(new File(catalinaBase, "work"));
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:61,代碼來源:TomcatBaseTest.java


注:本文中的org.apache.catalina.connector.Connector.setAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。