本文整理汇总了Java中io.dropwizard.server.SimpleServerFactory类的典型用法代码示例。如果您正苦于以下问题:Java SimpleServerFactory类的具体用法?Java SimpleServerFactory怎么用?Java SimpleServerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleServerFactory类属于io.dropwizard.server包,在下文中一共展示了SimpleServerFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: providesAgentMetadata
import io.dropwizard.server.SimpleServerFactory; //导入依赖的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);
}
示例2: SingularityHostAndPortProvider
import io.dropwizard.server.SimpleServerFactory; //导入依赖的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();
}
示例3: updatePortsToAvoidCollision
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
private static void updatePortsToAvoidCollision(ServerFactory serverFactory) {
if (serverFactory instanceof DefaultServerFactory) {
DefaultServerFactory defaultServerFactory = (DefaultServerFactory)serverFactory;
updatePortsToAvoidCollision(defaultServerFactory.getApplicationConnectors());
updatePortsToAvoidCollision(defaultServerFactory.getAdminConnectors());
} else if (serverFactory instanceof SimpleServerFactory) {
SimpleServerFactory simpleServerFactory = (SimpleServerFactory)serverFactory;
updatePortsToAvoidCollision(Collections.singleton(simpleServerFactory.getConnector()));
} else {
throw new IllegalStateException("Encountered an unexpected ServerFactory type");
}
}
示例4: provideSelfHostAndPort
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
@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);
}
示例5: provideSelfAdminHostAndPort
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
@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);
}
示例6: getPort
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
public static Integer getPort(ServerFactory serverFactory) {
if(serverFactory instanceof SimpleServerFactory) {
return getPort(((SimpleServerFactory)serverFactory).getConnector());
}
else if(serverFactory instanceof DefaultServerFactory) {
return getPort(((DefaultServerFactory)serverFactory).getApplicationConnectors().get(0));
}
throw new RuntimeException("Unable to infer Port of " + serverFactory);
}
示例7: getAdminPort
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
public static Integer getAdminPort(ServerFactory serverFactory) {
if(serverFactory instanceof SimpleServerFactory) {
return getPort(((SimpleServerFactory)serverFactory).getConnector());
}
else if(serverFactory instanceof DefaultServerFactory) {
return getPort(((DefaultServerFactory)serverFactory).getAdminConnectors().get(0));
}
throw new RuntimeException("Unable to infer AdminPort of " + serverFactory);
}
示例8: getConnectorFactoy
import io.dropwizard.server.SimpleServerFactory; //导入依赖的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()));
}
示例9: getSimpleServerFactory
import io.dropwizard.server.SimpleServerFactory; //导入依赖的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()));
}
示例10: getSingularityUriBase
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
@Provides
@Named(SingularityServiceUIModule.SINGULARITY_URI_BASE)
String getSingularityUriBase(final SingularityConfiguration configuration) {
final String singularityUiPrefix;
if (configuration.getServerFactory() instanceof SimpleServerFactory) {
singularityUiPrefix = configuration.getUiConfiguration().getBaseUrl().or(((SimpleServerFactory) configuration.getServerFactory()).getApplicationContextPath());
} else {
singularityUiPrefix = configuration.getUiConfiguration().getBaseUrl().or(((DefaultServerFactory) configuration.getServerFactory()).getApplicationContextPath());
}
return (singularityUiPrefix.endsWith("/")) ? singularityUiPrefix.substring(0, singularityUiPrefix.length() - 1) : singularityUiPrefix;
}
示例11: getSingularityUriBase
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
@Provides
@Named(SINGULARITY_URI_BASE)
String getSingularityUriBase(final SingularityConfiguration configuration) {
final String singularityUiPrefix = configuration.getUiConfiguration().getBaseUrl().or(((SimpleServerFactory) configuration.getServerFactory()).getApplicationContextPath());
return (singularityUiPrefix.endsWith("/")) ? singularityUiPrefix.substring(0, singularityUiPrefix.length() - 1) : singularityUiPrefix;
}
示例12: setup
import io.dropwizard.server.SimpleServerFactory; //导入依赖的package包/类
@BeforeClass
public void setup() throws Exception {
_lifeCycle = new SimpleLifeCycleRegistry();
_healthChecks = mock(HealthCheckRegistry.class);
// Start test instance of ZooKeeper in the current JVM
TestingServer testingServer = new TestingServer();
_lifeCycle.manage(testingServer);
// Connect to ZooKeeper
final CuratorFramework curator = CuratorFrameworkFactory.newClient(testingServer.getConnectString(),
new BoundedExponentialBackoffRetry(100, 1000, 5));
_lifeCycle.manage(curator).start();
// Setup the DataStoreModule
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(LifeCycleRegistry.class).toInstance(_lifeCycle);
bind(HealthCheckRegistry.class).toInstance(_healthChecks);
bind(TaskRegistry.class).toInstance(mock(TaskRegistry.class));
bind(DataStoreConfiguration.class).toInstance(new DataStoreConfiguration()
.setSystemTablePlacement("app_global:sys")
.setValidTablePlacements(ImmutableSet.of("app_global:sys", "ugc_global:ugc"))
.setCassandraClusters(ImmutableMap.<String, CassandraConfiguration>of(
"ugc_global", new TestCassandraConfiguration("ugc_global", "ugc_delta"),
"app_global", new TestCassandraConfiguration("app_global", "sys_delta")))
.setHistoryTtl(Period.days(2)));
bind(DataStore.class).annotatedWith(SystemDataStore.class).toInstance(mock(DataStore.class));
bind(JobService.class).toInstance(mock(JobService.class));
bind(JobHandlerRegistry.class).toInstance(mock(JobHandlerRegistry.class));
bind(DataCenterConfiguration.class).toInstance(new DataCenterConfiguration()
.setCurrentDataCenter("datacenter1")
.setSystemDataCenter("datacenter1")
.setDataCenterServiceUri(URI.create("http://localhost:8080"))
.setDataCenterAdminUri(URI.create("http://localhost:8080")));
bind(CqlDriverConfiguration.class).toInstance(new CqlDriverConfiguration());
bind(KeyspaceDiscovery.class).annotatedWith(Names.named("blob")).toInstance(mock(KeyspaceDiscovery.class));
bind(String.class).annotatedWith(ServerCluster.class).toInstance("local_default");
bind(String.class).annotatedWith(ReplicationKey.class).toInstance("password");
bind(String.class).annotatedWith(InvalidationService.class).toInstance("emodb-cachemgr");
bind(CuratorFramework.class).annotatedWith(Global.class).toInstance(curator);
bind(CuratorFramework.class).annotatedWith(DataStoreZooKeeper.class)
.toInstance(ZKNamespaces.usingChildNamespace(curator, "applications/emodb-sor"));
bind(CuratorFramework.class).annotatedWith(GlobalFullConsistencyZooKeeper.class)
.toInstance(ZKNamespaces.usingChildNamespace(curator, "applications/emodb-fct"));
bind(new TypeLiteral<Supplier<Boolean>>(){}).annotatedWith(CqlForScans.class)
.toInstance(Suppliers.ofInstance(true));
bind(new TypeLiteral<Supplier<Boolean>>(){}).annotatedWith(CqlForMultiGets.class)
.toInstance(Suppliers.ofInstance(true));
bind(ServerFactory.class).toInstance(new SimpleServerFactory());
bind(ServiceRegistry.class).toInstance(mock(ServiceRegistry.class));
bind(Clock.class).toInstance(Clock.systemDefaultZone());
EmoServiceMode serviceMode = EmoServiceMode.STANDARD_ALL;
install(new SelfHostAndPortModule());
install(new DataCenterModule(serviceMode));
install(new CacheManagerModule());
install(new DataStoreModule(serviceMode));
}
});
_store = injector.getInstance(DataStore.class);
_lifeCycle.start();
Map<String, Object> template = Collections.emptyMap();
_store.createTable(TABLE, new TableOptionsBuilder().setPlacement("ugc_global:ugc").build(), template, newAudit("create table"));
}