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


Java Connector.setPort方法代碼示例

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


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

示例1: httpConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
public Connector httpConnector() {
	Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
	connector.setScheme("http");
	// Connector監聽的http的端口號
	connector.setPort(80);
	connector.setSecure(false);
	// 監聽到http的端口號後轉向到的https的端口號
	connector.setRedirectPort(8443);
	return connector;
}
 
開發者ID:514840279,項目名稱:danyuan-application,代碼行數:11,代碼來源:App.java

示例2: configureHttp

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private void configureHttp(final TomcatEmbeddedServletContainerFactory tomcat) {
    final CasServerProperties.Http http = casProperties.getServer().getHttp();
    if (http.isEnabled()) {
        LOGGER.debug("Creating HTTP configuration for the embedded tomcat container...");
        final Connector connector = new Connector(http.getProtocol());
        int port = http.getPort();
        if (port <= 0) {
            LOGGER.warn("No explicit port configuration is provided to CAS. Scanning for available ports...");
            port = SocketUtils.findAvailableTcpPort();
        }
        LOGGER.info("Activated embedded tomcat container HTTP port to [{}]", port);
        connector.setPort(port);

        LOGGER.debug("Configuring embedded tomcat container for HTTP2 protocol support");
        connector.addUpgradeProtocol(new Http2Protocol());

        http.getAttributes().forEach(connector::setAttribute);
        tomcat.addAdditionalTomcatConnectors(connector);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:21,代碼來源:CasEmbeddedContainerTomcatConfiguration.java

示例3: createConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
/**
 * Create a new Connector
 *
 * @param parent MBean Name of the associated parent component
 * @param address The IP address on which to bind
 * @param port TCP port number to listen on
 * @param isAjp Create a AJP/1.3 Connector
 * @param isSSL Create a secure Connector
 *
 * @exception Exception if an MBean cannot be created or registered
 */
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
    throws Exception {
    Connector retobj = new Connector();
    if ((address!=null) && (address.length()>0)) {
        retobj.setProperty("address", address);
    }
    // Set port number
    retobj.setPort(port);
    // Set the protocol
    retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
    // Set SSL
    retobj.setSecure(isSSL);
    retobj.setScheme(isSSL ? "https" : "http");
    // Add the new instance to its parent component
    // FIX ME - addConnector will fail
    ObjectName pname = new ObjectName(parent);
    Service service = getService(pname);
    service.addConnector(retobj);
    
    // Return the corresponding MBean name
    ObjectName coname = retobj.getObjectName();
    
    return (coname.toString());
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:36,代碼來源:MBeanFactory.java

示例4: createSSLConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private Connector createSSLConnector(String absoluteKeyStore, String keystorePass) {
	Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
	Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
	try {
		connector.setPort(8443);
		connector.setSecure(true);
		connector.setScheme("https");
		
		protocol.setSSLEnabled(true);
		protocol.setKeystoreFile(absoluteKeyStore);
		protocol.setKeystorePass(keystorePass);
		protocol.setKeystoreType("JKS");
		protocol.setKeyAlias("tomcat");
		return connector;
	} catch(Exception ex) {
		throw new IllegalStateException("Can't access to keystore: [" + absoluteKeyStore + "]", ex);
	}
}
 
開發者ID:kflauri2312lffds,項目名稱:Android_watch_magpie,代碼行數:19,代碼來源:OAuth2SecurityConfiguration.java

示例5: additionalConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private Connector[] additionalConnector() {
  if (StringUtils.isBlank(this.additionalPorts)) {
    return null;
  }

  Set<String> defaultPorts = Sets.newHashSet(this.serverPort, this.managementPort);
  String[] ports = this.additionalPorts.split(",");
  List<Connector> result = new ArrayList<>();
  for (String port : ports) {
    if (!defaultPorts.contains(port)) {
      Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
      connector.setScheme("http");
      connector.setPort(Integer.valueOf(port));
      result.add(connector);
    }

  }

  return result.toArray(new Connector[] {});

}
 
開發者ID:SeldonIO,項目名稱:seldon-core,代碼行數:22,代碼來源:TomcatConfig.java

示例6: initiateHttpConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private Connector initiateHttpConnector() {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    connector.setScheme("http");
    connector.setPort(8080);
    connector.setSecure(false);
    connector.setRedirectPort(8443);

    return connector;
}
 
開發者ID:Clcanny,項目名稱:MicroServiceDemo,代碼行數:10,代碼來源:WebMvcConfig.java

示例7: servletContainer

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
@Bean
public EmbeddedServletContainerFactory servletContainer() {

    final TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
    if (isEnabled()) {
        final Connector ajpConnector = new Connector(getProtocol());
        ajpConnector.setPort(getPort());
        ajpConnector.setSecure(isSecure());
        ajpConnector.setAllowTrace(isAllowTrace());
        ajpConnector.setScheme(getScheme());

        tomcat.addAdditionalTomcatConnectors(ajpConnector);
    }

    return tomcat;
}
 
開發者ID:redlink-gmbh,項目名稱:smarti,代碼行數:17,代碼來源:TomcatConfiguration.java

示例8: createConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
/**
 * Create a new Connector
 *
 * @param parent
 *            MBean Name of the associated parent component
 * @param address
 *            The IP address on which to bind
 * @param port
 *            TCP port number to listen on
 * @param isAjp
 *            Create a AJP/1.3 Connector
 * @param isSSL
 *            Create a secure Connector
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
		throws Exception {
	Connector retobj = new Connector();
	if ((address != null) && (address.length() > 0)) {
		retobj.setProperty("address", address);
	}
	// Set port number
	retobj.setPort(port);
	// Set the protocol
	retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
	// Set SSL
	retobj.setSecure(isSSL);
	retobj.setScheme(isSSL ? "https" : "http");
	// Add the new instance to its parent component
	// FIX ME - addConnector will fail
	ObjectName pname = new ObjectName(parent);
	Service service = getService(pname);
	service.addConnector(retobj);

	// Return the corresponding MBean name
	ObjectName coname = retobj.getObjectName();

	return (coname.toString());
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:42,代碼來源:MBeanFactory.java

示例9: configureAjp

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private void configureAjp(final TomcatEmbeddedServletContainerFactory tomcat) {
    final CasServerProperties.Ajp ajp = casProperties.getServer().getAjp();
    if (ajp.isEnabled() && ajp.getPort() > 0) {
        LOGGER.debug("Creating AJP configuration for the embedded tomcat container...");
        final Connector ajpConnector = new Connector(ajp.getProtocol());
        ajpConnector.setProtocol(ajp.getProtocol());
        ajpConnector.setPort(ajp.getPort());
        ajpConnector.setSecure(ajp.isSecure());
        ajpConnector.setAllowTrace(ajp.isAllowTrace());
        ajpConnector.setScheme(ajp.getScheme());
        if (ajp.getAsyncTimeout() > 0) {
            ajpConnector.setAsyncTimeout(ajp.getAsyncTimeout());
        }
        ajpConnector.setEnableLookups(ajp.isEnableLookups());
        if (ajp.getMaxPostSize() > 0) {
            ajpConnector.setMaxPostSize(ajp.getMaxPostSize());
        }
        ajpConnector.addUpgradeProtocol(new Http2Protocol());

        if (ajp.getProxyPort() > 0) {
            LOGGER.debug("Set AJP proxy port to [{}]", ajp.getProxyPort());
            ajpConnector.setProxyPort(ajp.getProxyPort());
        }

        if (ajp.getRedirectPort() > 0) {
            LOGGER.debug("Set AJP redirect port to [{}]", ajp.getRedirectPort());
            ajpConnector.setRedirectPort(ajp.getRedirectPort());
        }

        ajp.getAttributes().forEach(ajpConnector::setAttribute);

        tomcat.addAdditionalTomcatConnectors(ajpConnector);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:35,代碼來源:CasEmbeddedContainerTomcatConfiguration.java

示例10: servletContainer

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
@Bean
public EmbeddedServletContainerFactory servletContainer() {

	TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
	if (tomcatAjpEnabled) {
		Connector ajpConnector = new Connector("AJP/1.3");
		ajpConnector.setPort(ajpPort);
		ajpConnector.setSecure(false);
		ajpConnector.setAllowTrace(false);
		ajpConnector.setScheme("http");
		tomcat.addAdditionalTomcatConnectors(ajpConnector);
	}

	return tomcat;
}
 
開發者ID:allianzit,項目名稱:ait-platform,代碼行數:16,代碼來源:AitTomcatCustomizer.java

示例11: 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

示例12: 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

示例13: 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

示例14: createStandardConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private Connector createStandardConnector() {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    connector.setPort(additionalHttpPort);
    return connector;
}
 
開發者ID:easyframe,項目名稱:easyframe,代碼行數:6,代碼來源:ZuulHttpConnector.java

示例15: createHttpConnector

import org.apache.catalina.connector.Connector; //導入方法依賴的package包/類
private Connector createHttpConnector() {
  final Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
  connector.setPort(getHttpPort());
  return connector;
}
 
開發者ID:adobe,項目名稱:S3Mock,代碼行數:6,代碼來源:S3MockApplication.java


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