message
Class MessageCentreImpl

java.lang.Object
  extended bymessage.MessageCentreImpl
All Implemented Interfaces:
MessageCentre, java.io.Serializable

public class MessageCentreImpl
extends java.lang.Object
implements MessageCentre

Storage and retrieval of portlet message mappings, and the messages. This implementation uses the Portlet session for storage, which restricts messaging to be between portlets in the same portlet application. Use of this class is only necessary when you want to modify message mappings in code; to simply load mappings from preferences, or send/receive messages, use MessageHelper.

See Also:
Serialized Form

Field Summary
protected  java.util.Map inputKeyMap
           
protected  java.util.Map msgBoxes
           
protected  java.util.Map outputKeyMap
           
 
Constructor Summary
MessageCentreImpl()
           
 
Method Summary
 void addInputMapping(MessageBoxKey key, MessageBoxKey source)
           
 void addInputMapping(java.lang.String portletID, java.lang.String name, MessageBoxKey source)
          Set a portlet message key => message box mapping.
 void addOutputMapping(MessageBoxKey key, MessageBoxKey target)
           
 void addOutputMapping(java.lang.String portletID, java.lang.String name, MessageBoxKey target)
          Add a portlet message key => message box mapping.
 MessageBoxKey findInputSource(MessageBoxKey key)
           
 MessageBoxKey findInputSource(java.lang.String portletID, java.lang.String name)
          Get the key of the source message box for this portletID+name combination.
 java.util.Set findOutputTargets(MessageBoxKey key)
           
 java.util.Set findOutputTargets(java.lang.String portletID, java.lang.String name)
          This will always return a Set which contains at least a key for a message box corresponding to the provided portletID+name (it always outputs to itself as well as any other registered mappings)
 java.lang.Object get(MessageBoxKey boxKey)
          Get message from this message box.
 java.lang.Object get(java.lang.String portletID, java.lang.String name)
          Get message for this portletID+name combination.
 java.util.Set getAllInputKeys()
           
 java.util.Set getAllOutputKeys()
           
 java.util.Map getBoxes()
           
 java.util.Set getInputKeys(java.lang.String portletID)
           
protected  java.util.Set getKeysWithNamespace(java.util.Collection searchKeys, java.lang.String ns)
           
 java.util.Set getOutputKeys(java.lang.String portletID)
           
 java.util.Set getPublicBoxKeys()
           
 void removeAllOutputMappings(MessageBoxKey key)
           
 void removeInputMapping(java.lang.String portletID, java.lang.String name)
          Remove a message key => message box mapping.
 void send(java.util.Set targetKeys, java.lang.Object message)
          Send message to these message boxes.
 void send(java.lang.String portletID, java.lang.String name, java.lang.Object message)
          Send message to this portletID+name combination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputKeyMap

protected java.util.Map inputKeyMap

outputKeyMap

protected java.util.Map outputKeyMap

msgBoxes

protected java.util.Map msgBoxes
Constructor Detail

MessageCentreImpl

public MessageCentreImpl()
Method Detail

addInputMapping

public void addInputMapping(java.lang.String portletID,
                            java.lang.String name,
                            MessageBoxKey source)
Set a portlet message key => message box mapping. This will overwrite any existing input mapping.

Specified by:
addInputMapping in interface MessageCentre
Parameters:
portletID - ID of the portlet which is receiving the input
name - (local) name of the portlet input, referred to in the portlet's code
source - the message box from which the portlet's input will read.

addInputMapping

public void addInputMapping(MessageBoxKey key,
                            MessageBoxKey source)
Specified by:
addInputMapping in interface MessageCentre

removeInputMapping

public void removeInputMapping(java.lang.String portletID,
                               java.lang.String name)
Remove a message key => message box mapping. As there can only be 1 mapping for each input, this will result in the default mapping: looking for a local portlet message of the same name.

Specified by:
removeInputMapping in interface MessageCentre

addOutputMapping

public void addOutputMapping(java.lang.String portletID,
                             java.lang.String name,
                             MessageBoxKey target)
Add a portlet message key => message box mapping. This will be in addition to any existing output mappings; the message will be copied to all mapped output targets.

Specified by:
addOutputMapping in interface MessageCentre
Parameters:
portletID - ID of the portlet which is sending the output
name - (local) name of the portlet output, referred to in the portlet's code
target - the message box to which the portlet's output will copy its message.

addOutputMapping

public void addOutputMapping(MessageBoxKey key,
                             MessageBoxKey target)
Specified by:
addOutputMapping in interface MessageCentre

removeAllOutputMappings

public void removeAllOutputMappings(MessageBoxKey key)
Specified by:
removeAllOutputMappings in interface MessageCentre

findOutputTargets

public java.util.Set findOutputTargets(java.lang.String portletID,
                                       java.lang.String name)
This will always return a Set which contains at least a key for a message box corresponding to the provided portletID+name (it always outputs to itself as well as any other registered mappings)

Specified by:
findOutputTargets in interface MessageCentre
Returns:
Set of MessageBoxKey's: the output keys registered for this portletID+name

findOutputTargets

public java.util.Set findOutputTargets(MessageBoxKey key)
Specified by:
findOutputTargets in interface MessageCentre

get

public java.lang.Object get(java.lang.String portletID,
                            java.lang.String name)
Get message for this portletID+name combination. If there is no mapping to a message box defined for the specified portletID+name, it tries to find a local message box of the same name. If there is no message, returns null.

Specified by:
get in interface MessageCentre

send

public void send(java.lang.String portletID,
                 java.lang.String name,
                 java.lang.Object message)
Send message to this portletID+name combination. It will be delivered to a local message box with this name. It will also be delivered to all message boxes for which mappings have been registered for this portletID+name using addMapping. It will replace any message already in the boxes.

Specified by:
send in interface MessageCentre

findInputSource

public MessageBoxKey findInputSource(java.lang.String portletID,
                                     java.lang.String name)
Get the key of the source message box for this portletID+name combination. If no mapping is found, returns a MessageBoxKey for this portletID+name.

Specified by:
findInputSource in interface MessageCentre

findInputSource

public MessageBoxKey findInputSource(MessageBoxKey key)
Specified by:
findInputSource in interface MessageCentre

get

public java.lang.Object get(MessageBoxKey boxKey)
Get message from this message box. If there is no message, returns null.

Specified by:
get in interface MessageCentre

send

public void send(java.util.Set targetKeys,
                 java.lang.Object message)
Send message to these message boxes. It will replace any message already in the boxes, or remove the box if 'message' is null.

Specified by:
send in interface MessageCentre
Parameters:
targetKeys - Set of MessageBoxKeys to which the message should be sent

getInputKeys

public java.util.Set getInputKeys(java.lang.String portletID)
Specified by:
getInputKeys in interface MessageCentre

getOutputKeys

public java.util.Set getOutputKeys(java.lang.String portletID)
Specified by:
getOutputKeys in interface MessageCentre

getPublicBoxKeys

public java.util.Set getPublicBoxKeys()
Specified by:
getPublicBoxKeys in interface MessageCentre

getKeysWithNamespace

protected java.util.Set getKeysWithNamespace(java.util.Collection searchKeys,
                                             java.lang.String ns)

getBoxes

public java.util.Map getBoxes()
Specified by:
getBoxes in interface MessageCentre

getAllInputKeys

public java.util.Set getAllInputKeys()
Specified by:
getAllInputKeys in interface MessageCentre

getAllOutputKeys

public java.util.Set getAllOutputKeys()
Specified by:
getAllOutputKeys in interface MessageCentre