Java Code Examples for org.eclipse.jetty.util.component.LifeCycle#Listener

The following examples show how to use org.eclipse.jetty.util.component.LifeCycle#Listener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockApplication.java    From soabase with Apache License 2.0 6 votes vote down vote up
@Override
public void run(MockConfiguration configuration, Environment environment) throws Exception
{
    AbstractBinder abstractBinder = new AbstractBinder()
    {
        @Override
        protected void configure()
        {
            bind(new MockHK2Injected()).to(MockHK2Injected.class);
        }
    };
    environment.jersey().register(abstractBinder);
    environment.jersey().register(MockResource.class);
    LifeCycle.Listener listener = new AbstractLifeCycle.AbstractLifeCycleListener()
    {
        @Override
        public void lifeCycleStarted(LifeCycle event)
        {
            System.out.println("Starting...");
            startedLatch.countDown();
        }
    };
    environment.lifecycle().addLifeCycleListener(listener);
}
 
Example 2
Source File: JettyServiceConfig.java    From armeria with Apache License 2.0 6 votes vote down vote up
JettyServiceConfig(@Nullable String hostname,
                   @Nullable Boolean dumpAfterStart, @Nullable Boolean dumpBeforeStop,
                   @Nullable Long stopTimeoutMillis,
                   @Nullable Handler handler, @Nullable RequestLog requestLog,
                   @Nullable Function<? super Server, ? extends SessionIdManager> sessionIdManagerFactory,
                   Map<String, Object> attrs, List<Bean> beans, List<HandlerWrapper> handlerWrappers,
                   List<Listener> eventListeners, List<LifeCycle.Listener> lifeCycleListeners,
                   List<Consumer<? super Server>> configurators) {

    this.hostname = hostname;
    this.dumpAfterStart = dumpAfterStart;
    this.dumpBeforeStop = dumpBeforeStop;
    this.stopTimeoutMillis = stopTimeoutMillis;
    this.handler = handler;
    this.requestLog = requestLog;
    this.sessionIdManagerFactory = sessionIdManagerFactory;
    this.attrs = Collections.unmodifiableMap(attrs);
    this.beans = Collections.unmodifiableList(beans);
    this.handlerWrappers = Collections.unmodifiableList(handlerWrappers);
    this.eventListeners = Collections.unmodifiableList(eventListeners);
    this.lifeCycleListeners = Collections.unmodifiableList(lifeCycleListeners);
    this.configurators = Collections.unmodifiableList(configurators);
}
 
Example 3
Source File: JettyServiceConfig.java    From armeria with Apache License 2.0 6 votes vote down vote up
static String toString(
        Object holder, @Nullable String hostname, @Nullable Boolean dumpAfterStart,
        @Nullable Boolean dumpBeforeStop, @Nullable Long stopTimeout,
        @Nullable Handler handler, @Nullable RequestLog requestLog,
        @Nullable Function<? super Server, ? extends SessionIdManager> sessionIdManagerFactory,
        Map<String, Object> attrs, List<Bean> beans, List<HandlerWrapper> handlerWrappers,
        List<Listener> eventListeners, List<LifeCycle.Listener> lifeCycleListeners,
        List<Consumer<? super Server>> configurators) {

    return MoreObjects.toStringHelper(holder)
                      .add("hostname", hostname)
                      .add("dumpAfterStart", dumpAfterStart)
                      .add("dumpBeforeStop", dumpBeforeStop)
                      .add("stopTimeoutMillis", stopTimeout)
                      .add("handler", handler)
                      .add("requestLog", requestLog)
                      .add("sessionIdManagerFactory", sessionIdManagerFactory)
                      .add("attrs", attrs)
                      .add("beans", beans)
                      .add("handlerWrappers", handlerWrappers)
                      .add("eventListeners", eventListeners)
                      .add("lifeCycleListeners", lifeCycleListeners)
                      .add("configurators", configurators)
                      .toString();
}
 
Example 4
Source File: MockOldStyleApplication.java    From soabase with Apache License 2.0 5 votes vote down vote up
@Override
public void run(Configuration configuration, Environment environment) throws Exception
{
    LifeCycle.Listener listener = new AbstractLifeCycle.AbstractLifeCycleListener()
    {
        @Override
        public void lifeCycleStarted(LifeCycle event)
        {
            System.out.println("Starting...");
            startedLatch.countDown();
        }
    };
    environment.lifecycle().addLifeCycleListener(listener);
}
 
Example 5
Source File: JettyServiceConfig.java    From armeria with Apache License 2.0 4 votes vote down vote up
List<LifeCycle.Listener> lifeCycleListeners() {
    return lifeCycleListeners;
}
 
Example 6
Source File: ApplicationRunEvent.java    From dropwizard-guicey with MIT License 2 votes vote down vote up
/**
 * @param listener jetty listener
 * @see org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
 */
public void registerJettyListener(final LifeCycle.Listener listener) {
    getEnvironment().lifecycle().addLifeCycleListener(listener);
}
 
Example 7
Source File: GuiceyEnvironment.java    From dropwizard-guicey with MIT License 2 votes vote down vote up
/**
 * Shortcut for jetty lifecycle listener {@link LifeCycle.Listener listener} registration.
 * <p>
 * Lifecycle listeners are called with lightweight guicey test helpers
 * {@link ru.vyarus.dropwizard.guice.test.GuiceyAppRule} or
 * {@link ru.vyarus.dropwizard.guice.test.spock.UseGuiceyApp} which makes them perfectly suitable for reporting.
 * <p>
 * If only startup event is required, prefer {@link #onApplicationStartup(ApplicationStartupListener)} method
 * as more expressive and easier to use.
 * <p>
 * Listeners are not called on custom command execution.
 *
 * @param listener jetty
 * @return environment instance for chained calls
 * @see org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener adapter
 */
public GuiceyEnvironment listenJetty(final LifeCycle.Listener listener) {
    environment().lifecycle().addLifeCycleListener(listener);
    return this;
}