-
Notifications
You must be signed in to change notification settings - Fork 179
LifecycleListener
Randgalt edited this page Feb 21, 2013
·
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.
You can bind multiple LifecycleListener
instances. The BootstrapBinder
has a method for binding LifecycleListener
instances.
// to bind a LifecycleListener in the BootstrapBinder
binder.bindLifecycleListener().to(MyListener.class);
/**
* Callback for injected instances
*/
public interface LifecycleListener
{
/**
* When Guice injects an object, this callback will be notified
*
* @param type object type being injected
* @param obj object being injected
*/
public <T> void objectInjected(TypeLiteral<T> type, T obj);
/**
* Called when an object's lifecycle state changes
*
* @param obj the object
* @param newState new state
*/
public void stateChanged(Object obj, LifecycleState newState);
}
- Home
- Getting Started
- Bootstrapping
- Lifecycle Management
- Auto Binding
- Module-Dependencies
- Warm Up
- Configuration Mapping
- Field Validation
- Lazy Singleton
- Concurrent Singleton
- Generic Binding Annotations
- LifecycleListener
- Governator Phases
- Grapher Integration
- JUnit Testing
- FAQ
- Best Practices
- Spring, PicoContainer, Etc.
- Javadoc
- End-to-End Examples