MentaContainer

Rev

Rev 146 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
64 soliveira 1
package org.mentacontainer;
2
 
70 soliveira 3
/**
95 soliveira 4
 * Some factories can also implement this interface to perform some cleanup
109 soliveira 5
 * when the instance is created or cleared. For example, a connection pool will want
70 soliveira 6
 * to know when the connection instance is cleared so it can return it to
7
 * the pool.
8
 *
95 soliveira 9
 * It makes more sense to use this interface for factories that will be placed
110 soliveira 10
 * in the THREAD scope, but you can also use it with other scopes as well.
70 soliveira 11
 *
12
 * This is particular useful for the THREAD scope for dealing with thread pools, so
13
 * when the thread is returned to the thread pool you will want to clear the THREAD
14
 * scope. That's pretty much how web containers work: one thread per request coming from
15
 * a thread pool.
16
 *
17
 * @author sergio.oliveira.jr@gmail.com
18
 *
19
 * @param <E>
20
 */
106 soliveira 21
public interface Interceptor<E> {
64 soliveira 22
 
109 soliveira 23
        /**
154 soliveira 24
         * This method will be called right after the getInstance() method returns a new instance from the factory.
109 soliveira 25
         *
154 soliveira 26
         * @param createdObject The object that was just returned by the factory.
109 soliveira 27
         */
88 soliveira 28
        public void onCreated(E createdObject);
29
 
109 soliveira 30
        /**
154 soliveira 31
         * This method will be called right after the object is cleared from the scope.
109 soliveira 32
         *
154 soliveira 33
         * @param clearedObject The object that was cleared.
109 soliveira 34
         */
110 soliveira 35
        public void onCleared(E clearedObject);
64 soliveira 36
}