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


Java ServerLifecycleListener类代码示例

本文整理汇总了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);
}
 
开发者ID:alex-shpak,项目名称:dropwizard-hk2bundle,代码行数:27,代码来源:HK2Bundle.java

示例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());
}
 
开发者ID:roskart,项目名称:dropwizard-jaxws,代码行数:21,代码来源:JAXWSBundleTest.java

示例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");
}
 
开发者ID:roskart,项目名称:dropwizard-jaxws,代码行数:26,代码来源:JAXWSBundleTest.java

示例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);
        }
    });
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:12,代码来源:LocalSchemaRegistryServer.java

示例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();
                }
            }
        });
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:16,代码来源:EmoService.java

示例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);
        }
    });
}
 
开发者ID:timmolter,项目名称:dropwizard-sundial,代码行数:10,代码来源:SundialBundleITBase.java

示例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();
    }
  };
}
 
开发者ID:camunda,项目名称:camunda-bpm-dropwizard,代码行数:9,代码来源:ActivateJobExecutor.java

示例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();
    }
  });

}
 
开发者ID:camunda,项目名称:camunda-bpm-dropwizard,代码行数:16,代码来源:DropwizardInvoiceExampleApplication.java

示例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);
  }
}
 
开发者ID:openstack,项目名称:monasca-common,代码行数:32,代码来源:AbstractAppTest.java

示例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();
    }
  });
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:11,代码来源:BaragonAgentService.java


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