ilog.rules.res.xu.pool
Interface IlrPool<T>
-
public interface IlrPool<T>
IlrPool
represents a pool of objects.Use implementations of this interface to pool resource adapter (JCA) connections.
The properties of a pool implementation are specified in
ra.xml
.An pool object can have the following states:
used
- the object has been added by callingadd(T)
and must not be returned bygetFreeObjects()
untilrelease(T)
is called.free
- the object can be returned by callinggetFreeObjects()
.
An object is removed from the pool:
- By the XU when
remove(T)
is called. - By the pool implementation itself. The registered
IlrPoolListeners
must be notified.
Implementations of this interface must be thread-safe.
After the instance is created,
setLogger(java.util.logging.Logger)
theninitialize(Map)
is called.- Since:
- 7.0
-
-
Method Summary
Methods Modifier and Type Method and Description void
add(T object)
Adds a free object to this pool.void
addPoolEventListener(IlrPoolListener<T> listener)
Adds a listener.java.util.Set<T>
getFreeObjects()
Returns all the free objects in this pool.void
initialize(java.util.Map<java.lang.String,java.lang.String> properties)
Initializes this pool with a given set of properties.boolean
isFull()
Checks if the pool is full.void
release(T object)
Notifies the pool that an object is no longer used.boolean
remove(T object)
Removes an object from this pool.void
removePoolEventListener(IlrPoolListener<T> listener)
Removes a listener.void
setLogger(java.util.logging.Logger logger)
Sets the logger to be used by the pool implementation.void
use(T object)
Notifies the pool that an object is used.void
waitNotFull()
Waits until the pool is not full.
-
-
-
Method Detail
-
initialize
void initialize(java.util.Map<java.lang.String,java.lang.String> properties)
Initializes this pool with a given set of properties.- Parameters:
properties
- A set of configuration properties.
-
add
void add(T object)
Adds a free object to this pool.- Parameters:
object
- A free object.
-
remove
boolean remove(T object)
Removes an object from this pool. This object should not be returned when you callgetFreeObjects()
.- Parameters:
object
- The object to remove.
-
getFreeObjects
java.util.Set<T> getFreeObjects()
Returns all the free objects in this pool.- Returns:
- The free objects in this pool.
-
use
void use(T object)
Notifies the pool that an object is used.- Parameters:
object
- The object used.
-
release
void release(T object)
Notifies the pool that an object is no longer used.- Parameters:
object
- The object to release.
-
isFull
boolean isFull()
Checks if the pool is full. If the pool is full no more objects can be added.- Returns:
- If the pool is full,
true
is returned.
-
waitNotFull
void waitNotFull() throws IlrPoolException, java.lang.UnsupportedOperationException
Waits until the pool is not full.- Throws:
IlrPoolException
- indicates that it is not possible to wait. The reason depends on the pool implementation. For example, the maximum number of waiters or the timeout has been reached.java.lang.UnsupportedOperationException
- indicates that this method is not supported by the implementation.
-
setLogger
void setLogger(java.util.logging.Logger logger)
Sets the logger to be used by the pool implementation.- Parameters:
logger
- The logger to be used by the pool implementation.
-
addPoolEventListener
void addPoolEventListener(IlrPoolListener<T> listener)
Adds a listener. This listener is used by the XU to receive notification when objects are removed from the pool.- Parameters:
listener
- A pool event listener.
-
removePoolEventListener
void removePoolEventListener(IlrPoolListener<T> listener)
Removes a listener.- Since:
- 7.0
- Parameters:
listener
- The pool event listener to remove.
-
-