org.ws4d.java.dispatch
Class DefaultMessageSelector

java.lang.Object
  extended by org.ws4d.java.dispatch.DefaultMessageSelector
All Implemented Interfaces:
MessageSelector

public class DefaultMessageSelector
extends java.lang.Object
implements MessageSelector

This class allows matching messages according to their message type or the address of the endpoint they are addressed to.

Selection criteria can be specified in a generic way by means of the setSelectionProperty(int, List) method. This method allows declaration of expected values for each property in question. A message will match those criteria only if it has matching values for all the given properties.


Field Summary
static int ENDPOINT_REFERENCE
          Property denoting a selection based on the target endpoint reference of the message (i.e. its WS-Addressing [destination] property).
static int MESSAGE_TYPE
          Property denoting a selection based on the message type.
 
Constructor Summary
DefaultMessageSelector()
          Create a new default message selector.
 
Method Summary
 boolean matches(Message msg)
          Decides whether the given message meets the selection criteria of this message selector instance.
 void setSelectionProperty(int property, List values)
          Adds a "selection rule" by specifying a message property and declaring a list of allowed values for this property.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_TYPE

public static final int MESSAGE_TYPE
Property denoting a selection based on the message type.

See Also:
Constant Field Values

ENDPOINT_REFERENCE

public static final int ENDPOINT_REFERENCE
Property denoting a selection based on the target endpoint reference of the message (i.e. its WS-Addressing [destination] property). The [destination] property is actually an IRI consisting of the [address] property of the target's endpoint reference. Nevertheless, when specifying a selection rule by means of setSelectionProperty(int, List) method, the provided List values is expected to contain EndpointReference instances rather than URIs.

See Also:
Constant Field Values
Constructor Detail

DefaultMessageSelector

public DefaultMessageSelector()
Create a new default message selector.

Method Detail

matches

public boolean matches(Message msg)
Description copied from interface: MessageSelector
Decides whether the given message meets the selection criteria of this message selector instance.

Specified by:
matches in interface MessageSelector
Parameters:
msg - the message to decide upon
Returns:
true, if the configured selection rules accept the message, false otherwise

setSelectionProperty

public void setSelectionProperty(int property,
                                 List values)
Adds a "selection rule" by specifying a message property and declaring a list of allowed values for this property. Each message, which has a value for this property that is contained within values, will be considered for a match. In case the provided list of values is null or empty, a message will always match regardless of its actual value for the property.

Calling this method more than once with the same property but different values overwrites (i.e. replaces) previously specified values for that property.

Parameters:
property - the property to set expected values for; allowed values are MESSAGE_TYPE and ENDPOINT_REFERENCE
values - a list of values the property may take in order to get matched by this selector; if empty, then any value of the property would match
Throws:
java.lang.IllegalArgumentException - if propertyType is neither MESSAGE_TYPE nor ENDPOINT_REFERENCE