<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
      "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <title>WSO2 ESB - PojoCommand Mediator </title>
  <link href="css/esb-docs.css" rel="stylesheet" />
  <link href="styles/dist-docs.css" rel="stylesheet" type="text/css"
  media="all" />
</head>

<body>
<h2>PojoCommand Mediator</h2>

<p>This mediator implements the popular <a href="http://en.wikipedia.org/wiki/Command_pattern">command pattern.</a></p>

<p>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. </p>

<h3>Syntax</h3>
<pre xml:space="preserve"> &lt;pojoCommand name="class-name"&gt;
   (
   &lt;property name="string" value="string"/&gt; |
   &lt;property name="string" context-name="literal" [action=(ReadContext | UpdateContext | ReadAndUpdateContext)]&gt;
    (either literal or XML child)
   &lt;/property&gt; |
   &lt;property name="string" expression="xpath" [action=(ReadMessage | UpdateMessage | ReadAndUpdateMessage)]/&gt;
   ) *
 &lt;/pojoCommand&gt;</pre>

<h3>UI Configuration</h3>
  <div class="image">
    <img src="../pojoCommand-mediator/docs/images/add-pojocommand.png" alt=""/>
    <p>
      Figure 1: Adding a PojoCommand mediator
    </p>
  </div>
  <p>
  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.</p>
  <div class="image">
    <img src="../pojoCommand-mediator/docs/images/command_mediator_screenshot.png" alt=""/>
    <p>
      Figure 2: Command mediator configuration options
    </p>
  </div>
  <p>
  Command mediator configuration descriptions
  </p>
  <ul>
    <li>
        Class Name: The class name of the Pojo class. You have to give the fully qualified name of the class and click
        "Load Class" button. 
    </li>
    <li>
        Properties of the POJOCommand mediator: After you click the "Load Class" and if it is a valid Pojo Class
        you will see the properties in the POJO class in a table with following fields.
        <ul>
            <li>
                Property Name - Name of the property. This will be automatically loaded from the class.
            </li>
            <li>
                Read Info - The value to set for the property. You can choose the value from eaither of following sources
                <ul>
                    <li>Value - A Static value </li>
                    <li>Message - Read a value from the incomming message. You can provide the xpath expression to
                        execute on the message in the 'Value' text field. </li>
                    <li>Context - Read a value from the Message context properties. You can provide the property key
                        in the 'Value' text field. </li>
                </ul>
            </li>
            <li>
                Update Info - Specify the action to do with reading the property value. You can choose following actions.
                <ul>
                    <li>NONE - No activitly </li>
                    <li>Message - Update the message. You can provide the xpath expression of the element you want to
                        update in the "Value" text field. </li>
                    <li>Context - Update the properties (Message context). You can give the property key in the 'Value' text field. </li>
                </ul>
            </li>
        </ul>
    </li>
  </ul>

    
    
</body>
</html>
