MentaContainer

Compare Revisions

Ignore whitespace Rev 108 → Rev 109

/trunk/src/main/java/org/mentacontainer/Interceptor.java
2,13 → 2,13
 
/**
* Some factories can also implement this interface to perform some cleanup
* when the instance is cleared. For example, a connection pool will want
* when the instance is created or cleared. For example, a connection pool will want
* to know when the connection instance is cleared so it can return it to
* the pool.
*
* It makes more sense to use this interface for factories that will be placed
* in the THREAD scope, but you can also use it with factories in the SINGLETON
* scope.
* scope. It does not make sense to use an interceptor for scope NONE.
*
* This is particular useful for the THREAD scope for dealing with thread pools, so
* when the thread is returned to the thread pool you will want to clear the THREAD
21,7 → 21,17
*/
public interface Interceptor<E> {
/**
* This method will be called right before the getInstance() method return a new instance created by the factory.
*
* @param createdObject The object that was just created.
*/
public void onCreated(E createdObject);
/**
* This method will be called right before the object is cleared from the scope.
*
* @param destroyedObject The object being cleared.
*/
public void onDestroyed(E destroyedObject);
}