org.perfectjpattern.core.api.behavioral.command
Interface IReceiver<P,R>

Type Parameters:
P - Command Parameter context-specific
R - Command Result context-specific
All Known Implementing Classes:
AbstractReceiver, Open, Paste

public interface IReceiver<P,R>

Command Design Pattern: Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. (Gamma et al, Design Patterns)

Responsibility: Abstract generic definition of the "Receiver".



Example usage:

    //
    // Create Command Pattern elements 
    //  
    IInvoker myInvoker = new ConcreteInvoker();
    ICommand myCommand = new ConcreteCommand();
    IReceiver myReceiver = new ConcreteReceiver();
    
    //
    // Associate Command Pattern elements 
    //
    myInvoker.setCommand(myCommand);
    myCommand.setReceiver(myReceiver);
    
    //
    // Optionally parameterize the Invoker
    //
    myInvoker.setParameter(new SomeParameter());
    
    //
    // Execute Invoker's invoke method that triggers execution of 
    // Command and Receiver
    //
    myInvoker.invoke();
    
    //
    // Optionally and if the Command is synchronous, retrieve a result
    //
    System.out.println(myInvoker.getResult().toString());
 

Version:
$Revision: 1.0 $ $Date: Jun 19, 2007 11:09:44 PM $
Author:
Giovanni Azua
 

Method Summary
 void execute()
          Starts the execution of the IReceiver.
 R getResult()
          Returns result out of executing this IReceiver.
 void setParameter(P aParameter)
          Sets the input parameter required for the execution of this IReceiver.
 

Method Detail

setParameter

void setParameter(P aParameter)
                  throws IllegalArgumentException
Sets the input parameter required for the execution of this IReceiver.

Parameters:
aParameter - Parameter required for executing the IReceiver.
Throws:
IllegalArgumentException - 'aParameter' must not be null.

getResult

R getResult()
            throws IllegalStateException
Returns result out of executing this IReceiver.

Returns:
Result out of executing this IReceiver.
Throws:
IllegalStateException - No result available.

execute

void execute()
             throws IllegalStateException
Starts the execution of the IReceiver.

Throws:
IllegalStateException - Parameter not set.


Copyright © 2007-2009. All Rights Reserved.