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


Java HttpConnectorFactory类代码示例

本文整理汇总了Java中io.dropwizard.jetty.HttpConnectorFactory的典型用法代码示例。如果您正苦于以下问题:Java HttpConnectorFactory类的具体用法?Java HttpConnectorFactory怎么用?Java HttpConnectorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getPort

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
private static int getPort(Config config) {
    int port = 0;
    DefaultServerFactory serverFactory = (DefaultServerFactory) config.getServerFactory();
    List<ConnectorFactory> connectorFactories = serverFactory.getApplicationConnectors();
    if (Preconditions.checkNotNull(connectorFactories).size() != 1) {
        throw new RuntimeException(
                String.format("Unexpected number of connectorFactories %s, check 'applicationConnectors' in the YAML config",
                        connectorFactories.size()));
    }

    HttpConnectorFactory connector = (HttpConnectorFactory) connectorFactories.get(0);
    if (connector.getClass().isAssignableFrom(HttpConnectorFactory.class)) {
        port = connector.getPort();
    }
    return port;
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:17,代码来源:ServiceDiscoveryRegistrar.java

示例2: getHostAndPortFromConnectorFactories

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
private HostAndPort getHostAndPortFromConnectorFactories(List<ConnectorFactory> connectors) {
    // find the first connector that matches and return it host/port information (in practice there should
    // be one, and just one, match)
    try {
        HttpConnectorFactory httpConnectorFactory = (HttpConnectorFactory) Iterables.find(connectors, Predicates.instanceOf(HttpConnectorFactory.class));

        String host = httpConnectorFactory.getBindHost();
        if (host == null) {
            host = getLocalHost().getHostAddress();
        }
        int port = httpConnectorFactory.getPort();
        return HostAndPort.fromParts(host, port);
    } catch (NoSuchElementException ex) {
        throw new IllegalStateException("Did not find a valid HttpConnector for the server", ex);
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:17,代码来源:SelfHostAndPortModule.java

示例3: providesAgentMetadata

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
@Provides
@Singleton
public BaragonAgentMetadata providesAgentMetadata(BaragonAgentConfiguration config) throws Exception {
  final SimpleServerFactory simpleServerFactory = (SimpleServerFactory) config.getServerFactory();
  final HttpConnectorFactory httpFactory = (HttpConnectorFactory) simpleServerFactory.getConnector();

  final int httpPort = httpFactory.getPort();
  final String hostname = config.getHostname().or(JavaUtils.getHostAddress());
  final Optional<String> domain = config.getLoadBalancerConfiguration().getDomain();
  final String appRoot = simpleServerFactory.getApplicationContextPath();

  final String baseAgentUri = String.format(config.getBaseUrlTemplate(), hostname, httpPort, appRoot);
  final String agentId = String.format("%s:%s", hostname, httpPort);

  return new BaragonAgentMetadata(baseAgentUri, agentId, domain, BaragonAgentEc2Metadata.fromEnvironment(), config.getExtraAgentData(), true);
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:17,代码来源:BaragonAgentServiceModule.java

示例4: run

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
@Override
public void run(SimpleFormConfiguration configuration, Environment environment) throws Exception {

    environment.jersey().setUrlPattern("/api/*");
    environment.jersey().register(new SimpleFormRest());

    /*
        very ugly code, but does not seem that Dropwizard gives you any alternative :(
     */
    HttpConnectorFactory applicationConnector = ((HttpConnectorFactory)
            ((DefaultServerFactory) configuration.getServerFactory())
                    .getApplicationConnectors().get(0));
    applicationConnector.setPort(port);

    ((HttpConnectorFactory) ((DefaultServerFactory) configuration.getServerFactory())
            .getAdminConnectors().get(0)).setPort(0);

    environment.lifecycle().addServerLifecycleListener(server -> jettyServer = server);


    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("0.0.1");
    beanConfig.setSchemes(new String[]{"http"});
    //beanConfig.setHost("localhost:8080");
    beanConfig.setBasePath("/api");
    beanConfig.setResourcePackage("com.foo.rest.examples.dw.simpleform");
    beanConfig.setScan(true);
    environment.jersey().register(new io.swagger.jaxrs.listing.ApiListingResource());
    environment.jersey().register(new io.swagger.jaxrs.listing.SwaggerSerializers());
}
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:31,代码来源:SimpleFormApplication.java

示例5: run

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
@Override
public void run(PIConfiguration configuration, Environment environment) throws Exception {

    environment.jersey().setUrlPattern("/api/*");
    environment.jersey().register(new PositiveIntegerRest());

    /*
        very ugly code, but does not seem that Dropwizard gives you any alternative :(
     */
    HttpConnectorFactory applicationConnector = ((HttpConnectorFactory)
            ((DefaultServerFactory) configuration.getServerFactory())
                    .getApplicationConnectors().get(0));
    applicationConnector.setPort(port);

    ((HttpConnectorFactory) ((DefaultServerFactory) configuration.getServerFactory())
            .getAdminConnectors().get(0)).setPort(0);

    environment.lifecycle().addServerLifecycleListener(server -> jettyServer = server);


    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("0.0.1");
    beanConfig.setSchemes(new String[]{"http"});
    //beanConfig.setHost("localhost:8080");
    beanConfig.setBasePath("/api");
    beanConfig.setResourcePackage("com.foo.rest.examples.dw.positiveinteger");
    beanConfig.setScan(true);
    environment.jersey().register(new io.swagger.jaxrs.listing.ApiListingResource());
    environment.jersey().register(new io.swagger.jaxrs.listing.SwaggerSerializers());
}
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:31,代码来源:PIApplication.java

示例6: SingularityHostAndPortProvider

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
@Inject
SingularityHostAndPortProvider(final SingularityConfiguration configuration, @Named(HOST_NAME_PROPERTY) String hostname) {
  checkNotNull(configuration, "configuration is null");
  this.hostname = configuration.getHostname().or(hostname);

  SimpleServerFactory simpleServerFactory = (SimpleServerFactory) configuration.getServerFactory();
  HttpConnectorFactory httpFactory = (HttpConnectorFactory) simpleServerFactory.getConnector();

  this.httpPort = httpFactory.getPort();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:11,代码来源:SingularityMainModule.java

示例7: updatePortsToAvoidCollision

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
private static void updatePortsToAvoidCollision(Collection<ConnectorFactory> connectorFactoryCollection) {
    for (ConnectorFactory connectorFactory : connectorFactoryCollection) {
        if (connectorFactory instanceof HttpConnectorFactory) {
            HttpConnectorFactory httpConnectorFactory = (HttpConnectorFactory)connectorFactory;
            httpConnectorFactory.setPort(httpConnectorFactory.getPort() + 100);
        }
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:9,代码来源:ScanUploadTest.java

示例8: getAdminBaseURI

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
protected String getAdminBaseURI () {
    int httpPort = 0;
    for(ConnectorFactory connector: ((DefaultServerFactory)_config.getServerFactory()).getAdminConnectors()) {
        if (connector.getClass().isAssignableFrom(HttpConnectorFactory.class)) {
            httpPort = ((HttpConnectorFactory) connector).getPort();
            break;
        }
    }

    return format("http://localhost:%d", httpPort);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:12,代码来源:BaseRoleConnectHelper.java

示例9: getServiceBaseURI

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
protected String getServiceBaseURI () {
    int port = 0;
    for(ConnectorFactory connector: ((DefaultServerFactory)_config.getServerFactory()).getApplicationConnectors()) {
        if (connector.getClass().isAssignableFrom(HttpConnectorFactory.class)) {
            port = ((HttpConnectorFactory) connector).getPort();
            break;
        }
    }

    return format("http://localhost:%d", port);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:12,代码来源:BaseRoleConnectHelper.java

示例10: getServiceBasePort

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
protected int getServiceBasePort () {
    int port = 0;
    for(ConnectorFactory connector: ((DefaultServerFactory)_config.getServerFactory()).getApplicationConnectors()) {
        if (connector.getClass().isAssignableFrom(HttpConnectorFactory.class)) {
            port = ((HttpConnectorFactory) connector).getPort();
            break;
        }
    }

    return port;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:12,代码来源:BaseRoleConnectHelper.java

示例11: getPort

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
private static int getPort(Configuration config) {
  DefaultServerFactory serverFactory = (DefaultServerFactory) config.getServerFactory();
  ConnectorFactory connectorFactory = serverFactory.getApplicationConnectors().get(0);

  if (connectorFactory instanceof HttpsConnectorFactory) {
    return ((HttpsConnectorFactory) connectorFactory).getPort();
  } else if (connectorFactory instanceof HttpConnectorFactory) {
    return ((HttpConnectorFactory) connectorFactory).getPort();
  }

  throw new IllegalArgumentException("Could not extract main application port from configuration");
}
 
开发者ID:brandtg,项目名称:dropwizard-helix,代码行数:13,代码来源:HelixServiceDiscoveryBundle.java

示例12: portFromConnectorFactory

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
private static HostAndPort portFromConnectorFactory(ConnectorFactory connectorFactory)
{
    if ( (connectorFactory != null) && HttpConnectorFactory.class.isAssignableFrom(connectorFactory.getClass()) )
    {
        HttpConnectorFactory factory = (HttpConnectorFactory)connectorFactory;
        String bindHost = MoreObjects.firstNonNull(factory.getBindHost(), "localhost");
        return HostAndPort.fromParts(bindHost, factory.getPort());
    }
    return defaultHostAndPort;
}
 
开发者ID:soabase,项目名称:soabase,代码行数:11,代码来源:SoaBundle.java

示例13: getPort

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
public static Integer getPort(ConnectorFactory connectorFactory) {
   if(connectorFactory instanceof HttpConnectorFactory) {
      return ((HttpConnectorFactory)connectorFactory).getPort();
   }
   if(connectorFactory instanceof HttpsConnectorFactory) {
      return ((HttpsConnectorFactory)connectorFactory).getPort();
   }
   throw new RuntimeException("Unable to infer Port of " + connectorFactory);
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:10,代码来源:DropwizardServerHelpers.java

示例14: getConnectorFactoy

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
private @Nonnull HttpConnectorFactory getConnectorFactoy(ServerFactory serverFactory) {
	if(serverFactory instanceof DefaultServerFactory) {
		return getDefaultServerFactory(serverFactory);
	} else if(serverFactory instanceof SimpleServerFactory) {
		return getSimpleServerFactory(serverFactory);
	}
	throw new IllegalArgumentException(
			String.format("Unknonw ServerFactory instance '%s'", serverFactory.getClass().getName()));
}
 
开发者ID:rrauschenbach,项目名称:FeedExpander,代码行数:10,代码来源:ExpanderApplication.java

示例15: getSimpleServerFactory

import io.dropwizard.jetty.HttpConnectorFactory; //导入依赖的package包/类
private @Nonnull HttpConnectorFactory getSimpleServerFactory(ServerFactory serverFactory) {
	HttpConnectorFactory connector = (HttpConnectorFactory) ((SimpleServerFactory)serverFactory).getConnector();
	if (connector.getClass().isAssignableFrom(HttpConnectorFactory.class)) {
	    return connector;
	}
	throw new IllegalArgumentException(String.format("Failed to find any server ConnectorFactory in serverFactory '%s'",
			serverFactory.getClass().getName()));		
}
 
开发者ID:rrauschenbach,项目名称:FeedExpander,代码行数:9,代码来源:ExpanderApplication.java


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