SK.gnome.dwarf.utils.cache
Interface Pool

All Known Implementing Classes:
SimplePool

public interface Pool

Provides interface for an object pool.

This class provides interface for a generic object pool. The cached objects may optionally implement the Cacheable interface, which provides a basic event handler, informing the objects about their state related to the caching process.


Method Summary
 void clear()
          Removes all objects from the pool.
 java.lang.Object get()
          Gets an object from the pool.
 boolean put(java.lang.Object obj)
          Puts the object to the pool.
 

Method Detail

put

public boolean put(java.lang.Object obj)
Puts the object to the pool.

If an object implementing the Cacheable interface is being added to the pool, the Cacheable.handleCacheEvent(Cacheable.CacheEvent) method must be invoked on it with the Cacheable.CacheEvent.ADDED value. If the object cannot be put to the pool for any reason, the method must return false, otherwise it returns true.

Parameters:
obj - the cached object
Returns:
true if the object was put to the pool, false otherwise

get

public java.lang.Object get()
Gets an object from the pool.

The object is removed from the pool and returned to the caller.

If an object implementing the Cacheable interface is being removed from the pool, the Cacheable.handleCacheEvent(Cacheable.CacheEvent) method must be invoked on it with the Cacheable.CacheEvent.REMOVED value.

Returns:
the cached object or null if no object exists in the pool

clear

public void clear()
Removes all objects from the pool.

If an object implementing the Cacheable interface is being removed from the pool, the Cacheable.handleCacheEvent(Cacheable.CacheEvent) method must be invoked on it with the Cacheable.CacheEvent.INVALIDATED value.



Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.