當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。