当前位置: 首页>>代码示例>>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;未经允许,请勿转载。