Skip to content

LifecycleListener

Randgalt edited this page Sep 15, 2012 · 6 revisions

Governator provides a mechanism to listen for injections and lifecycle state changes via the LifecycleListener interface. Add a binding to your listener in the Bootstrapping module.

/**
 * Callback for injected instances
 */
public interface LifecycleListener
{
    /**
     * When Guice injects an object, this callback will be notified
     *
     * @param obj object being injected
     */
    public void     objectInjected(Object obj);

    /**
     * Called when an object's lifecycle state changes
     *
     * @param obj the object
     * @param newState new state
     */
    public void     stateChanged(Object obj, LifecycleState newState);
}