本文整理汇总了Java中io.dropwizard.lifecycle.ServerLifecycleListener类的典型用法代码示例。如果您正苦于以下问题:Java ServerLifecycleListener类的具体用法?Java ServerLifecycleListener怎么用?Java ServerLifecycleListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerLifecycleListener类属于io.dropwizard.lifecycle包,在下文中一共展示了ServerLifecycleListener类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
@Override
public void run(Environment environment) {
ServiceLocatorUtilities.bind(serviceLocator, new EnvBinder(application, environment));
LifecycleEnvironment lifecycle = environment.lifecycle();
AdminEnvironment admin = environment.admin();
listServices(HealthCheck.class).forEach(healthCheck -> {
String name = healthCheck.getClass().getSimpleName();
environment.healthChecks().register(name, healthCheck);
});
listServices(Managed.class).forEach(lifecycle::manage);
listServices(LifeCycle.class).forEach(lifecycle::manage);
listServices(LifeCycle.Listener.class).forEach(lifecycle::addLifeCycleListener);
listServices(ServerLifecycleListener.class).forEach(lifecycle::addServerLifecycleListener);
listServices(Task.class).forEach(admin::addTask);
environment.jersey().register(HK2LifecycleListener.class);
//Set service locator as parent for Jersey's service locator
environment.getApplicationContext().setAttribute(ServletProperties.SERVICE_LOCATOR, serviceLocator);
environment.getAdminContext().setAttribute(ServletProperties.SERVICE_LOCATOR, serviceLocator);
serviceLocator.inject(application);
}
示例2: initializeAndRun
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
@Test
public void initializeAndRun() {
JAXWSBundle jaxwsBundle = new JAXWSBundle("/soap", jaxwsEnvironment);
try {
jaxwsBundle.run(null, null);
}
catch (Exception e) {
assertThat(e, is(instanceOf(IllegalArgumentException.class)));
}
jaxwsBundle.initialize(bootstrap);
verify(jaxwsEnvironment).setInstrumentedInvokerBuilder(any(InstrumentedInvokerFactory.class));
jaxwsBundle.run(null, environment);
verify(servletEnvironment).addServlet(startsWith("CXF Servlet"), any(Servlet.class));
verify(lifecycleEnvironment).addServerLifecycleListener(any(ServerLifecycleListener.class));
verify(servlet).addMapping("/soap/*");
verify(jaxwsEnvironment, never()).setPublishedEndpointUrlPrefix(anyString());
}
示例3: initializeAndRunWithPublishedEndpointUrlPrefix
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
@Test
public void initializeAndRunWithPublishedEndpointUrlPrefix() {
JAXWSBundle jaxwsBundle = new JAXWSBundle("/soap", jaxwsEnvironment) {
@Override
protected String getPublishedEndpointUrlPrefix(Object configuration) {
return "http://some/prefix";
}
};
try {
jaxwsBundle.run(null, null);
}
catch (Exception e) {
assertThat(e, is(instanceOf(IllegalArgumentException.class)));
}
jaxwsBundle.initialize(bootstrap);
verify(jaxwsEnvironment).setInstrumentedInvokerBuilder(any(InstrumentedInvokerFactory.class));
jaxwsBundle.run(null, environment);
verify(servletEnvironment).addServlet(startsWith("CXF Servlet"), any(Servlet.class));
verify(lifecycleEnvironment).addServerLifecycleListener(any(ServerLifecycleListener.class));
verify(servlet).addMapping("/soap/*");
verify(jaxwsEnvironment).setPublishedEndpointUrlPrefix("http://some/prefix");
}
示例4: run
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
@Override
public void run(RegistryConfiguration registryConfiguration, Environment environment) throws Exception {
super.run(registryConfiguration, environment);
environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(Server server) {
localServer = server;
LOG.info("Received callback as server is started :[{}]", server);
}
});
}
示例5: evaluateServiceStartedListeners
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
private void evaluateServiceStartedListeners() throws Exception {
final List<ServerStartedListener> listeners = _injector.getInstance(
Key.get(new TypeLiteral<List<ServerStartedListener>>() {}));
if (!listeners.isEmpty()) {
_environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(Server server) {
for (ServerStartedListener listener : listeners) {
listener.serverStarted();
}
}
});
}
}
示例6: run
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
@Override
public void run(TestConfiguration testConfiguration, Environment environment) throws Exception {
environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(Server server) {
SundialJobScheduler.addJob(JOB_NAME, TestJob.class);
}
});
}
示例7: serverLifecycleListener
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
public static ServerLifecycleListener serverLifecycleListener() {
return new ServerLifecycleListener() {
@Override
public void serverStarted(final Server unused) {
new ActivateJobExecutor().run();
}
};
}
示例8: run
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
@Override
public void run(Config configuration, Environment environment) throws Exception {
CamundaHealthChecks.processIsDeployed(environment, PROCESS_DEFINITION_KEY);
final StartProcessTask startProcessTask = new StartProcessTask();
environment.admin().addTask(startProcessTask);
environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(final Server server) {
startProcessTask.startProcess();
}
});
}
示例9: startIfRequired
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
private void startIfRequired() {
if (jettyServer != null) {
return;
}
try {
application = newApplication();
final Bootstrap<C> bootstrap = new Bootstrap<C>(application) {
@Override
public void run(C configuration, Environment environment) throws Exception {
environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(Server server) {
jettyServer = server;
}
});
AbstractAppTest.this.configuration = configuration;
AbstractAppTest.this.environment = environment;
super.run(configuration, environment);
}
};
application.initialize(bootstrap);
final ServerCommand<C> command = new ServerCommand<>(application);
final Namespace namespace = new Namespace(ImmutableMap.<String, Object>of("file", configPath));
command.run(bootstrap, namespace);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例10: run
import io.dropwizard.lifecycle.ServerLifecycleListener; //导入依赖的package包/类
@Override
public void run(BaragonAgentConfiguration configuration, Environment environment) throws Exception {
environment.lifecycle().addServerLifecycleListener(new ServerProvider());
environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(Server server) {
guiceBundle.getInjector().getInstance(LifecycleHelper.class).checkStateNodeVersion();
}
});
}