コマンドスクリプティングを利用することによって、ビジネスクラス全体をJavaで記述する代わりに、処理のフローをXML形式で記述しJavaの記述を必要な部分のみに限定することができます。
以下はコマンドスクリプティングで処理を記述した例です。
<?xml version="1.0" encoding="UTF-8"?>
<commandMap
    xmlns=http://interstage.fujitsu.com/schemas/uji/commandMap
    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
    xsi:schemaLocation="http://interstage.fujitsu.com/schemas/uji/commandMap
                        http://interstage.fujitsu.com/schemas/uji/commandmap.xsd">
  <config>
    <version>6.0</version>
  </config>
  <!-- 加算 sample1.BodyBean;add -->
  <entry bean="sample1.BodyBean" verb="add">
    <specSection>
      <term property="val1" op="ADD" operand="val2" target="result"/>
    </specSection>
    <copyValue bean="#加算を実行しました。" targetProperty="message"/>
    <setResponseBean pane="body" verb="resmode"/>
    <invoke name="setHead"/>
  </entry>
  <!-- 初期処理 ; -->
  <entry>
    <!-- BodyBeanインスタンス生成 -->
    <newBean cls="sample1.BodyBean" />
    <setResponseBean pane="body" verb="reqmode" />
    <invoke name="setHead"/>
  </entry>
  <!-- サブルーチン setHead -->
  <procedure name="setHead">
    <copyValue bean="uji.session" property="headBean" targetBean="hbean"/>
    <specSection bean="hbean" targetBean="hbean">
      <term property="count" op="ADD" operand="#1" target="count"/>
    </specSection>
    <setResponseBean pane="head" bean="hbean"/>
  </procedure>
</commandMap>コマンドスクリプティングでは、以下のメリットがあります。
処理のフローが明確になる
Javaの処理を細分化し、再利用を容易にする
修正時の再構築が不要で、変更が容易にできる
以下のような場合は、Javaで記述する必要があります。
分岐や条件を伴い、一連のフローで表現できない場合
実行性能を追求する場合
コマンドスクリプティングには、以下の機能があります。
入力値の検証
EJBの呼びだし
一般のクラスの呼びだし
XMLデータ仕様記述の呼びだし
データBeanの領域への対応付け
ログの出力
サブルーチンの定義
例外のキャッチ