org.powertac.util
Class MessageDispatcher

java.lang.Object
  extended by org.powertac.util.MessageDispatcher

public class MessageDispatcher
extends Object

Static resource for dispatching messages. Helps avoid visitor or double-dispatch intrusions into domain types.

Author:
John Collins

Constructor Summary
MessageDispatcher()
           
 
Method Summary
static Object dispatch(Object target, String methodName, Object... args)
          Dispatches a call to methodName inside target based on the type of message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageDispatcher

public MessageDispatcher()
Method Detail

dispatch

public static Object dispatch(Object target,
                              String methodName,
                              Object... args)
Dispatches a call to methodName inside target based on the type of message. Allows polymorphic method dispatch without the use of visitor or double dispatch schemes, which produce nasty couplings with domain types.

Note that this scheme finds only exact matches between types of arguments and declared types of formal parameters for declared or inherited methods. So it will not call a method with formal parameter types of (Transaction, List) if the actual arguments are (Transaction, ArrayList).



Copyright © 2011. All Rights Reserved.