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


Java Connector.getLocalPort方法代碼示例

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


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

示例1: removeConnector

import org.eclipse.jetty.server.Connector; //導入方法依賴的package包/類
synchronized public void removeConnector(String host, int port) {
    Connector[] connectors = server.getConnectors();
    if (connectors == null)
        return;

    for (Connector connector : connectors) {
        //Fix getPort()
        if (connector.getHost().equals(host) && connector.getLocalPort() == port) {
            if (connector.isStarted() || connector.isStarting()) {
                try {
                    connector.stop();
                } catch (Exception ex) {
                    log.severe("Couldn't stop connector: " + connector + " " + ex);
                    throw new RuntimeException(ex);
                }
            }
            server.removeConnector(connector);
            if (connectors.length == 1) {
                log.info("No more connectors, stopping Jetty server");
                stopIfRunning();
            }
            break;
        }
    }
}
 
開發者ID:kevinshine,項目名稱:BeyondUPnP,代碼行數:26,代碼來源:AndroidJettyServletContainer.java

示例2: getBaseUrl

import org.eclipse.jetty.server.Connector; //導入方法依賴的package包/類
/**
 * Returns a base URL consisting of the protocal, host, and port for a 
 * Connector in use by the Jetty Server contained in this runner.
 */
public URL getBaseUrl() {
  String protocol = null;
  try {
    Connector[] conns = server.getConnectors();
    if (0 == conns.length) {
      throw new IllegalStateException("Jetty Server has no Connectors");
    }
    Connector c = conns[0];
    if (c.getLocalPort() < 0) {
      throw new IllegalStateException("Jetty Connector is not open: " + 
                                      c.getLocalPort());
    }
    protocol = (c instanceof SslConnector) ? "https" : "http";
    return new URL(protocol, c.getHost(), c.getLocalPort(), context);

  } catch (MalformedURLException e) {
    throw new  IllegalStateException
      ("Java could not make sense of protocol: " + protocol, e);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:25,代碼來源:JettySolrRunner.java

示例3: initialize

import org.eclipse.jetty.server.Connector; //導入方法依賴的package包/類
@Before
public void initialize()
    throws Exception
{
    server = new Server( 0 );
    createContext( server, new File( "src/test/" ) );

    this.server.start();
    Connector connector = this.server.getConnectors()[0];
    this.port = connector.getLocalPort();
    log.info( "start server on port {}", this.port );
    nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:14,代碼來源:DownloadRemoteIndexTaskTest.java

示例4: findLocalHttpPort

import org.eclipse.jetty.server.Connector; //導入方法依賴的package包/類
/**
 * Finds the port the specified server is listening for HTTP connections on.
 *
 * @param webServer started web server
 * @return HTTP port, or -1 if no HTTP port was found
 */
public static int findLocalHttpPort(Server webServer) {
    for (Connector connector : webServer.getConnectors()) {
        if (!(connector instanceof SslSocketConnector)) {
            return connector.getLocalPort();
        }
    }

    return -1;
}
 
開發者ID:wxyzZ,項目名稱:little_mitm,代碼行數:16,代碼來源:TestUtils.java

示例5: findLocalHttpsPort

import org.eclipse.jetty.server.Connector; //導入方法依賴的package包/類
/**
 * Finds the port the specified server is listening for HTTPS connections on.
 *
 * @param webServer started web server
 * @return HTTP port, or -1 if no HTTPS port was found
 */
public static int findLocalHttpsPort(Server webServer) {
    for (Connector connector : webServer.getConnectors()) {
        if (connector instanceof SslSocketConnector) {
            return connector.getLocalPort();
        }
    }

    return -1;
}
 
開發者ID:wxyzZ,項目名稱:little_mitm,代碼行數:16,代碼來源:TestUtils.java

示例6: 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

示例7: getPort

import org.eclipse.jetty.server.Connector; //導入方法依賴的package包/類
public int getPort() {
    Connector connector = server.getConnectors()[0];
    return connector.getLocalPort() <= 0 ? connector.getPort() : connector.getLocalPort();
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:5,代碼來源:SimpleMockServer.java


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