This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata

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.

  • No labels