org.datamanager.kernel
Class Pool

java.lang.Object
  |
  +--org.datamanager.kernel.Pool
All Implemented Interfaces:
EventGenerator, Serializable

public class Pool
extends Object
implements EventGenerator, Serializable

The Pool is a collection of Entities. It can be searched, subscribed to, and modified, by adding and removing Entities.

Version:
$Revision: 1.51 $
Author:
Matthew Farrellee
See Also:
Serialized Form

Method Summary
 void add(DataManagerEvent event)
          Adds an event to the Pool.
 void add(Entity entity)
          Links an entity to the Pool.
 boolean equals(Object object)
          Returns true if the given Object is equivalent to this Pool.
protected  void fireEvent(DataManagerEvent event)
          Fires an event.
static Pool getDefaultPool()
          Reports the default Pool.
protected  void loadAssistant()
          The EventGeneratorAssistant is transient, so this method is used to reload the EventGeneratorAssistant when needed.
 void persist()
          Persists this Pool and all its Entities.
 void remove(Entity entity)
          Removes all the entity's entity links as well as its link to the pool.
 Entity[] search(EntityConstraint constraint)
          Searches for all entities in the Pool satisfying the parameterized constraint.
 void subscribe(EventHandler handler, EventConstraint constraint)
          Subscribes an EventHandler with an EntityConstraint to the Pool.
 void unsubscribe(EventHandler handler)
          Unsubscribes an EventHandler.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadAssistant

protected void loadAssistant()
The EventGeneratorAssistant is transient, so this method is used to reload the EventGeneratorAssistant when needed.


fireEvent

protected void fireEvent(DataManagerEvent event)
Fires an event. This method is used internally in the Pool for firing events generated by the Pool.

Parameters:
event - An event to fire.

getDefaultPool

public static Pool getDefaultPool()
                           throws DataManagerException
Reports the default Pool.

Returns:
The only instance of the Pool.
Throws:
DataManagerException

search

public Entity[] search(EntityConstraint constraint)
                throws DataManagerException
Searches for all entities in the Pool satisfying the parameterized constraint. In the future this may be better served by returning an immutable enumeration/iterator over the constrained entities.

Parameters:
constraint - A constraint to filter entities from the Pool.
Returns:
An array of Entities that satisfied the constraint.
Throws:
DataManagerException

add

public void add(Entity entity)
         throws DataManagerException
Links an entity to the Pool.

Parameters:
entity - The Entity to add to the Pool.
Throws:
DataManagerException

add

public void add(DataManagerEvent event)
         throws DataManagerException
Adds an event to the Pool. This event will also be fired to all EventHandlers subscribed to the Pool who are interested in it. Note: DataManagerEvents are NOT persistent. Entities are.

Parameters:
event - The event to add to the Pool.
Throws:
DataManagerException

remove

public void remove(Entity entity)
            throws DataManagerException
Removes all the entity's entity links as well as its link to the pool. Note: This is currently not implemented.

Parameters:
entity - The Entity to remove from the Pool.
Throws:
DataManagerException

subscribe

public void subscribe(EventHandler handler,
                      EventConstraint constraint)
               throws DataManagerException
Subscribes an EventHandler with an EntityConstraint to the Pool.

Specified by:
subscribe in interface EventGenerator
Parameters:
handler - The EventHandler to subscribe.
constraint - The constraint that identifies the events of interest to the EventHandler.
Throws:
DataManagerException

unsubscribe

public void unsubscribe(EventHandler handler)
                 throws DataManagerException
Unsubscribes an EventHandler.

Specified by:
unsubscribe in interface EventGenerator
Parameters:
handler - The EventHandler to unsubscribe.
Throws:
DataManagerException

persist

public void persist()
             throws DataManagerException
Persists this Pool and all its Entities. Package-private access. Delegates to the VerySimpleEntityManagers persist() method so as to preserve the Entity mappings necessary for querying the Pool (the Pool merely maintains a Set of Identifiers currently, which are useless without their associated Entities/EntityProxies).

DataManagerException

equals

public boolean equals(Object object)
Returns true if the given Object is equivalent to this Pool. They are equal when 1. The Object passed in is pointer equivalent to this Pool, or 2. the Object passed in is also a Pool and contains exactly the same set of Entity Identifiers that this Pool contains.

Overrides:
equals in class Object


See the Helium Website