synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From indika kumara <indika.k...@gmail.com>
Subject Re: Regarding the switch mediator's regex
Date Tue, 08 Nov 2011 23:43:35 GMT
Hi Amila,

I think if "matcher.find()" worked "correctly" for the strings worked for
"matcher.matches()", there would not be any issue. Indeed, It shouldn't be
. BTW, I do not know whether any kind of notable performance difference is
there.

Thanks,

Indika

On Wed, Nov 9, 2011 at 9:59 AM, Amila Maha Arachchi <amilam@wso2.com> wrote:

> Hi all,
>
> I wanted to use the switch mediator based on the From address of an email
> (using the mail transport). I was using the following configuration.
>
>         <switch source="$trp:From">
>             <case regex="^[\w\W]*(amilam@wso2.com)[\w\W]*$">
>                <xslt key="MyTransform" />
>             </case>
>             <default>
>                <log level="custom">
>                   <property name="sender"
> expression="get-property('transport', 'From')" />
>                </log>
>             </default>
>
> </switch>modules/core/src/main/java/org/apache/synapse/config/xml/SwitchCase.java
>
> I had to use the above mentioned regex because the From address is
> something like "Amila Maharachchi <amilam@wso2.com>". But, normally if i
> put amilam@wso2.com as the regex it should find a match.
>
> Then I checked the SwitchMediator code and found out that it is using
> matcher.matches() method. This checkes whether the whole string is matching
> the regex provided (not a part of the string). But, if we use
> matcher.find() it will look for a matching subsequence within the string.
>
> Is there any affect to the Switch mediation process in using the
> matcher.find() rather than matcher.matches() ?
>
> Thanks,
> AmilaM.
>

Mime
View raw message