Interface PmessageSystem
- All Known Subinterfaces:
PmessageSystemEE
- All Known Implementing Classes:
SimpleMessageSystem
public interface PmessageSystem
This interface is not ideal for use with Java EE. Currently, we can accommodate EE by adding one constructor to an extension of this interface called PmessageSystemEE
This interface, as originally written, assumes that processes share a communication area containing message queues. A robust implementation of a subclass will be sure to provide ways to save the queues when the system is going down. Simple implementations are allowed to ignore this area of functionality with only a message on the error log. A conforming Java EE concrete class may rely on the persistence of the queues in the EE server.
For ease of use with the pygar configuration convention, this class must provide a factory method in addition to the normal constructor. Thus, the configuration profile can contain an instance of the desired subclass which will subsequently provide instances during program execution.
-
Method Summary
Modifier and Type Method Description booleancanSend(Pmessage message)Test whether the system is ready to send to a given recipient.PmessageSystemgetPmessageSystem(java.lang.String senderId)Factory method returns a working instance for the specified senderId.booleanhasNext()Return true if there is a Pmessage waiting to be received.Pmessagenext()Return the next waiting Pmessage or void if there is none.voidprintAgents()Return all the agent names associated with this instance.voidsend(java.lang.String sender, java.lang.String receiver, java.lang.String event)Construct and send a simple event Pmessage to a destination.voidsend(Pmessage message)Send a Pmessage to the destination specified in the Pmessage object.booleanshutdownNow()Return true if the system should shutdown.
-
Method Details
-
getPmessageSystem
Factory method returns a working instance for the specified senderId.- Parameters:
senderId- the Id of the entity that will use this instance of the message system.- Returns:
- exemplar
-
send
Send a Pmessage to the destination specified in the Pmessage object.- Parameters:
message-- Throws:
MessageSystemException
-
canSend
Test whether the system is ready to send to a given recipient.- Parameters:
message-- Returns:
- true if ready to send
-
send
void send(java.lang.String sender, java.lang.String receiver, java.lang.String event) throws MessageSystemExceptionConstruct and send a simple event Pmessage to a destination.- Parameters:
sender-receiver-event-- Throws:
MessageSystemException
-
hasNext
boolean hasNext()Return true if there is a Pmessage waiting to be received.- Returns:
- boolean
-
next
Return the next waiting Pmessage or void if there is none.- Returns:
- Pmessage
- Throws:
MessageSystemException
-
printAgents
void printAgents()Return all the agent names associated with this instance. Usually, there is just one. However, in certain test procedures as well as in the subclass SimpleMessageSystem there may be several. -
shutdownNow
boolean shutdownNow()Return true if the system should shutdown. There is no general way to determine this condition. It will depend on the implementation in the subclasses.
-