Mule にフローがあります。これには、ポート番号とアドレスをリッスンする HTTP インバウンドが含まれています。ここで、HTTP インバウンドのアドレスに従って、それを別の VM にルーティングする必要があります。
この部分は以下のようにしました:
<flow name="MetaService">
<http:inbound-endpoint address="http://localhost:8000/jcore/meta"
transformer-refs="HttpParams" responseTransformer-refs="JavaObjectToJson">
</http:inbound-endpoint>
<component>
<spring-object bean="MetaServiceBean"/>
</component>
<choice>
<when evaluator="header" expression="INBOUND:http.request.path=/jcore/meta">
<vm:outbound-endpoint path="ToJSON" exchange-pattern="request-response"/>
</when>
<when evaluator="header" expression="INBOUND:http.request.path=/jcore/meta.json">
<vm:outbound-endpoint path="ToJSON" exchange-pattern="request-response"/>
</when>
<when evaluator="header" expression="INBOUND:http.request.path=/jcore/meta.xml">
<vm:outbound-endpoint path="ToXML" exchange-pattern="request-response"/>
</when>
<otherwise>
<message-properties-transformer>
<add-message-property key="http.status" value="404"/>
</message-properties-transformer>
<expression-transformer>
<return-argument evaluator="string"
expression="{"Exception": "Could not Render the Request. URL may be wrong"}"/>
</expression-transformer>
</otherwise>
</choice>
</flow>
アドレスの末尾に「.json」または「.xml」がある場合、それを VM にルーティングし、URL が無効な場合は HTTP 404 エラーを発生させます。
しかし、問題は: 有効/無効な URL を最後ではなく、フローの開始時にチェックする必要があります..また、それらを最後にルーティングする必要があります (示されているように URL にアクセスします)..!!
開始時に選択コンポーネントを使用することもできますが、それでは冗長になります..!!
良いオプションはありますか..??