| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jplate.foundation.gof.cor.impl.defaults.DefaultChainOfResponsibility<V,P>
V - The object to be processed.P - The processors in the chain.public class DefaultChainOfResponsibility<V,P extends ProcessorIfc<V>>
Default implementation of the "Gang of Four" Chain of Responsibility pattern:
    "Avoid coupling the sender of a request to its receiver by giving more than
    one object a chance to handle the request.  Chain the receiving objects and pass
    the request along the chain until an object handles it," p223 Design
    Patterns - Elements of Reusable Object-Oriented Software.
    
    
    Please note: when calling process(V), if any processor
    returns null, no more processors will be requested to process and
    the null value will be returned.
    
    
public final class PersonIfc
{
    public String getName ();
    public int getAge ();
}
final class PersonAgeProcessor implements ProcessorIfc <PersonIfc>
{
    public PersonIfc process ( final PersonIfc person )
    {
        // Do some person age work here...
        return person;
    }
}
final ChainOfResponsibility <PersonIfc, PersonAgeProcessor> cor =
    new DefaultChainOfResponsibility  <PersonIfc, PersonAgeProcessor> ();
    
    
Modifications:
    $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
    $Revision: 479 $
    $Author: sfloess $
    $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/gof/cor/impl/defaults/DefaultChainOfResponsibility.java $
    
| Field Summary | |
|---|---|
private  java.util.List<P> | 
_list
The list of processors in the chain.  | 
private  org.apache.commons.logging.Log | 
_log
Used for logging.  | 
| Constructor Summary | |
|---|---|
DefaultChainOfResponsibility()
Default constructor.  | 
|
DefaultChainOfResponsibility(ListFactoryIfc<P> listFactory)
This constructor uses listFactory to build its internal
 list to hold processors in the chain. | 
|
| Method Summary | |
|---|---|
 java.util.List<P> | 
getProcessors()
Returns the processors who make up the chain.  | 
 V | 
process(V toProcess)
Requests toProcess to be processed. | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
private final org.apache.commons.logging.Log _log
private final java.util.List<P extends ProcessorIfc<V>> _list
| Constructor Detail | 
|---|
public DefaultChainOfResponsibility(ListFactoryIfc<P> listFactory)
listFactory to build its internal
 list to hold processors in the chain.
listFactory - The factory that will be used to create the list of
        processors in the chain.public DefaultChainOfResponsibility()
| Method Detail | 
|---|
public V process(V toProcess)
          throws ProcessException
toProcess to be processed.
process in interface ProcessorIfc<V>toProcess - The object to process.
ProcessException - if any problem arises processing
         toProcess.public java.util.List<P> getProcessors()
getProcessors in interface ChainOfResponsibilityIfc<V,P extends ProcessorIfc<V>>
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||