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


Java SelectChannelConnector.setHost方法代碼示例

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


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

示例1: TestServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public TestServer() {
    mJsonMapper = new ObjectMapper();

    mServletHandler = new ServletHandler();
    mServletHandler.addServletWithMapping(TestServletWs.class, "/ws");
    mServletHandler.addServletWithMapping(TestServletHttp.class, "/http");

    mConnector = new SelectChannelConnector();
    mConnector.setThreadPool(new QueuedThreadPool(10));
    mConnector.setHost("localhost");
    mConnector.setPort(0);

    mServer = new Server();
    mServer.setThreadPool(new QueuedThreadPool(10));
    mServer.setHandler(mServletHandler);
    mServer.setConnectors(new Connector[]{mConnector});
}
 
開發者ID:promovicz,項目名稱:better-jsonrpc,代碼行數:18,代碼來源:TestServer.java

示例2: buildConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@Override
public Connector buildConnector(Server server, InetAddress inetAddress, int port) {
	// create the NIO connector
	SelectChannelConnector connector = new SelectChannelConnector();
	if (inetAddress != null) {
		connector.setHost(inetAddress.getHostAddress());
	}
	connector.setPort(port);

	// turn on statistics
	connector.setStatsOn(true);
	// set whether or not to reuse the addresses
	connector.setReuseAddress(true);

	// configure the thread pool for accepting connections
	QueuedThreadPool threadPool = new QueuedThreadPool();
	threadPool.setMinThreads(WEB_SERVER_MIN_THREADS);
	threadPool.setMaxThreads(WEB_SERVER_MAX_THREADS);
	threadPool.setName("simplejmx-web-server");
	connector.setThreadPool(threadPool);
	connector.setAcceptors(WEB_SERVER_MIN_THREADS);

	return connector;
}
 
開發者ID:j256,項目名稱:simplejmx,代碼行數:25,代碼來源:Jetty8ConnectorFactory.java

示例3: start

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@Override
public void start() {
    if (isStarted()) {
        return;
    }
    jettyServer = new org.eclipse.jetty.server.Server();
    int port = serverConfig.getPort();
    DispatcherServlet.addHttpHandler(port, new WebServiceHandler());

    int threads = serverConfig.getServerBusinessPoolSize();
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setName("JSF-WS-BZ");
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(threads);
    threadPool.setMinThreads(threads);
    jettyServer.setThreadPool(threadPool);

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setHost(serverConfig.getHost());
    connector.setPort(serverConfig.getPort());
    jettyServer.addConnector(connector);

    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);

    jettyServer.setHandler(servletHandler);

    try {
        jettyServer.start();
    } catch (Exception e) {
        throw new InitErrorException("Failed to start jetty server at port " + port
                + ", cause: " + e.getMessage(), e);
    }
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:36,代碼來源:HttpWsServer.java

示例4: setAddressAndPort

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private static void setAddressAndPort(final Server jetty,
    final String bindAddress, final int port) {
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(port);

  if (!StringUtils.isBlank(bindAddress)) {
    connector.setHost(bindAddress);
  }
  jetty.addConnector(connector);
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:11,代碼來源:JettyHelper.java

示例5: start

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
	// 啟動web應用
	org.eclipse.jetty.server.Server server = new Server();
	server.setStopAtShutdown(true);
	SelectChannelConnector connector = new SelectChannelConnector();
	connector.setPort(Config.NET_CONFIG.getHessianPort());
	connector.setHost(Config.NET_CONFIG.getIp());
	// 解決Windows下重複啟動Jetty居然不報告端口衝突的問題.
	connector.setReuseAddress(false);
	server.setConnectors(new Connector[] { connector });
	// web配置
	WebAppContext context = new WebAppContext();
	String resourcePath = MyTvUtils.getRunningPath(HessianServer.class);
	logger.info("web app context path: " + resourcePath);
	context.setContextPath("/");
	String descriptor = resourcePath + "/WEB-INF/web.xml";
	logger.info("web app descriptor: " + descriptor);
	context.setDescriptor(descriptor);
	context.setResourceBase(resourcePath);
	context.setParentLoaderPriority(true);
	ClassLoader appClassLoader = Thread.currentThread()
			.getContextClassLoader();
	context.setClassLoader(appClassLoader);

	server.setHandler(context);
	server.start();
}
 
開發者ID:52Jolynn,項目名稱:MyTv,代碼行數:29,代碼來源:HessianServer.java

示例6: main

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * Entry point of Ephyra. Initializes the engine and starts the web service interface.
 * 
 * @param args command line arguments are ignored
 */
public static void main(String[] args) throws Exception {
	// enable output of status and error messages
	MsgPrinter.enableStatusMsgs(true);
	MsgPrinter.enableErrorMsgs(true);
	
	// set log file and enable logging
	Logger.setLogfile("log/OpenEphyra");
	Logger.enableLogging(true);
	

       String addr = "localhost";
       int port = 8080;
       if (args.length > 1) {
           addr = args[0];
           port = Integer.parseInt(args[1]);
       }
       int NTHREADS = Integer.parseInt(System.getenv("THREADS"));

       Server server = new Server();
       SelectChannelConnector con1 = new SelectChannelConnector();
       con1.setHost(addr);
       con1.setPort(port);
       con1.setThreadPool(new QueuedThreadPool(NTHREADS));
       con1.setMaxIdleTime(30000);
       con1.setRequestHeaderSize(8192);

       server.setConnectors(new Connector[]{con1});
	server.setHandler(new OpenEphyraServer()); 
 
	server.start();
	server.join();
}
 
開發者ID:claritylab,項目名稱:lucida,代碼行數:38,代碼來源:OpenEphyraServer.java

示例7: CAPIServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public CAPIServer(CAPIBehavior capiBehavior, CouchbaseBehavior couchbaseBehavior, InetSocketAddress bindAddress, String username, String password, int numVbuckets) {
    super(bindAddress);

    SelectChannelConnector connector0 = new SelectChannelConnector();
    connector0.setHost(bindAddress.getHostName());
    connector0.setPort(bindAddress.getPort());
    connector0.setRequestBufferSize(32 * 1024);

    setConnectors(new Connector[]{ connector0 });

    this.bindAddress = bindAddress;

    ServletContextHandler context = new ServletContextHandler(
            ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    context.setSecurityHandler(basicAuth(username, password, "Couchbase Server Admin / REST"));
    setHandler(context);

    context.addServlet(new ServletHolder(new StatsServlet(couchbaseBehavior, capiBehavior)), "/_stats");
    context.addServlet(new ServletHolder(new ClusterMapServlet(couchbaseBehavior)),
            "/pools/*");
    context.addServlet(new ServletHolder(new BucketMapServlet(
            couchbaseBehavior, numVbuckets)), "/pools/default/buckets/*");
    context.addServlet(
            new ServletHolder(new CAPIServlet(capiBehavior)), "/*");

}
 
開發者ID:lucidworks,項目名稱:solr-couchbase-plugin,代碼行數:28,代碼來源:CAPIServer.java

示例8: createConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private void createConnector(int port) {
    httpConnector = null;
    if (port > 0) {
        SelectChannelConnector connector = new SelectChannelConnector();
        // Listen on a specific network interface if it has been set.
        connector.setHost(getBindInterface());
        connector.setPort(port);
        httpConnector = connector;
    }
}
 
開發者ID:coodeer,項目名稱:g3server,代碼行數:11,代碼來源:HttpBindManager.java

示例9: createConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private Connector createConnector(int port) {
    if (port > 0) {
        SelectChannelConnector connector = new SelectChannelConnector();
        // Listen on a specific network interface if it has been set.
        connector.setHost(getBindInterface());
        connector.setPort(port);
        return connector;
    }
    return null;
}
 
開發者ID:igniterealtime,項目名稱:Openfire-connectionmanager,代碼行數:11,代碼來源:HttpBindManager.java

示例10: createConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private void createConnector(int port) {
    httpConnector = null;
    if (port > 0) {
        SelectChannelConnector connector = new SelectChannelConnector();
        // Listen on a specific network interface if it has been set.
        connector.setHost(getBindInterface());
        connector.setPort(port);
        configureProxiedConnector(connector);
        httpConnector = connector;
    }
}
 
開發者ID:idwanglu2010,項目名稱:openfire,代碼行數:12,代碼來源:HttpBindManager.java

示例11: deployWebApp

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private void deployWebApp() {
    try {
        Server server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
        connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
        connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
        connector.setHost(getHost());
        connector.setPort(getPort());
        if (isHttpsEnabled()) {
            connector.setConfidentialPort(getHttpsPort());
        }
        server.addConnector(connector);

        if (isHttpsEnabled()) {
            SslSocketConnector sslConnector = new SslSocketConnector();
            sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
            sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setHost(getHost());
            sslConnector.setPort(getHttpsPort());
            sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
            sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
            server.addConnector(sslConnector);
        }

        WebAppContext context = new WebAppContext();
        context.setTempDirectory(getJettyDirectory());
        context.setContextPath(getContextPath());
        context.setWar(getWar());

        if (isHttpsEnabled()) {
            ConstraintMapping constraintMapping = new ConstraintMapping();
            Constraint constraint = new Constraint();
            constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
            constraintMapping.setPathSpec("/");
            constraintMapping.setConstraint(constraint);
            ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
            csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
        } 

        server.setHandler(context);
        server.start();

        System.err.println("FutureSonic running on: " + getUrl());
        if (isHttpsEnabled()) {
            System.err.println("                and: " + getHttpsUrl());
        }

    } catch (Throwable x) {
        x.printStackTrace();
        exception = x;
    }
}
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:55,代碼來源:SubsonicDeployer.java

示例12: deployWebApp

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private void deployWebApp() {
       try {
           Server server = new Server();
           SelectChannelConnector connector = new SelectChannelConnector();
           connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
           connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
           connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
           connector.setHost(getHost());
           connector.setPort(getPort());
           if (isHttpsEnabled()) {
               connector.setConfidentialPort(getHttpsPort());
           }
           server.addConnector(connector);

           if (isHttpsEnabled()) {
               SslSocketConnector sslConnector = new SslSocketConnector();
               SslContextFactory sslContextFactory = sslConnector.getSslContextFactory();
               sslContextFactory = sslConnector.getSslContextFactory();
               sslContextFactory.setExcludeCipherSuites(
                       new String[] {
                           "SSL_RSA_WITH_DES_CBC_SHA",
                           "SSL_DHE_RSA_WITH_DES_CBC_SHA",
                           "SSL_DHE_DSS_WITH_DES_CBC_SHA",
                           "SSL_RSA_EXPORT_WITH_RC4_40_MD5",
                           "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
                           "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
                           "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"
                       });
               sslContextFactory.addExcludeProtocols(new String[]{"SSLv3","SSLv2Hello"});
               sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
               sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
               sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
               sslConnector.setHost(getHost());
               sslConnector.setPort(getHttpsPort());
               sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
               sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
               server.addConnector(sslConnector);
           }

           WebAppContext context = new WebAppContext();
           context.setTempDirectory(getJettyDirectory());
           context.setContextPath(getContextPath());
           context.setWar(getWar());
           context.setOverrideDescriptor("/web-jetty.xml");

           if (isHttpsEnabled()) {

               // Allow non-https for streaming and cover art (for Chromecast, UPnP etc)
               ((ConstraintSecurityHandler) context.getSecurityHandler()).setConstraintMappings(new ConstraintMapping[]{
                       createConstraintMapping("/stream", Constraint.DC_NONE),
                       createConstraintMapping("/coverArt.view", Constraint.DC_NONE),
                       createConstraintMapping("/", Constraint.DC_CONFIDENTIAL)
               });
           } 

           server.setHandler(context);
           server.start();

           System.err.println("Madsonic running on: " + getUrl());
           if (isHttpsEnabled()) {
           System.err.println("                and: " + getHttpsUrl());
           }

       } catch (Throwable x) {
           x.printStackTrace();
           exception = x;
       }
   }
 
開發者ID:MadMarty,項目名稱:madsonic-server-5.1,代碼行數:70,代碼來源:MadsonicDeployer.java

示例13: create

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public static Server create(HttpConfiguration configuration) throws Exception {
    Server server = new Server();

    SelectChannelConnector connector = new InstrumentedSelectChannelConnector(configuration.listenAddress.getPort());
    connector.setHost(configuration.listenAddress.getHostName());
    QueuedThreadPool queuedThreadPool = new InstrumentedQueuedThreadPool();
    queuedThreadPool.setMaxThreads(configuration.numHttpWorkers);
    connector.setThreadPool(queuedThreadPool);
    queuedThreadPool.start();

    server.setConnectors(new Connector[]{connector});
    server.setSendServerVersion(true);
    server.setSendDateHeader(true);
    server.setStopAtShutdown(true);
    server.setGracefulShutdown((int) TimeUnit.SECONDS.toMillis(5));

    ServletContextHandler root = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    root.setContextPath("/");

    server.setHandler(new InstrumentedHandler(root));

    // Jersey
    root.addServlet(buildJerseyServlet(), "/*");

    NCSARequestLog requestLog = new NCSARequestLog(configuration.httpLogFileName);
    requestLog.setRetainDays(90);
    requestLog.setAppend(true);
    requestLog.setExtended(true);
    requestLog.setLogTimeZone("GMT");
    requestLog.setLogLatency(true);
    requestLog.setLogDispatch(true);

    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    root.setHandler(requestLogHandler);

    connector.setStatsOn(true);
    StatisticsHandler statisticsHandler = new StatisticsHandler();
    statisticsHandler.setServer(server);

    requestLogHandler.setHandler(statisticsHandler);

    // Setup JMX
    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    server.getContainer().addEventListener(mbContainer);
    mbContainer.addBean(statisticsHandler);

    return server;
}
 
開發者ID:chriskearney,項目名稱:stickypunch,代碼行數:50,代碼來源:JettyService.java

示例14: deployWebApp

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private void deployWebApp() {
    try {
        Server server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
        connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
        connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
        connector.setHost(getHost());
        connector.setPort(getPort());
        if (isHttpsEnabled()) {
            connector.setConfidentialPort(getHttpsPort());
        }
        server.addConnector(connector);

        if (isHttpsEnabled()) {
            SslSocketConnector sslConnector = new SslSocketConnector();
            sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
            sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
            sslConnector.setHost(getHost());
            sslConnector.setPort(getHttpsPort());
            sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
            sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
            server.addConnector(sslConnector);
        }

        WebAppContext context = new WebAppContext();
        context.setTempDirectory(getJettyDirectory());
        context.setContextPath(getContextPath());
        context.setWar(getWar());

        if (isHttpsEnabled()) {
            ConstraintMapping constraintMapping = new ConstraintMapping();
            Constraint constraint = new Constraint();
            constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
            constraintMapping.setPathSpec("/");
            constraintMapping.setConstraint(constraint);
            ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
            csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
        } 

        server.setHandler(context);
        server.start();

        System.err.println("Madsonic running on: " + getUrl());
        if (isHttpsEnabled()) {
            System.err.println("                and: " + getHttpsUrl());
        }

    } catch (Throwable x) {
        x.printStackTrace();
        exception = x;
    }
}
 
開發者ID:MadMarty,項目名稱:madsonic-server-5.0,代碼行數:55,代碼來源:SubsonicDeployer.java

示例15: createConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private SelectChannelConnector createConnector() {
    SelectChannelConnector _connector = new SelectChannelConnector();
    _connector.setPort(port);
    _connector.setHost(hostname);
    return _connector;
}
 
開發者ID:mattprovis,項目名稱:uitest,代碼行數:7,代碼來源:WebServer.java


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