Class MessageDispatcher
- java.lang.Object
-
- org.powertac.visualizer.service_ptac.MessageDispatcher
-
- All Implemented Interfaces:
VisualizerMessageListener
,NewObjectListener
@Service public class MessageDispatcher extends Object implements VisualizerMessageListener, NewObjectListener
ADAPTED FROM broker coreRoutes incoming messages to broker components, and outgoing messages to the server. Components must register for specific message types with the broker, which passes the registrations to this router. For this to work, registered components must implement a handleMessage(msg) method that takes the specified type as its single argument.
- Author:
- Jurica Babic, Govert Buijs, Erik Kemperman
-
-
Constructor Summary
Constructors Constructor Description MessageDispatcher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
static Object
dispatch(Object target, String methodName, Object... args)
Dispatches a call to methodName inside target based on the type of message.void
handleNewObject(Object obj)
void
receiveMessage(Object message)
void
registerAllHandlers()
-
-
-
Method Detail
-
afterPropertiesSet
@PostConstruct public void afterPropertiesSet() throws Exception
- Throws:
Exception
-
receiveMessage
public void receiveMessage(Object message)
- Specified by:
receiveMessage
in interfaceVisualizerMessageListener
-
handleNewObject
public void handleNewObject(Object obj)
- Specified by:
handleNewObject
in interfaceNewObjectListener
-
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).
-
registerAllHandlers
public void registerAllHandlers()
-
-