Package org.powertac.samplebroker.core
Class MessageDispatcher
- java.lang.Object
-
- org.powertac.samplebroker.core.MessageDispatcher
-
@Service public class MessageDispatcher extends Object
Routes 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:
- John Collins
-
-
Constructor Summary
Constructors Constructor Description MessageDispatcher()Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidregisterMessageHandler(Object handler, Class<?> messageType)Sets up handlers for incoming messages by message type.voidrouteMessage(Object message)Routes incoming messages from the servervoidsendMessage(Object message)Converts outgoing message to XML, sends it to the servervoidsendRawMessage(String message)Sends XML-formatted message to the server without interpretation.
-
-
-
Method Detail
-
registerMessageHandler
public void registerMessageHandler(Object handler, Class<?> messageType)
Sets up handlers for incoming messages by message type.
-
routeMessage
public void routeMessage(Object message)
Routes incoming messages from the server
-
sendMessage
public void sendMessage(Object message)
Converts outgoing message to XML, sends it to the server
-
sendRawMessage
public void sendRawMessage(String message)
Sends XML-formatted message to the server without interpretation.
-
-