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


Java AbstractConnector类代码示例

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


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

示例1: getEmbeddedServletContainer

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
		ServletContextInitializer... initializers) {
	JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext();
	int port = (getPort() >= 0 ? getPort() : 0);
	InetSocketAddress address = new InetSocketAddress(getAddress(), port);
	Server server = createServer(address);
	configureWebAppContext(context, initializers);
	server.setHandler(addHandlerWrappers(context));
	this.logger.info("Server initialized with port: " + port);
	if (getSsl() != null && getSsl().isEnabled()) {
		SslContextFactory sslContextFactory = new SslContextFactory();
		configureSsl(sslContextFactory, getSsl());
		AbstractConnector connector = getSslServerConnectorFactory()
				.getConnector(server, sslContextFactory, port);
		server.setConnectors(new Connector[] { connector });
	}
	for (JettyServerCustomizer customizer : getServerCustomizers()) {
		customizer.customize(server);
	}
	if (this.useForwardHeaders) {
		new ForwardHeadersCustomizer().customize(server);
	}
	return getJettyEmbeddedServletContainer(server);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:JettyEmbeddedServletContainerFactory.java

示例2: getConnector

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
@Override
public AbstractConnector getConnector(Server server,
		SslContextFactory sslContextFactory, int port) {
	try {
		Class<?> connectorClass = Class
				.forName("org.eclipse.jetty.server.ssl.SslSocketConnector");
		AbstractConnector connector = (AbstractConnector) connectorClass
				.getConstructor(SslContextFactory.class)
				.newInstance(sslContextFactory);
		connector.getClass().getMethod("setPort", int.class).invoke(connector,
				port);
		return connector;
	}
	catch (Exception ex) {
		throw new IllegalStateException(ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:JettyEmbeddedServletContainerFactory.java

示例3: customizeConnectionTimeout

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
private void customizeConnectionTimeout(
		JettyEmbeddedServletContainerFactory factory,
		final int connectionTimeout) {
	factory.addServerCustomizers(new JettyServerCustomizer() {
		@Override
		public void customize(Server server) {
			for (org.eclipse.jetty.server.Connector connector : server
					.getConnectors()) {
				if (connector instanceof AbstractConnector) {
					((AbstractConnector) connector)
							.setIdleTimeout(connectionTimeout);
				}
			}
		}
	});
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:ServerProperties.java

示例4: setupJettyServer

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
private static Server setupJettyServer(VarOneConfiguration conf) {
	AbstractConnector connector = new SelectChannelConnector();
    

    // Set some timeout options to make debugging easier.
    int timeout = 1000 * 30;
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setHost(conf.getServerAddress());
    connector.setPort(conf.getServerPort());

    final Server server = new Server();
    server.addConnector(connector);

    return server;
}
 
开发者ID:SparkMonitor,项目名称:varOne,代码行数:17,代码来源:VarOneServer.java

示例5: applyConfiguration

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
protected void applyConfiguration(AbstractConnector connector) {
    connector.setAcceptorPriorityOffset(configuration.getAcceptorThreadPriorityOffset());
    connector.setAcceptors(configuration.getAcceptorThreads());
    connector.setAcceptQueueSize(configuration.getAcceptQueueSize());
    connector.setLowResourcesMaxIdleTime(configuration.getLowResourcesMaxIdleTime());
    connector.setMaxBuffers(configuration.getMaxBufferCount());
    connector.setMaxIdleTime(configuration.getMaxIdleTime());
    connector.setRequestBufferSize(configuration.getRequestBufferSize());
    connector.setRequestHeaderSize(configuration.getRequestHeaderBufferSize());
    connector.setResponseBufferSize(configuration.getResponseBufferSize());
    connector.setResponseHeaderSize(configuration.getResponseHeaderBufferSize());
    connector.setReuseAddress(configuration.isReuseAddress());

    // Use X-Forwarded-For header for origin IP
    connector.setForwarded(true);
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:17,代码来源:AbstractConnectorFactory.java

示例6: build

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
@Override
public Set<? extends AbstractConnector> build() {
    final Set<AbstractConnector> connectors = new HashSet<AbstractConnector>();

    if (getConfiguration().isMixedMode()) {
        connectors.add(configureExternalHttpsConnector());
        connectors.add(configureExternalHttpConnector());
    } else if (getConfiguration().isSsl()) {
        connectors.add(configureExternalHttpsConnector());
    } else {
        connectors.add(configureExternalHttpConnector());
    }

    // apply the configured values to each connector
    for (AbstractConnector connector : connectors) {
        applyConfiguration(connector);
    }

    return connectors;
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:21,代码来源:ExternalConnectorFactory.java

示例7: configureExternalHttpsConnector

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
private AbstractConnector configureExternalHttpsConnector() {
    logger.info("Creating https connector");

    final SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setCertAlias(getConfiguration().getSslConfiguration().getKeyStoreAlias());
    sslContextFactory.setKeyStorePath(getConfiguration().getSslConfiguration().getKeyStorePath());
    sslContextFactory.setKeyStorePassword(getConfiguration().getSslConfiguration().getKeyStorePassword());

    final Integer port = getConfiguration().getSslConfiguration().getPort() != null ?
            getConfiguration().getSslConfiguration().getPort() :
            getConfiguration().getPort();

    final InstrumentedSslSocketConnector connector = new InstrumentedSslSocketConnector(
            this.metricRegistry,
            port,
            sslContextFactory,
            Clock.defaultClock());
    connector.setName(EXTERNAL_HTTPS_CONNECTOR_NAME);

    return connector;
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:22,代码来源:ExternalConnectorFactory.java

示例8: createConnector

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
	if (ClassUtils.isPresent(CONNECTOR_JETTY_8, getClass().getClassLoader())) {
		return new Jetty8ConnectorFactory().createConnector(server, address,
				this.acceptors, this.selectors);
	}
	return new Jetty9ConnectorFactory().createConnector(server, address,
			this.acceptors, this.selectors);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:JettyEmbeddedServletContainerFactory.java

示例9: getEmbeddedServletContainer

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
@Override
public EmbeddedServletContainer getEmbeddedServletContainer(
		ServletContextInitializer... initializers) {
	JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext();
	int port = (getPort() >= 0 ? getPort() : 0);
	Server server = new Server(new InetSocketAddress(getAddress(), port));
	configureWebAppContext(context, initializers);
	if (getCompression() != null && getCompression().getEnabled()) {
		HandlerWrapper gzipHandler = createGzipHandler();
		gzipHandler.setHandler(context);
		server.setHandler(gzipHandler);
	}
	else {
		server.setHandler(context);
	}
	this.logger.info("Server initialized with port: " + port);
	if (getSsl() != null && getSsl().isEnabled()) {
		SslContextFactory sslContextFactory = new SslContextFactory();
		configureSsl(sslContextFactory, getSsl());
		AbstractConnector connector = getSslServerConnectorFactory()
				.getConnector(server, sslContextFactory, port);
		server.setConnectors(new Connector[] { connector });
	}
	for (JettyServerCustomizer customizer : getServerCustomizers()) {
		customizer.customize(server);
	}
	if (this.useForwardHeaders) {
		new ForwardHeadersCustomizer().customize(server);
	}
	return getJettyEmbeddedServletContainer(server);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:32,代码来源:JettyEmbeddedServletContainerFactory.java

示例10: configureProxiedConnector

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
private void configureProxiedConnector(AbstractConnector connector) {
     // Check to see if we are deployed behind a proxy
     // Refer to http://docs.codehaus.org/display/JETTY/Configuring+Connectors
     if (isXFFEnabled()) {
     	connector.setForwarded(true);
     	// default: "X-Forwarded-For"
     	String forwardedForHeader = getXFFHeader();
     	if (forwardedForHeader != null) {
     		connector.setForwardedForHeader(forwardedForHeader);
     	}
     	// default: "X-Forwarded-Server"
     	String forwardedServerHeader = getXFFServerHeader();
     	if (forwardedServerHeader != null) {
     		connector.setForwardedServerHeader(forwardedServerHeader);
     	}
     	// default: "X-Forwarded-Host"
     	String forwardedHostHeader = getXFFHostHeader();
     	if (forwardedHostHeader != null) {
     		connector.setForwardedHostHeader(forwardedHostHeader);
     	}
     	// default: none
     	String hostName = getXFFHostName();
     	if (hostName != null) {
     		connector.setHostHeader(hostName);
     	}
     }
     connector.setStatsOn(JMXManager.isEnabled());
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:29,代码来源:HttpBindManager.java

示例11: build

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
@Override
public Set<? extends AbstractConnector> build() {
    final SocketConnector connector = new SocketConnector();
    connector.setPort(getConfiguration().getAdminPort());
    connector.setThreadPool(new QueuedThreadPool(8));
    connector.setName(INTERNAL_CONNECTOR_NAME);
    return Sets.newHashSet(connector);
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:9,代码来源:InternalConnectorFactory.java

示例12: configureExternalHttpConnector

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
private AbstractConnector configureExternalHttpConnector() {
    logger.info("Creating http connector");

    final InstrumentedSelectChannelConnector connector = new InstrumentedSelectChannelConnector(
            this.metricRegistry,
            getConfiguration().getPort(),
            Clock.defaultClock());
    connector.setName(EXTERNAL_HTTP_CONNECTOR_NAME);
    connector.setUseDirectBuffers(true);

    return connector;
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:13,代码来源:ExternalConnectorFactory.java

示例13: createConnectorJettyInternal

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
protected AbstractConnector createConnectorJettyInternal(Server server,
                                                  JettyHttpEndpoint endpoint,
                                                  SslContextFactory sslcf) {
    try {
        String hosto = endpoint.getHttpUri().getHost();
        int porto = endpoint.getPort();
        org.eclipse.jetty.server.HttpConfiguration httpConfig = new org.eclipse.jetty.server.HttpConfiguration();
        httpConfig.setSendServerVersion(endpoint.isSendServerVersion());
        httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
        httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
        
        if (requestBufferSize != null) {
            // Does not work
            //httpConfig.setRequestBufferSize(requestBufferSize);
        }
        if (requestHeaderSize != null) {
            httpConfig.setRequestHeaderSize(requestHeaderSize);
        }
        if (responseBufferSize != null) {
            httpConfig.setOutputBufferSize(responseBufferSize);
        }
        if (responseHeaderSize != null) {
            httpConfig.setResponseHeaderSize(responseHeaderSize);
        }
        
        HttpConnectionFactory httpFactory = new org.eclipse.jetty.server.HttpConnectionFactory(httpConfig); 

        ArrayList<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>();
        ServerConnector result = new org.eclipse.jetty.server.ServerConnector(server);
        if (sslcf != null) {
            httpConfig.addCustomizer(new org.eclipse.jetty.server.SecureRequestCustomizer());
            SslConnectionFactory scf = new org.eclipse.jetty.server.SslConnectionFactory(sslcf, "HTTP/1.1");
            connectionFactories.add(scf);
            result.setDefaultProtocol("SSL-HTTP/1.1");
        }
        connectionFactories.add(httpFactory);
        result.setConnectionFactories(connectionFactories);
        result.setPort(porto);
        if (hosto != null) {
            result.setHost(hosto);
        }
        /*
        if (getSocketConnectorProperties() != null && !"https".equals(endpoint.getProtocol())) {
            // must copy the map otherwise it will be deleted
            Map<String, Object> properties = new HashMap<String, Object>(getSocketConnectorProperties());
            IntrospectionSupport.setProperties(httpConfig, properties);
            if (properties.size() > 0) {
                throw new IllegalArgumentException("There are " + properties.size()
                    + " parameters that couldn't be set on the SocketConnector."
                    + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
                    + " Unknown parameters=[" + properties + "]");
            }
        } else*/
        if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) {
            // must copy the map otherwise it will be deleted
            Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
            IntrospectionSupport.setProperties(sslcf, properties);
            if (properties.size() > 0) {
                throw new IllegalArgumentException("There are " + properties.size()
                    + " parameters that couldn't be set on the SocketConnector."
                    + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
                    + " Unknown parameters=[" + properties + "]");
            }                
        }
        return result;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:70,代码来源:JettyHttpComponent9.java

示例14: addConnector

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
/**
 * Adds a listener to the <code>httpServer</code>. The listener is created and configured
 * according to the Jetty configuration.
 * @param httpServer the server to add the listener to
 * @param jettyConfig The configuraton for the server. Do not read the port at this point.
 * @param port The port to listen on. The configuration may have been overriden by this value.
 * @throws UnknownHostException if an invalid hostname was specified in the Mulgara server configuration
 */
@SuppressWarnings("deprecation")
private void addConnector(Server httpServer, JettyConnector jettyConfig, int port) throws UnknownHostException {
  if (httpServer == null) throw new IllegalArgumentException("Null \"httpServer\" parameter");

  if (logger.isDebugEnabled()) logger.debug("Adding socket listener");

  // create and configure a listener
  AbstractConnector connector = new BlockingChannelConnector();
  if ((hostName != null) && !hostName.equals("")) {
    connector.setHost(hostName);
    if (logger.isDebugEnabled()) logger.debug("Servlet container listening on host " + hostName);
  } else {
    hostName = EmbeddedMulgaraServer.getResolvedLocalHost();
    if (logger.isDebugEnabled()) logger.debug("Servlet container listening on all host interfaces");
  }

  // Each connector will get its own thread pool, so that they may be configured separately.
  // If a connector does not have its own thread pool, it inherits one from the server that it might
  // share with other connectors.
  QueuedThreadPool threadPool = new QueuedThreadPool();
  if (jettyConfig.hasMaxThreads()) {
    threadPool.setMaxThreads(jettyConfig.getMaxThreads());
  }
  connector.setThreadPool(threadPool);

  connector.setPort(port);
  if (jettyConfig.hasMaxIdleTimeMs()) connector.setMaxIdleTime(jettyConfig.getMaxIdleTimeMs());
  if (jettyConfig.hasLowResourceMaxIdleTimeMs()) connector.setLowResourceMaxIdleTime(jettyConfig.getLowResourceMaxIdleTimeMs());
  if (jettyConfig.hasAcceptors()) {
    int acceptors = jettyConfig.getAcceptors();
    // Acceptors are part of the thread pool, but they delegate handling of servlet
    // requests to another thread in the pool.  Therefore, the number of acceptors
    // must be strictly less than the maximum number of threads in the pool.
    int acceptorLimit = threadPool.getMaxThreads() - 1;
    if (acceptors > acceptorLimit) {
      logger.warn("Acceptor threads set beyond HTTP Server limits. Reducing from" + acceptors + " to " + acceptorLimit);
      acceptors = acceptorLimit;
    }
    connector.setAcceptors(acceptors);
  }

  // add the listener to the http server
  httpServer.addConnector(connector);
}
 
开发者ID:quoll,项目名称:mulgara,代码行数:53,代码来源:HttpServicesImpl.java

示例15: createConnectorJettyInternal

import org.eclipse.jetty.server.AbstractConnector; //导入依赖的package包/类
protected abstract AbstractConnector createConnectorJettyInternal(Server server, JettyHttpEndpoint endpoint, SslContextFactory sslcf); 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:2,代码来源:JettyHttpComponent.java


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