jadex.standalone.service
Class MessageService

java.lang.Object
  extended by jadex.commons.service.BasicService
      extended by jadex.standalone.service.MessageService
All Implemented Interfaces:
IMessageService, IRemotable, IInternalService, IService

public class MessageService
extends BasicService
implements IMessageService

The Message service serves several message-oriented purposes: a) sending and delivering messages by using transports b) management of transports (add/remove) The message service performs sending and delivering messages by separate actions that are individually executed on the execution service, i.e. they are delivered synchronous or asynchronous depending on the execution service mode.


Nested Class Summary
protected  class MessageService.DeliverMessage
          Deliver message(s) executable.
protected  class MessageService.SendManager
          Send message(s) executable.
 
Field Summary
protected  IClockService clockservice
          The cashed clock service.
protected  IComponentManagementService cms
          The cashed clock service.
protected static IContentCodec[] DEFCODECS
          The default codecs.
protected  MessageService.DeliverMessage delivermsg
          The deliver message action executed by platform executor.
protected  List listeners
          The listeners.
protected  String LOCAL
          No addresses constant.
protected  Logger logger
          The logger.
protected  LRU managers
          The target managers.
protected  Map messagetypes
          The message types.
protected  IServiceProvider provider
          The provider.
protected  List transports
          The transports.
 
Fields inherited from class jadex.commons.service.BasicService
idcnt, properties, shutdowned, sid, started, startfutures
 
Fields inherited from interface jadex.commons.service.IService
EMPTY_SERVICES
 
Constructor Summary
MessageService(IServiceProvider provider, ITransport[] transports, MessageType[] messagetypes)
          Constructor for Outbox.
 
Method Summary
 void addMessageListener(IMessageListener listener)
          Add a message listener.
 void addTransport(ITransport transport)
          Adds a transport for this outbox.
 void changeTransportPosition(boolean up, ITransport transport)
          Moves a transport up or down.
 Map createReply(Map msg, MessageType mt)
          Create a reply to this message event.
 void deliverMessage(Map message, String msgtype, IComponentIdentifier[] receivers)
          Deliver a message to the intended components.
protected  void doSendMessage(Map msg, MessageType type, IExternalAccess comp, ClassLoader cl, Map msgcopy, Future ret)
          Extracted method to be callable from listener.
 String[] getAddresses()
          Get the adresses of a component.
 String[] getAddressSchemes()
          Get addresses of all transports.
static IContentCodec[] getContentCodecs(Map props)
          Get a matching content codec.
 MessageType getMessageType(String type)
          Get the message type.
 MessageService.SendManager getSendManager(IComponentIdentifier cid)
          Get a send target manager for addresses.
 ITransport[] getTransports()
          Get the transports.
protected  void internalDeliverMessage(Map msg, String type, IComponentIdentifier[] receivers)
          Deliver a message to the receivers.
 void removeMessageListener(IMessageListener listener)
          Remove a message listener.
 void removeTransport(ITransport transport)
          Remove a transport for the outbox.
 IFuture sendMessage(Map msg, MessageType type, IComponentIdentifier sender, ClassLoader cl)
          Send a message.
 IFuture shutdownService()
          Called when the platform shuts down.
 IFuture startService()
          Start the service.
 
Methods inherited from class jadex.commons.service.BasicService
createServiceIdentifier, generateServiceName, getPropertyMap, getServiceIdentifier, isValid, setPropertyMap, signalStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jadex.commons.service.IService
getPropertyMap, getServiceIdentifier, signalStarted
 

Field Detail

DEFCODECS

protected static IContentCodec[] DEFCODECS
The default codecs.


LOCAL

protected String LOCAL
No addresses constant.


provider

protected IServiceProvider provider
The provider.


transports

protected List transports
The transports.


messagetypes

protected Map messagetypes
The message types.


delivermsg

protected MessageService.DeliverMessage delivermsg
The deliver message action executed by platform executor.


logger

protected Logger logger
The logger.


listeners

protected List listeners
The listeners.


clockservice

protected IClockService clockservice
The cashed clock service.


cms

protected IComponentManagementService cms
The cashed clock service.


managers

protected LRU managers
The target managers.

Constructor Detail

MessageService

public MessageService(IServiceProvider provider,
                      ITransport[] transports,
                      MessageType[] messagetypes)
Constructor for Outbox.

Parameters:
platform -
Method Detail

sendMessage

public IFuture sendMessage(Map msg,
                           MessageType type,
                           IComponentIdentifier sender,
                           ClassLoader cl)
Send a message.

Specified by:
sendMessage in interface IMessageService
Parameters:
message - The native message.

doSendMessage

protected void doSendMessage(Map msg,
                             MessageType type,
                             IExternalAccess comp,
                             ClassLoader cl,
                             Map msgcopy,
                             Future ret)
Extracted method to be callable from listener.


getContentCodecs

public static IContentCodec[] getContentCodecs(Map props)
Get a matching content codec.

Parameters:
props - The properties.
Returns:
The content codec.

deliverMessage

public void deliverMessage(Map message,
                           String msgtype,
                           IComponentIdentifier[] receivers)
Deliver a message to the intended components. Called from transports.

Specified by:
deliverMessage in interface IMessageService
Parameters:
message - The native message. (Synchronized because can be called from concurrently executing transports)

createReply

public Map createReply(Map msg,
                       MessageType mt)
Create a reply to this message event.

Specified by:
createReply in interface IMessageService
Parameters:
msgeventtype - The message event type.
Returns:
The reply event.

addTransport

public void addTransport(ITransport transport)
Adds a transport for this outbox.

Parameters:
transport - The transport.

removeTransport

public void removeTransport(ITransport transport)
Remove a transport for the outbox.

Parameters:
transport - The transport.

changeTransportPosition

public void changeTransportPosition(boolean up,
                                    ITransport transport)
Moves a transport up or down.

Parameters:
up - Move up?
transport - The transport to move.

getAddresses

public String[] getAddresses()
Get the adresses of a component.

Specified by:
getAddresses in interface IMessageService
Returns:
The addresses of this component.

getAddressSchemes

public String[] getAddressSchemes()
Get addresses of all transports.

Specified by:
getAddressSchemes in interface IMessageService
Returns:
The address schemes of all transports.

getTransports

public ITransport[] getTransports()
Get the transports.

Returns:
The transports.

getSendManager

public MessageService.SendManager getSendManager(IComponentIdentifier cid)
Get a send target manager for addresses.


startService

public IFuture startService()
Start the service.

Specified by:
startService in interface IInternalService
Overrides:
startService in class BasicService

shutdownService

public IFuture shutdownService()
Called when the platform shuts down. Do necessary cleanup here (if any).

Specified by:
shutdownService in interface IInternalService
Overrides:
shutdownService in class BasicService

getMessageType

public MessageType getMessageType(String type)
Get the message type.

Specified by:
getMessageType in interface IMessageService
Parameters:
type - The type name.
Returns:
The message type.

addMessageListener

public void addMessageListener(IMessageListener listener)
Add a message listener.

Specified by:
addMessageListener in interface IMessageService
Parameters:
listener - The change listener.

removeMessageListener

public void removeMessageListener(IMessageListener listener)
Remove a message listener.

Specified by:
removeMessageListener in interface IMessageService
Parameters:
listener - The change listener.

internalDeliverMessage

protected void internalDeliverMessage(Map msg,
                                      String type,
                                      IComponentIdentifier[] receivers)
Deliver a message to the receivers.



Copyright © 2010. All Rights Reserved.