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


Java ConnectionFactory类代码示例

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


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

示例1: getConnectorPath

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
private String getConnectorPath(ServerConnector sc) {
    String prefix = "http";
    String host = sc.getHost();
    int port = sc.getPort();

    ConnectionFactory cf = sc.getDefaultConnectionFactory();
    if (cf instanceof SslConnectionFactory) {
        prefix = "https";
    }

    if (host == null || host.equals("0.0.0.0")) {
        try {
            host = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            // Well, we failed to read from system, fall back to main.properties.
            // Better than nothing
            host = CONFIG.getJetty().getServerHost();
        }
    }

    String layout = "%s://%s:%d" + CONFIG.getContextPath();

    return String.format(layout, prefix, host, port);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:25,代码来源:JettyServer.java

示例2: setup

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
public ServerConnector setup(final Server server, final InetSocketAddress address) {
    final HttpConfiguration config = this.config.build();

    final ConnectionFactory[] factories = this.factories
        .stream()
        .map(f -> f.setup(config))
        .toArray(size -> new ConnectionFactory[size]);

    final ServerConnector c = new ServerConnector(server, factories);

    c.setHost(this.address.map(a -> a.getHostString()).orElseGet(address::getHostString));
    c.setPort(this.address.map(a -> a.getPort()).orElseGet(address::getPort));

    defaultProtocol.ifPresent(c::setDefaultProtocol);
    return c;
}
 
开发者ID:spotify,项目名称:heroic,代码行数:17,代码来源:JettyServerConnector.java

示例3: startHttpsServer

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
@BeforeClass
public static void startHttpsServer() throws Exception {
    skipIfHeadlessEnvironment();
    server = new Server();

    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(ErrorCases.class.getResource("keystore").getPath());
    sslContextFactory.setKeyStorePassword("activeeon");

    HttpConfiguration httpConfig = new HttpConfiguration();
    HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());

    ServerConnector sslConnector = new ServerConnector(server,
                                                       new ConnectionFactory[] { new SslConnectionFactory(sslContextFactory,
                                                                                                          HttpVersion.HTTP_1_1.asString()),
                                                                                 new HttpConnectionFactory(httpsConfig) });

    server.addConnector(sslConnector);
    server.start();
    serverUrl = "https://localhost:" + sslConnector.getLocalPort() + "/rest";
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:23,代码来源:ErrorCases.java

示例4: startup

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
public static boolean startup(int port) {
    Server server = new Server(port);
    
       ServletHandler handler = new ServletHandler();
       handler.addServletWithMapping(CrocoWebDecryptor.class, "/*");
       
    for(Connector y : server.getConnectors()) {
        for(ConnectionFactory x  : y.getConnectionFactories()) {
            if(x instanceof HttpConnectionFactory) {
                ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false);
            }
        }
    }

    server.setHandler(handler);
    try {
	    server.start();
	    return true;
	} catch (Exception e) {
		try {
			server.stop();
		} catch (Exception e2) {}
	}
    
    return false;
}
 
开发者ID:fhissen,项目名称:CrococryptFile,代码行数:27,代码来源:JettyStart.java

示例5: getServerUri

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
private URI getServerUri(ServerConnector connector)
		throws URISyntaxException {
	String scheme = "http";
	for (ConnectionFactory connectFactory : connector
			.getConnectionFactories()) {
		if (connectFactory.getProtocol().startsWith("SSL-http")) {
			scheme = "https";
		}
	}
	String host = connector.getHost();
	if (host == null) {
		try{
			host = InetAddress.getLocalHost().getHostName();
		}catch(Exception ex){}
	}
	if (host == null){
		host = "localhost";			
	}
	int myport = connector.getLocalPort();
	serverURI = new URI(String.format("%s://%s:%d", scheme, host, myport));
	System.out.println(new Date() + " Server URI: " + serverURI + this.contextPath);
	return serverURI;
}
 
开发者ID:yahoo,项目名称:mysql_perf_analyzer,代码行数:24,代码来源:App.java

示例6: startHttp1

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
private static Server startHttp1() throws Exception {
    Server server = new Server(0);

    ServletHandler handler = new ServletHandler();
    handler.addServletWithMapping(newServletHolder(thriftServlet), TSERVLET_PATH);
    handler.addServletWithMapping(newServletHolder(rootServlet), "/");
    handler.addFilterWithMapping(new FilterHolder(new ConnectionCloseFilter()), "/*",
                                 EnumSet.of(DispatcherType.REQUEST));

    server.setHandler(handler);

    for (Connector c : server.getConnectors()) {
        for (ConnectionFactory f : c.getConnectionFactories()) {
            for (String p : f.getProtocols()) {
                if (p.startsWith("h2c")) {
                    fail("Attempted to create a Jetty server without HTTP/2 support, but failed: " +
                         f.getProtocols());
                }
            }
        }
    }

    server.start();
    return server;
}
 
开发者ID:line,项目名称:armeria,代码行数:26,代码来源:ThriftOverHttpClientTServletIntegrationTest.java

示例7: startup

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
public static boolean startup(int port) {
    Server server = new Server(port);
    
       ServletHandler handler = new ServletHandler();
       handler.addServletWithMapping(Querler.class, "/*");
       
    for(Connector y : server.getConnectors()) {
        for(ConnectionFactory x  : y.getConnectionFactories()) {
            if(x instanceof HttpConnectionFactory) {
                ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false);
            }
        }
    }

    server.setHandler(handler);
    try {
	    server.start();
	    return true;
	} catch (Exception e) {
		try {
			server.stop();
		} catch (Exception e2) {}
	}
    
    return false;
}
 
开发者ID:fhissen,项目名称:CrococryptQuerl,代码行数:27,代码来源:JettyLaunch.java

示例8: start

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
public void start(){
    try{
        jettyServer=new Server(port);

        HttpConfiguration httpConfiguration = new HttpConfiguration();
        ConnectionFactory c = new HttpConnectionFactory(httpConfiguration);

        ServerConnector serverConnector = new ServerConnector(jettyServer, c);
        serverConnector.setPort(port);
        
        jettyServer.setConnectors(new Connector[] { serverConnector });

        jettyServer.setHandler(requestHandler);
        jettyServer.start();
    
        if(statusButton!=null){
            updateStatusIcon();
            iconThread=new IconThread();
            iconThread.start();
        }
    }
    catch(Exception e){
        wandora.handleError(e);
    }
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:26,代码来源:WandoraJettyServer.java

示例9: getPort

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
private Integer getPort(Scheme scheme) {
    for (Connector connector : server.getConnectors()) {
        if (connector instanceof ServerConnector) {
            ServerConnector serverConnector = (ServerConnector) connector;
            Collection<ConnectionFactory> connectionFactories = serverConnector.getConnectionFactories();
            for (ConnectionFactory connectionFactory : connectionFactories) {
                Class<? extends AbstractConnectionFactory> connectorClass;
                switch (scheme) {
                    case HTTP:
                        connectorClass = HttpConnectionFactory.class;
                        break;
                    case HTTPS:
                        connectorClass = SslConnectionFactory.class;
                        break;
                    default:
                        throw new UnsupportedOperationException("No such scheme.");
                }
                if (connectorClass.isAssignableFrom(connectionFactory.getClass())) {
                    return serverConnector.getLocalPort();
                }
            }
        }
    }
    return null;
}
 
开发者ID:xoom,项目名称:feathercon,代码行数:26,代码来源:FeatherCon.java

示例10: testSsl

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
@Test
public void testSsl() {
    final MockServer server = new MockServer();

    final Minijax minijax = new Minijax() {
        @Override
        protected Server createServer() {
            return server;
        }
    };

    minijax.property(MinijaxProperties.SSL_KEY_STORE_PATH, "keystore.jks")
            .property(MinijaxProperties.SSL_KEY_STORE_PASSWORD, "certpassword")
            .property(MinijaxProperties.SSL_KEY_MANAGER_PASSWORD, "certpassword")
            .run(8080);

    final Connector[] connectors = server.connectors;
    assertNotNull(connectors);
    assertEquals(1, connectors.length);

    final ServerConnector connector = (ServerConnector) connectors[0];
    assertNotNull(connector);

    final List<ConnectionFactory> factories = new ArrayList<>(connector.getConnectionFactories());
    assertEquals(2, factories.size());
    assertEquals("org.eclipse.jetty.server.SslConnectionFactory", factories.get(0).getClass().getName());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:28,代码来源:ServerTest.java

示例11: createServerConnector

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
private ServerConnector createServerConnector(Server server, ConfigMap<String, Object> connectorCfg, ConnectionFactory... factories) {
	ServerConnector connector = new ServerConnector(server, factories);
	
	connector.setHost(connectorCfg.getString("address", "0.0.0.0"));
	connector.setPort(connectorCfg.getInteger("port", 80));
	connector.setIdleTimeout(connectorCfg.getLong("timeout", TimeUnit.SECONDS.toMillis(60)));
	
	server.setAttribute(MAX_BODY_SIZE_KEY,  connectorCfg.getInteger("max-body-size", 4096) * KB);
	
	return connector;
}
 
开发者ID:PinaeOS,项目名称:pumbaa,代码行数:12,代码来源:PumbaaServer.java

示例12: customize

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
@Override
public void customize(Server server) {
	ForwardedRequestCustomizer customizer = new ForwardedRequestCustomizer();
	for (Connector connector : server.getConnectors()) {
		for (ConnectionFactory connectionFactory : connector
				.getConnectionFactories()) {
			if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) {
				((HttpConfiguration.ConnectionFactory) connectionFactory)
						.getHttpConfiguration().addCustomizer(customizer);
			}
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:JettyEmbeddedServletContainerFactory.java

示例13: createConnector

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
@Override
public AbstractConnector createConnector(Server server, InetSocketAddress address,
		int acceptors, int selectors) {
	ServerConnector connector = new ServerConnector(server, acceptors, selectors);
	connector.setHost(address.getHostName());
	connector.setPort(address.getPort());
	for (ConnectionFactory connectionFactory : connector
			.getConnectionFactories()) {
		if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) {
			((HttpConfiguration.ConnectionFactory) connectionFactory)
					.getHttpConfiguration().setSendServerVersion(false);
		}
	}
	return connector;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:JettyEmbeddedServletContainerFactory.java

示例14: buildConnector

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
@Override
protected ServerConnector buildConnector(Server server,
                                         Scheduler scheduler,
                                         ByteBufferPool bufferPool,
                                         String name,
                                         ThreadPool threadPool,
                                         ConnectionFactory... factories) {
    // Intercept any buildConnector() calls and wrap the provided ConnectionFactory instances with our InstrumentedConnectionFactoryWrapper
    InstrumentedConnectionFactoryWrapper connectionFactoryWrappers[] = new InstrumentedConnectionFactoryWrapper[factories.length];
    for (int i = 0; i < factories.length; ++i) {
        connectionFactoryWrappers[i] = new InstrumentedConnectionFactoryWrapper(factories[i], _metricRegistry.get(), getBindHost(), getPort());
    }

    return super.buildConnector(server, scheduler, bufferPool, name, threadPool, connectionFactoryWrappers);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:16,代码来源:InstrumentedHttpConnectorFactory.java

示例15: InstrumentedConnectionFactoryWrapper

import org.eclipse.jetty.server.ConnectionFactory; //导入依赖的package包/类
public InstrumentedConnectionFactoryWrapper(ConnectionFactory wrappedConnectionFactory, MetricRegistry metricRegistry, String bindHost, Integer port) {
    _wrappedConnectionFactory = wrappedConnectionFactory;

    final String counterName = name(HttpConnectionFactory.class,
            bindHost,
            Integer.toString(port),
            "activeConnections");
    _activeConnectionCounter = metricRegistry.counter(counterName);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:10,代码来源:InstrumentedHttpConnectorFactory.java


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