org.perfectjpattern.core.api.behavioral.chainofresponsibility
Interface IParameterlessHandler

All Superinterfaces:
IHandler<NullRequest>
All Known Implementing Classes:
AbstractParameterlessHandler

public interface IParameterlessHandler
extends IHandler<NullRequest>

Chain of Responsibility Design 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. (Gamma et al, Design Patterns)

Responsibility: Abstract definition of the "Handler".


Example usage:

    //
    // Create chain elements 
    //  
    IParameterlessHandler myFirst = new ConcreteHandler();
    IParameterlessHandler mySecond = new ConcreteHandler();
    IParameterlessHandler myThird = new ConcreteHandler();
    
    //
    // Associate Handler elements 
    //
    myFirst.setSuccessor(mySecond);
    mySecond.setSuccessor(myThird);
    
    //
    // Execute the first Handler that triggers the execution of the 
    // complete chain.
    //
    myFirst.start();
 

Version:
$Revision: 1.0 $ $Date: Nov 6, 2007 6:14:22 PM $
Author:
Giovanni Azua
 

Method Summary
 void handle()
          Handle the given request.
 void start()
          Triggers execution of the Chain if the target Handler is the first reference, otherwise implements the decision-making regarding forwarding the request to its successor IHandler instance.
 
Methods inherited from interface org.perfectjpattern.core.api.behavioral.chainofresponsibility.IHandler
canHandle, getSuccessor, handle, setChainStrategy, setSuccessor, start
 

Method Detail

start

void start()
Triggers execution of the Chain if the target Handler is the first reference, otherwise implements the decision-making regarding forwarding the request to its successor IHandler instance.


handle

void handle()
Handle the given request. Implements the actual handling logic and must not contain any decision-making regarding e.g. forwarding the request.



Copyright © 2007-2009. All Rights Reserved.