WSO2 ESB - PojoCommand Mediator

PojoCommand Mediator

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 POJO Command class is created to process each message processed. After execution of the POJO Command 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 behaviour 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

Figure 1: Adding a PojoCommand mediator

Clicking on the command mediator created as shown in figure 1 will open up the command mediator specific options. You can specify the command mediator implementaion class and load it by clicking LoadClass button. Once you load the pojo command class you'll see the command mediator configuration options as in figure2.

Figure 2: Command mediator configuration options

Command mediator configuration descriptions

Example