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


Java ServerConnector.setHost方法代码示例

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


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

示例1: JettyAdminServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
public JettyAdminServer(String address, int port, int timeout, String commandUrl) {
    this.port = port;
    this.idleTimeout = timeout;
    this.commandUrl = commandUrl;
    this.address = address;

    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    connector.setHost(address);
    connector.setPort(port);
    connector.setIdleTimeout(idleTimeout);
    server.addConnector(connector);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/*");
    server.setHandler(context);

    context.addServlet(new ServletHolder(new CommandServlet()), commandUrl + "/*");
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:20,代码来源:JettyAdminServer.java

示例2: jettyServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
@Bean
public Server jettyServer(ApplicationContext context) throws Exception {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    Servlet servlet = new JettyHttpHandlerAdapter(handler);

    Server server = new Server();
    ServletContextHandler contextHandler = new ServletContextHandler(server, "");
    contextHandler.addServlet(new ServletHolder(servlet), "/");
    contextHandler.start();

    ServerConnector connector = new ServerConnector(server);
    connector.setHost("localhost");
    connector.setPort(port);
    server.addConnector(connector);

    return server;
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:18,代码来源:Application.java

示例3: RestServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
/**
 * Create a REST server for this herder using the specified configs.
 */
public RestServer(WorkerConfig config) {
    this.config = config;

    // To make the advertised port available immediately, we need to do some configuration here
    String hostname = config.getString(WorkerConfig.REST_HOST_NAME_CONFIG);
    Integer port = config.getInt(WorkerConfig.REST_PORT_CONFIG);

    jettyServer = new Server();

    ServerConnector connector = new ServerConnector(jettyServer);
    if (hostname != null && !hostname.isEmpty())
        connector.setHost(hostname);
    connector.setPort(port);
    jettyServer.setConnectors(new Connector[]{connector});
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:19,代码来源:RestServer.java

示例4: setUp

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    PullHttpChangeIngestorCommonTest.init();

    final ServerConnector http = new ServerConnector(jetty);

    http.setPort(0);
    http.setHost("localhost");

    http.setIdleTimeout(3000L);
    jetty.addConnector(http);

    jetty.start();

    Thread.sleep(1000);

    if (!jetty.isStarted()) {
        throw new IllegalStateException("Jetty server not started");
    }
}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:21,代码来源:PullHttpChangeIngestorTest.java

示例5: JettyHttpTestServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
public JettyHttpTestServer(String host, int port){
       this.host = host;
       this.port = port;
	server = new Server();

       ServerConnector http = new ServerConnector(server);
       http.setHost(host);
       http.setPort(port);
       http.setIdleTimeout(30000);

       server.addConnector(http);
       server.setHandler(new RequestHandler());

       try {
           server.start();
       } catch (Exception e) {
           e.printStackTrace();
       }

       this.port = http.getLocalPort();
}
 
开发者ID:yahoo,项目名称:parsec-libraries,代码行数:22,代码来源:JettyHttpTestServer.java

示例6: start

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
public void start() {
    try {
        final ServerConnector httpConnector = new ServerConnector(server);

        httpConnector.setHost(root.host);
        httpConnector.setPort(root.port);
        httpConnector.setIdleTimeout(config.getInt("web.idle-timeout"));
        server.addConnector(httpConnector);

        final HandlerList handlers = new HandlerList();

        handlers.addHandler(inContext("/static", newResourcesHandler()));
        handlers.addHandler(inContext("/", new RootHandler(version, routes)));

        server.setHandler(handlers);
        server.start();

        log.info("Web Server started on http://" + root.host + ":" + root.port);
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        throw new RuntimeException(ex);
    }
}
 
开发者ID:alpian,项目名称:tired,代码行数:24,代码来源:WebServer.java

示例7: installListeners

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
private static void installListeners(Server server, Collection<? extends InetSocketAddress> addresses) {
    final List<Connector> connectors = new ArrayList<>(addresses.size());

    for (InetSocketAddress address : addresses) {
        final ServerConnector server_connector = new ServerConnector(server);
        server_connector.setReuseAddress(true);
        if (address.getAddress() != null) {
            if (!address.getAddress().isAnyLocalAddress()) {
                LOG.log(Level.INFO, "Binding API server address: {0}", address.getAddress().getHostAddress());
                server_connector.setHost(address.getAddress().getHostAddress());
            }
        } else if (address.getHostString() != null) {
            LOG.log(Level.INFO, "Binding API server address name: {0}", address.getHostString());
            server_connector.setHost(address.getHostString());
        }
        LOG.log(Level.INFO, "Binding API server port: {0}", address.getPort());
        server_connector.setPort(address.getPort());
        connectors.add(server_connector);
    }

    server.setConnectors(connectors.toArray(new Connector[connectors.size()]));
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:23,代码来源:ApiServer.java

示例8: jettyServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
/** Build a Jetty server */
private static Server jettyServer(int port, boolean loopback) {
    Server server = new Server() ;
    HttpConnectionFactory f1 = new HttpConnectionFactory() ;
    // Some people do try very large operations ... really, should use POST.
    f1.getHttpConfiguration().setRequestHeaderSize(512 * 1024);
    f1.getHttpConfiguration().setOutputBufferSize(5 * 1024 * 1024) ;
    // Do not add "Server: Jetty(....) when not a development system.
    if ( true )
        f1.getHttpConfiguration().setSendServerVersion(false) ;
    ServerConnector connector = new ServerConnector(server, f1) ;
    connector.setPort(port) ;
    server.addConnector(connector);
    if ( loopback )
        connector.setHost("localhost");
    return server ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:18,代码来源:PatchLogServer.java

示例9: setUp

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    component = new WebsocketComponent();
    component.setCamelContext(new DefaultCamelContext());
    System.out.println("Server : " + server.isStarted());
    server = component.createServer();
    System.out.println("Server : " + server.isStarted());
    ServerConnector connector = new ServerConnector(server);
    connector.setHost("localhost");
    connector.setPort(1988);
    server.addConnector(connector);

    WebsocketEndpoint endpoint = (WebsocketEndpoint) component.createEndpoint("websocket://x");
    producer = (WebsocketProducer) endpoint.createProducer();
    component.connect(producer);

    // wire the consumer with the endpoint so that WebSocketComponent.getConnectorKey() works without throwing NPE
    when(consumer.getEndpoint()).thenReturn(endpoint);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:WebsocketComponentTest.java

示例10: startServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
private void startServer() throws Exception {

        log.info("Starting http server on port " + httpPort);
        Server server = new Server(new QueuedThreadPool(threadCount));
        ServerConnector serverConnector = new ServerConnector(server);
        serverConnector.setPort(httpPort);
        if (!Strings.isNullOrEmpty(httpBindAddress)) {
            serverConnector.setHost(httpBindAddress);
        }
        server.setConnectors(new Connector[]{serverConnector});
        ServletContextHandler context = new ServletContextHandler();
        context.setMaxFormContentSize(maxFormContextSizeBytes);
        context.setContextPath("/");

        ServletHolder metricSearchServletHolder = new ServletHolder(metricSearchServlet);
        context.addServlet(metricSearchServletHolder, "/search/*");
        context.addServlet(metricSearchServletHolder, "/ban/*");
        context.addServlet(metricSearchServletHolder, "/multiBan/*");
        context.addServlet(metricSearchServletHolder, "/approve/*");
        context.addServlet(metricSearchServletHolder, "/multiApprove/*");
        context.addServlet(metricSearchServletHolder, "/hide/*");
        context.addServlet(metricSearchServletHolder, "/multiHide/*");

        ServletHolder monitoringServletHolder = new ServletHolder(monitoringServlet);
        context.addServlet(monitoringServletHolder, "/ping");
        context.addServlet(monitoringServletHolder, "/monitoring");

        ServletHolder metricDataServletHolder = new ServletHolder(metricDataServiceServlet);
        context.addServlet(metricDataServletHolder, "/metricData");

        HandlerCollection handlers = new HandlerCollection();
        handlers.setHandlers(new Handler[]{context, new DefaultHandler()});
        server.setHandler(handlers);
        server.start();

        log.info("Web server started on port " + httpPort);
    }
 
开发者ID:yandex,项目名称:graphouse,代码行数:38,代码来源:GraphouseWebServer.java

示例11: get

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
@Override
public ServerConnector get(Server server) {
  HttpConfiguration configuration = new HttpConfiguration(defaultConfig);
  configuration.setSecurePort(configurator.getPort());
  configuration.setSecureScheme(HttpScheme.HTTPS.asString());

  final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration));
  connector.setPort(configurator.getPort());
  connector.setHost(configurator.getHost());

  return connector;
}
 
开发者ID:sorskod,项目名称:webserver,代码行数:13,代码来源:HTTPSConnectorFactory.java

示例12: get

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
public ServerConnector get(Server server) {
  HttpConfiguration configuration = new HttpConfiguration(defaultConfig);

  final ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration));
  connector.setPort(configurator.getPort());
  connector.setHost(configurator.getHost());

  return connector;
}
 
开发者ID:sorskod,项目名称:webserver,代码行数:10,代码来源:HTTPConnectorFactory.java

示例13: createConnector

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
private void createConnector(Properties properties) {
    final ServerConnector http = new ServerConnector(jetty);

    http.setPort(Integer.parseInt(properties.getProperty(PORT_KEY, "0")));
    http.setHost(properties.getProperty(HOST_KEY, "localhost"));

    // Severely taxed or distant environments may have significant delays when executing.
    http.setIdleTimeout(30000L);
    jetty.addConnector(http);

    logger.info("Added an http connector on the host '{}' and port '{}'", new Object[]{http.getHost(), http.getPort()});
}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:13,代码来源:RestChangeIngestor.java

示例14: setUp

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
    PullHttpChangeIngestorCommonTest.init();

    SslContextFactory ssl = new SslContextFactory();

    ssl.setKeyStorePath("./src/test/resources/localhost-ks.jks");
    ssl.setKeyStorePassword("localtest");
    ssl.setKeyStoreType("JKS");
    ssl.setTrustStorePath("./src/test/resources/localhost-ts.jks");
    ssl.setTrustStorePassword("localtest");
    ssl.setTrustStoreType("JKS");
    ssl.setNeedClientAuth(true);

    // build the connector
    final ServerConnector https = new ServerConnector(jetty, ssl);

    // set host and port
    https.setPort(0);
    https.setHost("localhost");

    // Severely taxed environments may have significant delays when executing.
    https.setIdleTimeout(30000L);

    // add the connector
    jetty.addConnector(https);

    jetty.start();

    Thread.sleep(1000);

    if (!jetty.isStarted()) {
        throw new IllegalStateException("Jetty server not started");
    }
}
 
开发者ID:apache,项目名称:nifi-minifi,代码行数:36,代码来源:PullHttpChangeIngestorSSLTest.java

示例15: httpConnector

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
private ServerConnector httpConnector(HttpConfiguration httpConfig) {
    // === jetty-http.xml ===
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
    http.setHost(CONFIG.getJetty().getServerHost());
    http.setPort(CONFIG.getJetty().getHttpPort());
    http.setIdleTimeout(IDLE_TIMEOUT);
    return http;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:9,代码来源:JettyServer.java


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