@Override public void run(Environment environment) { environment.lifecycle().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarting(LifeCycle event) { starting = true; try { ServerContainer wsContainer = InstWebSocketServerContainerInitializer. configureContext(environment.getApplicationContext(), environment.metrics()); StringBuilder sb = new StringBuilder("Registering websocket endpoints: ") .append(System.lineSeparator()) .append(System.lineSeparator()); endpointConfigs.forEach(rethrow(conf -> addEndpoint(wsContainer, conf, sb))); LOG.info(sb.toString()); } catch (ServletException ex) { throw new RuntimeException(ex); } } private void addEndpoint(ServerContainer wsContainer, ServerEndpointConfig conf, StringBuilder sb) throws DeploymentException { wsContainer.addEndpoint(conf); sb.append(String.format(" WS %s (%s)", conf.getPath(), conf.getEndpointClass().getName())).append(System.lineSeparator()); } }); }
@Override public void run(Environment environment) { environment.lifecycle().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarting(LifeCycle event) { starting = true; try { ServerContainer wsContainer = InstWebSocketServerContainerInitializer. configureContext(environment.getApplicationContext(), environment.metrics()); StringBuilder sb = new StringBuilder("Registering websocket endpoints: ") .append(System.lineSeparator()) .append(System.lineSeparator()); endpointConfigs.forEach(rethrow(conf -> addEndpoint(wsContainer, conf, sb))); LOG.info(sb.toString()); } catch (ServletException ex) { throw new RuntimeException(ex); } } private void addEndpoint(ServerContainer wsContainer, ServerEndpointConfig conf, StringBuilder sb) throws DeploymentException { wsContainer.addEndpoint(conf); sb.append(String.format(" WS %s (%s)", conf.getPath(), conf.getEndpointClass().getName())).append(System.lineSeparator()); } }); }
/** * @param listener jetty listener * @see org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener */ public void registerJettyListener(final LifeCycle.Listener listener) { getEnvironment().lifecycle().addLifeCycleListener(listener); }
/** * @param listener jetty listener * @see org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener */ public void registerJettyListener(final LifeCycle.Listener listener) { getEnvironment().lifecycle().addLifeCycleListener(listener); }
@Override public void initialize(final GuiceyBootstrap bootstrap) { // use listener to work properly for both guicey only test and normal app (to show hk stats) bootstrap.environment().lifecycle().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarted(final LifeCycle event) { report(bootstrap.application()); } }); bootstrap.modules(new DiagnosticModule()); }
@Override public void initialize(final GuiceyBootstrap bootstrap) { // use listener to work properly for both guicey only test and normal app (to show hk stats) bootstrap.environment().lifecycle().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarted(final LifeCycle event) { report(bootstrap.application()); } }); bootstrap.modules(new DiagnosticModule()); }