net.sf.spif
Class StoreDispatcher

java.lang.Object
  |
  +--net.sf.spif.StoreChain
        |
        +--net.sf.spif.StoreDispatcher

public class StoreDispatcher
extends StoreChain

A StoreChain which dispatches requests to the correct chain dependent upon object type. A StoreDispatcher can have multiple chains. It will forward to the chain it deems appropriate.

This type of chain will enable you to implements StoreChain chains that represents tree structures.


                         StoreDispatcher
                                /\                        
           LegacyPerson        /  \ All other types
           LegacyEmployee     /    \
                             /      \
                    LegacyStore    StorePersister
                         |
                   StoreDispatcher
                        /\
                       /  \
      LegacyEmployee  /    \ LegacayPerson 
                     /      \
                    /        \
               DB2Store   ISAMStore

 

Note that the tree structure can be introduced at any level. Currently, only one chain per type is supported, which means that StoreDispatcher will only dispatch to one StoreChain.

Version:
$Id: StoreDispatcher.java,v 1.4 2003/04/03 20:46:24 bratseth Exp $
Author:
Bjørn Bjerkeli <Bjørn Bjerkeli@zenior.no>, Jon S Bratseth

Field Summary
 
Fields inherited from class net.sf.spif.StoreChain
chained
 
Constructor Summary
StoreDispatcher()
           
 
Method Summary
 StoreChain getChained(Id id)
          Get the chain for the appropriate id type
protected  StoreChain getStoreChainInstance(java.lang.Class clazz)
          Retrieve the StoreChain instance for the given type (class).
 void setChained(java.lang.Class clazz, StoreChain chain)
          Sets a chained store for a particular type.
 java.lang.String toString()
          String representation for debugging purposes.
 
Methods inherited from class net.sf.spif.StoreChain
clear, equals, get, getChained, getChained, hashCode, put, remove, setChained
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StoreDispatcher

public StoreDispatcher()
Method Detail

getChained

public StoreChain getChained(Id id)
Get the chain for the appropriate id type

Overrides:
getChained in class StoreChain
Parameters:
id - the id to return the chain of, or null to return the default chain. Note that all implementations are required to return a sensible chain given null.
Returns:
the StoreChain chained on this for the given id type
See Also:
Id.getType(), StoreDispatcher

setChained

public void setChained(java.lang.Class clazz,
                       StoreChain chain)
Sets a chained store for a particular type. All requests pertaining this type will go to this store. Requests for which no certain type store has been registered will go to the default chain (set by setChained(java.lang.Class, net.sf.spif.StoreChain)).

Parameters:
clazz - the type this store should handle
chain - the store chain which handles this type, or null to use the default chain for this type

getStoreChainInstance

protected StoreChain getStoreChainInstance(java.lang.Class clazz)
Retrieve the StoreChain instance for the given type (class).

Parameters:
clazz - the type from which the StoreChain is related to.
Returns:
a StoreChain value

toString

public java.lang.String toString()
String representation for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
a String value


Spif 1.01 (2003-04-03). http://spif.sf.net