I have a mule-config file where i have defined a "http inbound" to accept request on the corresponding URL.
Now what i have to to is to accept only a valid http inbound address and reject others.
So i have applied a "choice" filter to filter out valid URL's. (like the following) :
<flow name="abc">
<http:inbound-endpoint address="http://localhost:1212/jcore/abc"
transformer-refs="HttpParams" responseTransformer-refs="JavaObjectToJson"
contentType="application/json" encoding="UTF-8">
</http:inbound-endpoint>
<component class="main.java.com.jcore.abc"/>
<choice>
<when evaluator="header"
expression="INBOUND:http.request.path=/jcore/abc/a">
<vm:outbound-endpoint path="ToSomething"/>
</when>
<when evaluator="header"
expression="INBOUND:http.request.path=/jcore/abc/b">
<vm:outbound-endpoint path="ToSomething"/>
</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>
It is Working ..!!
But i have around 30 "Flows" like this one. And i want to apply "choice" filter like this on every flow.
Note : the matching URL will get changed in each case. Like in this case it is "/abc/a". In others , it is different
So, i wanted to know, if there is a way to avoid writing much of this redundant code and make a Spring bean with parameters OR sumthing else, that i can apply on each flow..??