servicemix-exec has been edited by Lars Heinemann (May 07, 2009).

(View changes)

Content:

ServiceMix Exec

ServiceMix Exec component is used to invoke commands (executables, shell commands, shell scripts, ...). The command can be static (defined in the component endpoint descriptor) or dynamic (provided in the incoming message, including arguments).

Availability

Note that this component is now only available as snapshot, not yet included in a ServiceMix release.

Installation

Simply drop the servicemix-exec installer zip in an hotdeploy directory monitored by ServiceMix.

How it works

ServiceMix Exec service engine acts as a provider. It supports all MEP.

When used with an InOnly MEP, the Exec component executes the command and set the exchange in DONE status.

When used with an InOut MEP, the Exec components executes the command and get the command output buffer. The command output is put in the out message and send back in the exchange.

Exec in message format

<message>
  <command>ls</command>
  <arguments>
    <argument>-l</argument>
    <argument>/tmp</argument>
  </arguments>
</message>

If the in message doesn't contain the command tag, Exec component uses the command attribute provided in the xbean.xml. If no command is provided in the in message and in the xbean.xml, the component throws an exception and the exchange fails.

You can support any message format by defining your own exec marshaler implementation. The endpoint supports a marshaler attribute where you can define your class that implements the ExecMarshalerSupport interface.

Exec out message format

When used with an InOut MEP, the Exec return the command execution output into the out message. The out message content looks like:

<result>
<exitcode>0</exitcode>
<output><![CDATA[
total 6729
-rw------- 1 jb       jb   1693752 2009-04-09 09:07 f9G0lWzx.tar.part
-rw-r--r-- 1 jb       jb         8 2009-03-27 18:27 gnome-session-manager
srwxr-xr-x 1 jb       jb         0 2009-03-26 10:56 gnome-system-monitor.jb.3619273851
drwxr-xr-x 2 jb       jb      1024 2009-04-23 08:43 hsperfdata_jb
drwxr-xr-x 2 jboss    java    1024 2009-04-17 12:46 hsperfdata_jboss
drwxr-xr-x 2 weblogic java    1024 2009-04-17 09:40 hsperfdata_weblogic
-rw-r--r-- 1 jb       jb       870 2009-03-26 10:59 jbi12672.zip
-rw-r--r-- 1 jb       jb       870 2009-03-26 10:59 jbi12673.zip
]]></output>
<error><![CDATA[
]]></error>
</result>

Endpoint

The Exec endpoint can be very simple, waiting for command contained in the in message:

<beans xmlns="http://servicemix.apache.org/exec/1.0"
       xmlns:test="http://test">
  <exec:endpoint service="test:MyService"
                 endpoint="MyExec"/>
</beans>

You can define a fallback command if the incoming doesn't provide a command:

<beans xmlns="http://servicemix.apache.org/exec/1.0"
       xmlns:test="http://test">
   <exec:endpoint service="test:MyService"
                  endpoint="MyExec"
                  command="date"/>
</beans>
Endpoint attributes
Name Type Description Required
endpoint String JBI Endpoint name no (will be auto-generated if not specified)
interfaceName QName Interface QName implemented by the JBI endpoint no (will be auto-generated if not specified)
service QName JBI Service name no (will be auto-generated if not specified)
command String Fallback command Command that will be executed if the in message doesn't provide a command.
marshaler ExecMarshalerSupport Marshaler to use to parse the incoming message and construct the exec command. no (DefaultExecMarshaler by default)

Reply via email to