This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

POJOCommand Mediator

Tip

This mediator implements the popular command pattern.

The POJOCommand (or Command) Mediator creates an instance of the specified command class, which may implement the org.apache.synapse.Command interface or should have a public void method public void execute(). If any properties are specified, the corresponding setter methods are invoked on the class before each message is executed. It should be noted that a new instance of the POJOCommand class is created to process each message. After execution of the POJOCommand Mediator, depending on the action attribute of the property, the new value returned by a call to the corresponding getter method is stored back to the message or to the context.

The action attribute may specify whether this behavior is expected or not via the Read, Update and ReadAndUpdate properties.



Syntax

<pojoCommand name="class-name">
   (
   <property name="string" value="string"/> |
   <property name="string" context-name="literal" [action=(ReadContext | UpdateContext | ReadAndUpdateContext)]>
    (either literal or XML child)
   </property> |
   <property name="string" expression="xpath" [action=(ReadMessage | UpdateMessage | ReadAndUpdateMessage)]/>
   ) *
 </pojoCommand>

UI Configuration

You can specify the Command Mediator implementation class and load it by clicking on the "LoadClass" button. Once you load the POJOCommand class, you'll see the Command Mediator configuration options.

Command Mediator configuration descriptions:

  • Class Name - The class name of the Pojo class. You have to give the fully qualified name of the class and click the "Load Class" button.
  • Properties of the POJOCommand mediator -  After you click "Load Class" and if it is a valid Pojo Class, you will see the properties of the POJO class in a table with the following fields.
    • Property Name - Name of the property. This will be automatically loaded from the class.
    • Read Info - The value to set for the property. You can choose the value from either of following sources:
      • Value - A Static value.
      • Message - Reads a value from the incoming message. You can provide the XPath expression to execute on the message in the "Value" text field.
      • Context - Reads a value from the Message context properties. You can provide the property key in the "Value" text field.
    • Update Info - Specifies the action to be executed on the property value. You can choose following actions:
      • NONE - No activity.
      • Message - Updates the message. You can provide the XPath expression of the element you want to update in the "Value" text field.
      • Context - Updates the properties (Message context). You can give the property key in the "Value" text field.
    • Action - Link to delete the unused properties from the list.

Note

You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.