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


Java Connector.setPort方法代码示例

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


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

示例1: afterPropertiesSet

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
public void afterPropertiesSet() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();
    Integer port = getPort();
    if (port != null && port > 0) {
        Connector[] connectors = server.getConnectors();
        for (Connector connector : connectors) {
            connector.setPort(port);
        }
    }

    Handler handler = server.getHandler();
    if (handler != null && handler instanceof ServletContextHandler) {
        ServletContextHandler servletHandler = (ServletContextHandler) handler;
        servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", htdocsDir);
    }

    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:24,代码来源:JettyEmbedServer.java

示例2: main

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
    XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
    Server server = (Server) configuration.configure();
    int port = 8081;
    Connector[] connectors = server.getConnectors();
    for (Connector connector : connectors) {
        connector.setPort(port);
    }

    Handler handler = server.getHandler();
    if (handler != null && handler instanceof ServletContextHandler) {
        ServletContextHandler servletHandler = (ServletContextHandler) handler;
        servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
    }

    server.start();
    server.join();
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:JettyEmbedIntegration.java

示例3: start

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
/**
 * 启动jetty
 */
private static void start() throws Exception {
  long bg = System.currentTimeMillis();
  Server server = new Server();
  Connector connector = new SelectChannelConnector();
  connector.setPort(PORT);
  server.setConnectors(new Connector[] {connector});

  WebAppContext webAppContext = new WebAppContext("src/main/webapp", "/");
  webAppContext.setDescriptor("src/main/webapp/WEB-INF/web.xml");
  webAppContext.setDisplayName("multilanguage");
  WebAppClassLoader classLoader = new WebAppClassLoader(webAppContext);
  webAppContext.setClassLoader(classLoader);
  webAppContext.setParentLoaderPriority(true);
  server.setHandler(webAppContext);
  System.out.println("ContextPath: " + webAppContext.getContextPath() + ";  Descriptor: "
      + webAppContext.getDescriptor());

  server.start();

  long time = System.currentTimeMillis() - bg;
  System.out.println("Jetty started in " + time + "ms");
}
 
开发者ID:xionghuiCoder,项目名称:multilanguage-interface-demo,代码行数:26,代码来源:JettyStart.java

示例4: start

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
public void start() throws Exception {
  server = new Server();
  Connector connector = new SelectChannelConnector();
  connector.setPort(port);
  server.setConnectors(new Connector[]{connector});

  RequestLogHandler requestLogHandler = new RequestLogHandler();
  configureRequestLogImpl();
  requestLogHandler.setRequestLog(requestLogImpl);

  HandlerList handlers = new HandlerList();
  handlers.addHandler(requestLogHandler);
  handlers.addHandler(getRequestHandler());

  server.setHandler(handlers);
  server.start();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:JettyFixtureBase.java

示例5: startHttp

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
protected void startHttp() throws Exception {
    _server = new Server();

//    QueuedThreadPool p = new QueuedThreadPool();
//    p.setName("jetty-h2o");
//    p.setMinThreads(3);
//    p.setMaxThreads(50);
//    p.setMaxIdleTimeMs(3000);
//    _server.setThreadPool(p);

    Connector connector=new SocketConnector();
    if (_ip != null) {
      connector.setHost(_ip);
    }
    connector.setPort(_port);

    createServer(connector);
  }
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:19,代码来源:JettyHTTPD.java

示例6: startServer

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
/**
 * Method for starting the Jetty server with the ATS Agent webapp.
 * @param port the port on which to start the server.
 * @return the started server.
 * @throws IOException
 */
private static Server startServer() throws IOException {

    addAppender();

    final int agentPort = getAgentDefaultPort();
    log.info("Starting ATS agent at port: " + agentPort);

    final String jettyHome = getJettyHome();

    logSystemInformation(jettyHome);

    // start the server
    Connector connector = new SelectChannelConnector();
    connector.setPort(agentPort);

    Server server = new Server();
    server.setConnectors(new Connector[]{ connector });

    WebAppContext webApp = new WebAppContext();
    webApp.setContextPath("/agentapp");
    webApp.setWar(jettyHome + "/webapp/agentapp.war");

    server.setHandler(webApp);
    server.setStopAtShutdown(true);

    setExtraClasspath(webApp, jettyHome);

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

    log.info("ATS agent started");
    return server;
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:44,代码来源:ContainerStarter.java

示例7: start

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
public void start() throws Exception
{
  server = new Server();
  Connector connector = new SelectChannelConnector();
  connector.setPort(port);
  server.addConnector(connector);

    // Setup the basic application "context" for this application at "/"
  // This is also known as the handler tree (in jetty speak)
  ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
  contextHandler.setContextPath("/");
  server.setHandler(contextHandler);
  WebSocketServlet webSocketServlet = new WebSocketServlet()
  {
    @Override
    public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol)
    {
      return websocket;
    }
  };

  contextHandler.addServlet(new ServletHolder(webSocketServlet), "/pubsub");
  server.start();
  if (port == 0) {
    port = server.getConnectors()[0].getLocalPort();
  }
}
 
开发者ID:apache,项目名称:apex-core,代码行数:28,代码来源:StramTestSupport.java

示例8: createServer

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
/**
 * Creates a new instance of {@link Server} with the given port,
 * request response buffer size and response buffer size.
 * @param serverProperties the properties required to configure the server
 * @return the instance
 */
public Server createServer(final ServerProperties serverProperties) {
    Server server = new Server();
    Connector connector = new SelectChannelConnector();
    connector.setPort(serverProperties.getProxyPort());
    connector.setRequestBufferSize(serverProperties.getRequestBufferSize());
    connector.setResponseBufferSize(serverProperties.getResponseBufferSize());
    server.setConnectors(new Connector[]{connector});
    server.setGracefulShutdown(SHUTDOWN_TIMEOUT);
    server.setStopAtShutdown(true);
    return server;
}
 
开发者ID:epam,项目名称:Wilma,代码行数:18,代码来源:ServerFactory.java

示例9: setUp

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
/**
 * Set up server with handler
 *
 * @param handler
 * @return port
 * @throws Exception
 */
public static String setUp(final Handler handler) throws Exception {
  server = new Server();
  if (handler != null)
    server.setHandler(handler);
  Connector connector = new SelectChannelConnector();
  connector.setPort(0);
  server.setConnectors(new Connector[] { connector });
  server.start();

  proxy = new Server();
  Connector proxyConnector = new SelectChannelConnector();
  proxyConnector.setPort(0);
  proxy.setConnectors(new Connector[] { proxyConnector });

  ServletHandler proxyHandler = new ServletHandler();

  RequestHandler proxyCountingHandler = new RequestHandler() {

    @Override
    public void handle(Request request, HttpServletResponse response) {
      proxyHitCount.incrementAndGet();
      String auth = request.getHeader("Proxy-Authorization");
      auth = auth.substring(auth.indexOf(' ') + 1);
      try {
        auth = B64Code.decode(auth, CHARSET_UTF8);
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
      int colon = auth.indexOf(':');
      proxyUser.set(auth.substring(0, colon));
      proxyPassword.set(auth.substring(colon + 1));
      request.setHandled(false);
    }
  };

  HandlerList handlerList = new HandlerList();
  handlerList.addHandler(proxyCountingHandler);
  handlerList.addHandler(proxyHandler);
  proxy.setHandler(handlerList);

  ServletHolder proxyHolder = proxyHandler.addServletWithMapping("org.eclipse.jetty.servlets.ProxyServlet", "/");
  proxyHolder.setAsyncSupported(true);

  proxy.start();

  proxyPort = proxyConnector.getLocalPort();

  return "http://localhost:" + connector.getLocalPort();
}
 
开发者ID:junicorn,项目名称:NiuBi,代码行数:57,代码来源:ServerTestCase.java

示例10: onSetUp

import org.eclipse.jetty.server.Connector; //导入方法依赖的package包/类
/**
    * Initializes things your test might need
    * <ul>
    * <li>Creates a dataDir in the "java.io.tmpdir"</li>
    * <li>initializes the TestHarness h using this data directory, and
    * getSchemaPath()</li>
    * <li>initializes the LocalRequestFactory lrf using sensible defaults.</li>
    * </ul>
    */
   @SuppressWarnings("deprecation")
   @Override
   public void onSetUp() throws Exception {
super.onSetUp();


if (!serverStarted && isMustStartServlet()) {
    String separator = System.getProperty("file.separator");
    String solrDataDirPropertyName = "solr.data.dir";
    String solrDataDirValue = "./target" + separator + "classes" + separator
	    + "data";
    if (System.getProperty(solrDataDirPropertyName) == null
	    || !System.getProperty(solrDataDirPropertyName).equals(solrDataDirValue)) {
	logger.info("change system property from "
		+ System.getProperty(solrDataDirPropertyName) + " to " + solrDataDirValue);
	System.setProperty(solrDataDirPropertyName, solrDataDirValue);

	logger.info("System property " + solrDataDirPropertyName + " is now : "
		+ System.getProperty(solrDataDirPropertyName));
    } else {
	logger.info(solrDataDirPropertyName + "=" + System.getProperty("file.encoding"));
    }
    
    String jetty_default=new java.io.File("./start.jar").exists()?".":"./src/dist/";;
    String jetty_home = System.getProperty("jetty.home",jetty_default);

    server = new Server();
    int port = generateRandomPort();
    //force port
    //int port=54611;
    Connector connector=new SelectChannelConnector();
    connector.setPort(Integer.getInteger("jetty.port",port).intValue());
    System.out.println("starting solr on port "+port);
    server.setConnectors(new Connector[]{connector});
    
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath(FULLTEXT_SEARCH_ENGINE_CONTEXT);
    webapp.setWar(jetty_home+"webapps/solr.war");
    webapp.setDefaultsDescriptor(jetty_home+"etc/webdefault.xml");
    
    server.setHandler(webapp);
    server.setStopAtShutdown(true);
    logger.info("will start jetty on "+port);
    serverStarted = true;
    server.start();
    fulltextSearchUrlBinded=("http://localhost:"+port
    + FULLTEXT_SEARCH_ENGINE_CONTEXT);

    this.solrClient.bindToUrl(fulltextSearchUrlBinded);
    // set log to off
    // comment this line to see solr logs
    this.solrClient.setSolRLogLevel(Level.OFF);
}
if (isMustStartServlet()) {
    this.solRSynchroniser.deleteAll();
}

   }
 
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:68,代码来源:AbstractIntegrationHttpSolrTestCase.java


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