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


Java ServerConnector.getLocalPort方法代码示例

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


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

示例1: extractTableRowForDefaultServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
private static List<ApplicationUrlsGenerator> extractTableRowForDefaultServer(Environment environment, ServerConnector connector) {
    String protocol = connector.getDefaultProtocol();
    int port = connector.getLocalPort();

    if ("admin".equals(connector.getName())) {
        String adminContextPath = environment.getAdminContext().getContextPath();

        return ImmutableList.of(
            new ApplicationUrlsGenerator(ADMIN_URL_TYPE, isHttps(protocol), port, adminContextPath),
            new ApplicationUrlsGenerator(HEALTHCHECK_URL_TYPE, isHttps(protocol), port, adminContextPath)
        );
    }

    return ImmutableList.of(
        new ApplicationUrlsGenerator(APPLICATION_URL_TYPE, isHttps(protocol), port, environment.getApplicationContext().getContextPath())
    );
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:18,代码来源:UsefulApplicationUrlsTableFormatter.java

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

示例3: createRpcServerMetadata

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
private RpcMetadataResponse createRpcServerMetadata(ServerConnector connector) throws
    UnknownHostException {
  String host = connector.getHost();
  if (null == host) {
    // "null" means binding to all interfaces, we need to pick one so the client gets a real
    // address and not "0.0.0.0" or similar.
    host = InetAddress.getLocalHost().getHostName();
  }

  final int port = connector.getLocalPort();

  return new RpcMetadataResponse(
      String.format(Locale.ROOT, "%s:%d", host, port));
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:15,代码来源:HttpServer.java

示例4: setUp

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
	registry = spy(new MetricRegistry());
	client = new HttpClient();
	server = new Server();
	when(registry.getNanos()).thenAnswer(i -> now += 123456789);
	ServerConnector connector = new ServerConnector(server);
	InstrumentedHandler handler = new InstrumentedHandler(registry);
	handler.setHandler(new HelloWorldHandler());
	server.addConnector(connector);
	server.setHandler(handler);
	server.start();
	client.start();
	url = "http://localhost:" + connector.getLocalPort();
}
 
开发者ID:mevdschee,项目名称:tqdev-metrics,代码行数:16,代码来源:InstrumentedHandlerTest.java

示例5: setupServer

import org.eclipse.jetty.server.ServerConnector; //导入方法依赖的package包/类
@BeforeClass
    public static void setupServer() throws Exception {
        // start a local HTTP proxy using Jetty server
        server = new Server();

/*
        final SSLContextParameters contextParameters = new SSLContextParameters();
        final SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setSslContext(contextParameters.createSSLContext());
        ServerConnector connector = new ServerConnector(server, sslContextFactory);
*/
        ServerConnector connector = new ServerConnector(server);

        connector.setHost(HTTP_PROXY_HOST);
        server.addConnector(connector);

        final String authenticationString = "Basic "
            + B64Code.encode(HTTP_PROXY_USER_NAME + ":" + HTTP_PROXY_PASSWORD, StringUtil.__ISO_8859_1);

        ConnectHandler connectHandler = new ConnectHandler() {
            @Override
            protected boolean handleAuthentication(HttpServletRequest request, HttpServletResponse response, String address) {
                // validate proxy-authentication header
                final String header = request.getHeader(PROXY_AUTHORIZATION.toString());
                if (!authenticationString.equals(header)) {
                    LOG.warn("Missing header " + PROXY_AUTHORIZATION);
                    // ask for authentication header
                    response.setHeader(PROXY_AUTHENTICATE.toString(), String.format("Basic realm=\"%s\"", HTTP_PROXY_REALM));
                    return false;
                }
                LOG.info("Request contains required header " + PROXY_AUTHORIZATION);
                return true;
            }
        };
        server.setHandler(connectHandler);

        LOG.info("Starting proxy server...");
        server.start();

        httpProxyPort = connector.getLocalPort();
        LOG.info("Started proxy server on port {}", httpProxyPort);
    }
 
开发者ID:HydAu,项目名称:Camel,代码行数:43,代码来源:HttpProxyMojoIntegrationTest.java


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