Java 类io.dropwizard.jetty.ConnectorFactory 实例源码

项目:stroom-stats    文件:ServiceDiscoveryRegistrar.java   
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;
}
项目:emodb    文件:SelfHostAndPortModule.java   
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);
    }
}
项目:emodb    文件:ScanUploadTest.java   
private static void updatePortsToAvoidCollision(Collection<ConnectorFactory> connectorFactoryCollection) {
    for (ConnectorFactory connectorFactory : connectorFactoryCollection) {
        if (connectorFactory instanceof HttpConnectorFactory) {
            HttpConnectorFactory httpConnectorFactory = (HttpConnectorFactory)connectorFactory;
            httpConnectorFactory.setPort(httpConnectorFactory.getPort() + 100);
        }
    }
}
项目:emodb    文件:BaseRoleConnectHelper.java   
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);
}
项目:emodb    文件:BaseRoleConnectHelper.java   
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);
}
项目:emodb    文件:BaseRoleConnectHelper.java   
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;
}
项目:emodb    文件:SelfHostAndPortModule.java   
@Provides @Singleton @SelfHostAndPort
public HostAndPort provideSelfHostAndPort(ServerFactory serverFactory) {
    // Our method for obtaining connector factories from the server factory varies depending on the latter's type
    List<ConnectorFactory> appConnectorFactories;
    if (serverFactory instanceof DefaultServerFactory) {
        appConnectorFactories = ((DefaultServerFactory) serverFactory).getApplicationConnectors();
    } else if (serverFactory instanceof SimpleServerFactory) {
        appConnectorFactories = Collections.singletonList(((SimpleServerFactory) serverFactory).getConnector());
    } else {
        throw new IllegalStateException("Encountered an unexpected ServerFactory type");
    }

    return getHostAndPortFromConnectorFactories(appConnectorFactories);
}
项目:emodb    文件:SelfHostAndPortModule.java   
@Provides @Singleton @SelfAdminHostAndPort
public HostAndPort provideSelfAdminHostAndPort(ServerFactory serverFactory) {
    // Our method for obtaining connector factories from the server factory varies depending on the latter's type
    List<ConnectorFactory> adminConnectorFactories;
    if (serverFactory instanceof DefaultServerFactory) {
        adminConnectorFactories = ((DefaultServerFactory) serverFactory).getAdminConnectors();
    } else if (serverFactory instanceof SimpleServerFactory) {
        adminConnectorFactories = Collections.singletonList(((SimpleServerFactory) serverFactory).getConnector());
    } else {
        throw new IllegalStateException("Encountered an unexpected ServerFactory type");
    }

    return getHostAndPortFromConnectorFactories(adminConnectorFactories);
}
项目:dropwizard-helix    文件:HelixServiceDiscoveryBundle.java   
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");
}
项目:oauth2-dropwizard    文件:RestClientBuilder.java   
public RestClientBuilder setupSSL(ApiServerConfig cfg) {
    SSLContext sslContext;
    ConnectorFactory factory = cfg.getClientConfig();

    if (factory == null || !(factory instanceof HttpsConnectorFactory))
        return this;

    HttpsConnectorFactory hcf = (HttpsConnectorFactory) factory;

    if (hcf.getKeyStorePath() != null) {
        keyStore = hcf.getKeyStorePath();
        keyStorePassword = hcf.getKeyStorePassword();
        trustStore = hcf.getTrustStorePath();
        trustStorePassword = hcf.getTrustStorePassword();

        sslContext = getSSLContext();
    } else {
        SslConfigurator sslConfig = SslConfigurator.newInstance();
        sslContext = sslConfig.createSSLContext();
    }

    SSLConnectionSocketFactory sslConnectionSocketFactory = hcf.isValidateCerts() ?
            new SSLConnectionSocketFactory(sslContext) :
            new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

    Registry<ConnectionSocketFactory> registry =
            RegistryBuilder.<ConnectionSocketFactory>create().register("https", sslConnectionSocketFactory).build();
    using(registry);

    return this;
}
项目:soabase    文件:SoaBundle.java   
private static HostAndPort portFromConnectorFactories(List<ConnectorFactory> applicationConnectors)
{
    if ( applicationConnectors.size() > 0 )
    {
        return portFromConnectorFactory(applicationConnectors.get(0));
    }
    return defaultHostAndPort;
}
项目:soabase    文件:SoaBundle.java   
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;
}
项目:log-dropwizard-eureka-mongo-sample    文件:DropwizardServerHelpers.java   
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);
}
项目:log-dropwizard-eureka-mongo-sample    文件:DropwizardServerHelpers.java   
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);
}
项目:log-dropwizard-eureka-mongo-sample    文件:DropwizardServerHelpers.java   
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);
}
项目:FeedExpander    文件:ExpanderApplication.java   
private @Nonnull HttpConnectorFactory getDefaultServerFactory(ServerFactory serverFactory) {
    for (ConnectorFactory connector : ((DefaultServerFactory)serverFactory).getApplicationConnectors()) {
        if (connector.getClass().isAssignableFrom(HttpConnectorFactory.class)) {
            return (HttpConnectorFactory) connector;
        }
    }
    throw new IllegalArgumentException(String.format("Failed to find any server ConnectorFactory in serverFactory '%s'",
            serverFactory.getClass().getName()));
}
项目:dropwizard-orient-server    文件:AutoSslConfigurator.java   
private void checkAndConfigure(final ConnectorFactory connector) {
    if (connector instanceof HttpsConnectorFactory) {
        final List<OServerSocketFactoryConfiguration> sockets = conf.network.sockets;
        // no defined sockets already mean no ssl configured, otherwise look listeners
        // (sockets may be defined but not actually used)
        if (sockets != null && !sockets.isEmpty() && isSslAlreadyDefined()) {
            logger.warn("Orient auto ssl configuration not performed because ssl socket is defined "
                    + "manually and used in one of the listeners (see network.listeners section)");
        } else {
            applySsl((HttpsConnectorFactory) connector);
        }
    }
}
项目:oauth2-dropwizard    文件:ApiServerConfig.java   
public ConnectorFactory getClientConfig() {
    return clientConfig;
}