Guicey lifecycle

Tip

Guicey broadcast events in all major points. You can see most of them with enabled lifecycle report.

Configuration phase

Note

All manual registrations must be performed under this phase (the only exception is guice modules). All bundles are registered and initialized only under configuration phase.

Everything below happens under bundle registration call:

@Override
public void initialize(Bootstrap<Configuration> bootstrap) {
    bootstrap.addBundle(GuiceBundle.builder()
            ...
            .build());

    // everything here will be called after all steps below
}

Run phase

Note

As dropwizard bundles were registered under GuiceBundle configuration, they will be run by dropwizard after GuiceBundle.

Note

Your Application.run() method will be called after guicey startup, so you can use created injector there.

Jersey startup

Note

Jersey startup will initiate hk2 context creation

  • Managed beans started
  • hk2 context creation activates GuiceFeature (registered earlier)
    • Apply guice bridge (if required)
    • Run jersey specific installers (resource, extension): installers will register required bindings in hk2 context

Note

Any EnvironmentCommand did no start jersey, so managed objects will not be started (but you can start required services manually. Also, all jersey related extensions will not be started. Still, core guice context will be completely operable.

When guice context is created, jersey context doesn't exist and when jersey context is created it doesn't aware of guice existence.