以下の手順を実行すると、新規にトランスポートを作成するための、全てのJavaテンプレート・ファイルを生成します。テンプレート・ファイルの利用方法はコメントとしてファイルに記述されます。
トランスポート原型は、ESB Muleのmavenリポジトリから入手できます。
MavenにBobberPlusを追加
MavenがBobberPlusプラグインを見つけることができるように、settings.xmlファイル(通常は$HOME/.m2ディレクトリ下にある)を修正します。
<settings>
...
<pluginGroups>
<pluginGroup>org.mule.tools</pluginGroup>
</pluginGroups>
...
</settings>
テンプレートの生成
コードを生成するディレクトリに移動します。(既存のmavenプロジェクトと統合する場合は(標準のESB Muleトランスポート・ディレクトリはsvnからダウンロードすることができます)、正しい「親」を指定するようにpomを修正して、親のpomにモジュールを追加します。
> cd ディレクトリ
テンプレートを生成。複数の質問をした後にファイルを生成します。(以下のコマンドで「\」は行が継続していることを表しています。)
> mvn bobberplus:create -DarchetypeGroupId=org.mule.tools \
-DarchetypeArtifactId=mule-transport-archetype -DarchetypeVersion=1.4.1-SNAPSHOT \
-DgroupId=yourGroupId -DartifactId=yourArtifactId -Dversion=yourVersion
[INFO] Scanning for projects...
[...lots of output snipped...]
[INFO] Please enter the values for the following archetype variables:
[INFO] MuleVersion:
********************************************************************************
Which version of Mule are you working with?
[default: 1.4]
********************************************************************************
1.4.1-SNAPSHOT
[INFO] TransportName:
********************************************************************************
The protocol name to use for the transport (lower case) i.e. jms or http
[default: myTransport]
********************************************************************************
foo
[INFO] TransportDescription:
********************************************************************************
Provide a description of what the transport does:
[default: ]
********************************************************************************
Stuff. Lots of stuff.
[INFO] Receiver:
********************************************************************************
Can the transport receive inbound requests? [y] or [n]
[default: y]
********************************************************************************
y
[INFO] PollingMessageReceiver:
********************************************************************************
Does the Message Receiver need to poll the underlying resource? [y] or [n]
[default: n]
********************************************************************************
y
[INFO] Streaming:
********************************************************************************
Does this transport support Streaming? [y] or [n]
[default: n]
********************************************************************************
y
[INFO] InboundTransformer:
********************************************************************************
If this transport will have a default inbound transformer, enter the name of the
transformer? (i.e. JmsMessageToObject)
[default: n]
********************************************************************************
FooMessageToObject
[INFO] Dispatcher:
********************************************************************************
Can the transport dispatch outbound requests?
[default: y]
********************************************************************************
y
[INFO] OutboundTransformer:
********************************************************************************
If this transport will have a default outbound transformer, enter the name of the
transformer? (i.e. ObjectToJmsMessage)
[default: n]
********************************************************************************
ObjectToFooMessage
[INFO] Transactions:
********************************************************************************
Does this transport support transactions? [y] or [n]
[default: n]
********************************************************************************
y
[INFO] CustomTransactions:
********************************************************************************
Does this transport use a non-JTA Transaction manager? [y] or [n]
(i.e. needs to wrap proprietary transaction management)
[default: n]
********************************************************************************
y
[INFO] EndpointBuilder:
********************************************************************************
What type of Endpoints does this transport use?
- [r]esource endpoints (i.e. jms://my.queue)
- [u]rl endpoints (i.e. http://localhost:1234/context/foo?param=1)
- [s]ocket endpoints (i.e. tcp://localhost:1234)
- [c]ustom - parse your own
[default: r]
********************************************************************************
c
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating Archetype: mule-transport-archetype:1.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: packagePath = yourGroupId
[INFO] Parameter: Receiver = y
[INFO] Parameter: Dispatcher = y
[INFO] Parameter: InboundTransformer = FooMessageToObject
[INFO] Parameter: MuleVersion = 1.4.1-SNAPSHOT
[INFO] Parameter: TransportName = foo
[INFO] Parameter: CustomTransactions = y
[INFO] Parameter: version = yourVersion
[INFO] Parameter: Transactions = y
[INFO] Parameter: groupId = yourGroupId
[INFO] Parameter: PollingMessageReceiver = y
[INFO] Parameter: EndpointBuilder = c
[INFO] Parameter: packageName = yourGroupId
[INFO] Parameter: Streaming = y
[INFO] Parameter: OutboundTransformer = ObjectToFooMessage
[INFO] Parameter: basedir = /home/andrew/projects/mule/trunk/mule-sandbox/transports
[INFO] Parameter: package = yourGroupId
[INFO] Parameter: TransportDescription = Stuff. Lots of stuff.
[INFO] Parameter: artifactId = yourArtifactId
[...lots of output snipped...]