java - How to filter a single URI from a group of URI's in a Mule inbound endpoint? -
i have following code configure jersey service @ "http://localhost:8080/alpha":
*** mule config *** <flow name="flow1"> <inbound-endpoint address="http://localhost:8080/" exchange-pattern="request-response" /> <jersey:resources> <component> <singleton-object class="com.address.flow1resource"/> </component> </jersey:resources> </flow> *** flow1resource.java *** @path("/alpha") public class flow1resource {...}
i want add new inbound-endpoint handles addresses under "http://localhost:8080" except "http://localhost:8080/alpha" (e.g. "http://localhost:8080/beta"). these new addresses need single jersey resource. example:
*** mule config *** <flow name="flow1"> <inbound-endpoint address="http://localhost:8080/" exchange-pattern="request-response" /> <jersey:resources> <component> <singleton-object class="com.address.flow1resource"/> </component> </jersey:resources> </flow> <flow name="flow2"> <inbound-endpoint address="http://localhost:8080/*" exchange-pattern="request-response" /> <jersey:resources> <component> <singleton-object class="com.address.flow2resource"/> </component> </jersey:resources> </flow> *** flow1resource.java *** @path("/alpha") public class flow1resource {...} *** flow2resource.java *** @path("/") public class flow2resource { @path("beta") public void beta() {...} @path("gamma") public void gamma() {...} ... }
how set mule inbound-endpoint capture addresses (i.e. beta & gamma), except specific url (i.e. alpha).
i know can hardcode paths in mule config, result in duplication because each address (i.e. beta & gamma) need own flow , resource code, similar.
please note used "http://localhost:8080/*" in code above conceptual example. not work.
--- update ---
i forgot mention beta , gamma uri's have security associated them using:
<http:inbound-endpoint ...> <spring-security:http-security-filter realm="mule-realm"/> </http:inbound-endpoint>
i tried adding 'choice' element endpoint, complained spring-security invalid inside choice decision structure.
a solution need accommodate feature.
an easy way achieve goal combine flows 1 , use choice router. in configuration flow following:
<flow name="stackoverflowflow1" doc:name="stackoverflowflow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="http" /> <logger level="error" /> <choice doc:name="choice"> <when expression="#[message.inboundproperties['http.request'] == '/']"> <processor-chain> <logger message="/ invoked " level="error" /> <jersey:resources doc:name="rest"> <component class="resource" /> </jersey:resources> </processor-chain> </when> <otherwise> <processor-chain> <logger message="otherwise invoked " level="error" /> <jersey:resources doc:name="rest"> <component class="applicationsresource" /> </jersey:resources> </processor-chain> </otherwise> </choice> </flow>
as can imagine can take decision on path or on top of other http header.
you can find router documentation here , list of common http properties can use make choices here
Comments
Post a Comment