java - In mule3, how to set a custom expression for choice-when router? -


i new mule, want validate timestamp , nonce parameter uri preventing replay attack. use choice-when router, when timestamp , nonce valid(the validation process complex), forward request backend rest service, otherwise return error code , message. found lot of mel usage choice-when, can define custom expression use java? , there example available? uri example:

http://muledemo.org/ci2/ni/del?id=0xe413&timestamp=1376022133&nonce=a03ed9c 

code snippets:

<choice doc:name="choice">   <when expression="???how call java validator???">   </when>   <otherwise>     <processor-chain doc:name="processor chain">       <echo-component doc:name="echo" />       <http:outbound-endpoint exchange-pattern="request-response" method="post"         address="http://localhost:8081#[message.inboundproperties['http.request']]" doc:name="http" />     </processor-chain>   </otherwise> </choice> 

edit:

xml config:

<spring:beans>   <spring:bean id="replayattackcheck" class="org.jamee.demo.mule.replayattackcheck"/> </spring:beans>  ... ...  <when expression="#[replayattackcheck.validate(payload)]">   <expression-component doc:name="check required params"><![cdata[payload="{\"code\":\"pa002\", \"message\":\"timestamp or nonce illegal\"}"]]>   </expression-component> </when> 

error log:

error 2013-08-09 14:32:39,090 [[demo.router].connector.http.mule.default.receiver.02] org.mule.exception.defaultmessagingexceptionstrategy:  ******************************************************************************** message               : execution of expression "replayattackcheck.validate(payload)" failed. (org.mule.api.expression.expressionruntimeexception). message payload of type: hashmap code                  : mule_error--2 -------------------------------------------------------------------------------- exception stack is: 1. [error: unresolvable property or identifier: replayattackcheck] [near : {... replayattackcheck.validate(pay ....}] 

correct mel syntax:

<when expression="#[app.registry.replayattackcheck.validate(payload)]"> 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -