You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mounir Benzid <mb...@meetingmasters.de> on 2012/03/07 18:39:45 UTC

Does the orrder of wildcard-annotated methods effects greediness?

Here is a simple example showing two methods in the given order

     
/*******************************************************************************************/
     @Override
     @Action(value="/do/some/specificstuff/{thing}", 
results={@Result(location = "result.jsp")}),
     public String execute() throws Exception {...}


     
/*******************************************************************************************/
     @Override
     @Action(value="/do/some/{thing}", results={@Result(location = 
"result.jsp")}),
     public String input() throws Exception {...}



Now if the request contains myApp/do/some/specificstuff/eat


which action will fire? I my case it's the input() method but it really 
should be the execute()  method.
The parameter "thing" in the second annotation then equals 
"specificstuff/eat"


Is it possible to control the "greediness" of the patternmatcher? Using 
XML notation one could simply control
this behaviour by  reordering the <action> tags.

Thanks

- Mounir



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Maurizio Cucchiara <mc...@apache.org>.
Not sure it works, the action definitions does not belong necessarily on
the same java class.
So it could not be so easy to choose the right priority value.

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 19 March 2012 12:21, Mounir Benzid <mb...@meetingmasters.de> wrote:

> matchPriority

Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 19.03.2012 09:28, schrieb Maurizio Cucchiara:
> Twitter     :http://www.twitter.com/m_cucchiara
> G+          :https://plus.google.com/107903711540963855921
> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
> We could implement a "most specific take a precedence along the path"
> policy (though I don't know how ATM :) ), could you please file an issue on
> jira [1]?
> [1] https://issues.apache.org/jira/browse/WW
Definitely not the best or most elegant solution, but some sort of 
@matchPriority(A)

where A is a pos. int value (or zero) and if A > B, A fires before B

could do the trick (for now)


Usage scenario:

@Action(value="some/{stuff}", results={@Result(location ="result.jsp")})
@matchPriority(0)
public String action1() {....}

@Action(value="some/useful/{stuff}", results={@Result(location 
="result.jsp")})
@matchPriority(1)
public String action2() {....}

This way the second action method fires before the first one.


Mounir

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Maurizio Cucchiara <mc...@apache.org>.
Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara
We could implement a "most specific take a precedence along the path"
policy (though I don't know how ATM :) ), could you please file an issue on
jira [1]?
[1] https://issues.apache.org/jira/browse/WW


On 19 March 2012 08:49, Mounir Benzid <mb...@meetingmasters.de> wrote:

> Am 18.03.2012 20:15, schrieb Maurizio Cucchiara:
>
>  I don't know how to get this work with annotations, but it looks like that
>> it works using xml (you can control greediness sorting by more specific
>> expression)
>>
>> Twitter     :http://www.twitter.com/m_**cucchiara<http://www.twitter.com/m_cucchiara>
>> G+          :https://plus.google.com/**107903711540963855921<https://plus.google.com/107903711540963855921>
>> Linkedin    :http://www.linkedin.com/in/**mauriziocucchiara<http://www.linkedin.com/in/mauriziocucchiara>
>>
>> Maurizio Cucchiara
>>
> It could be sufficiant if the order of the regex pattern in the  java
> class file matters or
> alternativly one should be able to make the pattern matcher itself
> nongreedy by using the ? op.
> I'm not sure though weather the ? notation will work this way.
>
>
> Mounir
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 18.03.2012 20:15, schrieb Maurizio Cucchiara:
> I don't know how to get this work with annotations, but it looks like that
> it works using xml (you can control greediness sorting by more specific
> expression)
>
> Twitter     :http://www.twitter.com/m_cucchiara
> G+          :https://plus.google.com/107903711540963855921
> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
It could be sufficiant if the order of the regex pattern in the  java 
class file matters or
alternativly one should be able to make the pattern matcher itself 
nongreedy by using the ? op.
I'm not sure though weather the ? notation will work this way.

Mounir

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Maurizio Cucchiara <mc...@apache.org>.
I don't know how to get this work with annotations, but it looks like that
it works using xml (you can control greediness sorting by more specific
expression)

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 8 March 2012 14:53, Mounir Benzid <mb...@meetingmasters.de> wrote:

> Am 08.03.2012 14:39, schrieb Mounir Benzid:
>
>  Ok after finally getting my repositories straight I started my struts
>> junit testcase against the nighty build that is 2.3.2 SNAPSHOT
>>
>> The results are the same though.
>>
>> For the time being I'm going to change my url patterns to avoid the
>> ambiguity.
>>
>> cheers
>> - Mounir
>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>  Just for the record. My repositories have been installed correctly and
> running against the nightly builds for some time now.
> (I checked our local nexus repository and just found the apache snapshot
> respository was already configured there)
>
> Ok, that's all for now. Thanks again..
>
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 08.03.2012 14:39, schrieb Mounir Benzid:
> Ok after finally getting my repositories straight I started my struts 
> junit testcase against the nighty build that is 2.3.2 SNAPSHOT
>
> The results are the same though.
>
> For the time being I'm going to change my url patterns to avoid the 
> ambiguity.
>
> cheers
> - Mounir
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Just for the record. My repositories have been installed correctly and 
running against the nightly builds for some time now.
(I checked our local nexus repository and just found the apache snapshot 
respository was already configured there)

Ok, that's all for now. Thanks again..



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Ok after finally getting my repositories straight I started my struts 
junit testcase against the nighty build that is 2.3.2 SNAPSHOT

The results are the same though.

For the time being I'm going to change my url patterns to avoid the 
ambiguity.

cheers
- Mounir



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 08.03.2012 14:15, schrieb Łukasz Lenart:
> 2012/3/8 Mounir Benzid<mb...@meetingmasters.de>:
>> To be 100% ubersure. This is how I configured mvn struts dependency
> Did you specify a repository in pom ?
>
>      <repositories>
>          <repository>
>              <id>apache-snapshot</id>
>              <name>ASF Snapshots</name>
>              <url>https://repository.apache.org/content/groups/snapshots/</url>
>              <layout>default</layout>
>              <releases>
>                  <enabled>false</enabled>
>              </releases>
>              <snapshots>
>                  <enabled>true</enabled>
>              </snapshots>
>          </repository>
>      </repositories>
>
>
> Regards
Shoot! Thanks for reminding me.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Łukasz Lenart <lu...@googlemail.com>.
2012/3/8 Mounir Benzid <mb...@meetingmasters.de>:
> To be 100% ubersure. This is how I configured mvn struts dependency

Did you specify a repository in pom ?

    <repositories>
        <repository>
            <id>apache-snapshot</id>
            <name>ASF Snapshots</name>
            <url>https://repository.apache.org/content/groups/snapshots/</url>
            <layout>default</layout>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 08.03.2012 14:01, schrieb Łukasz Lenart:
> 2012/3/8 Mounir Benzid<mb...@meetingmasters.de>:
>> Can you please tell me how to access your nightly builds through maven?
>> https://builds.apache.org/job/Struts2/lastStableBuild/org.apache.struts$struts2-assembly/
> Here
> https://repository.apache.org/content/groups/snapshots
>
>
> Regards
To be 100% ubersure. This is how I configured mvn struts dependency

<struts2-snapshot.version>2.3.2-SNAPSHOT</struts2-snapshot.version>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2-snapshot.version}</version>
</dependency>

So I'm already accessing the nightly builds. rigth?




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Łukasz Lenart <lu...@googlemail.com>.
2012/3/8 Mounir Benzid <mb...@meetingmasters.de>:
> Can you please tell me how to access your nightly builds through maven?
> https://builds.apache.org/job/Struts2/lastStableBuild/org.apache.struts$struts2-assembly/

Here
https://repository.apache.org/content/groups/snapshots


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 07.03.2012 19:17, schrieb Maurizio Cucchiara:
> In addition to what Dave suggested, could you check it against the latest
> nightly build? IIRC I made some change recently on wildcard support.

Can you please tell me how to access your nightly builds through maven?
https://builds.apache.org/job/Struts2/lastStableBuild/org.apache.struts$struts2-assembly/

or should I svn and build locally?

At the moment I'm developing against 2.3.2-snapshots

cheers
> Twitter     :http://www.twitter.com/m_cucchiara
> G+          :https://plus.google.com/107903711540963855921
> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
>
>
> On 7 March 2012 18:39, Mounir Benzid<mb...@meetingmasters.de>  wrote:
>
>> Here is a simple example showing two methods in the given order
>>
>>     /***************************************************************
>> **********************************/
>>     @Override
>>     @Action(value="/do/some/**specificstuff/{thing}",
>> results={@Result(location = "result.jsp")}),
>>     public String execute() throws Exception {...}
>>
>>
>>     /***************************************************************
>> **********************************/
>>     @Override
>>     @Action(value="/do/some/{**thing}", results={@Result(location =
>> "result.jsp")}),
>>     public String input() throws Exception {...}
>>
>>
>>
>> Now if the request contains myApp/do/some/specificstuff/**eat
>>
>>
>> which action will fire? I my case it's the input() method but it really
>> should be the execute()  method.
>> The parameter "thing" in the second annotation then equals
>> "specificstuff/eat"
>>
>>
>> Is it possible to control the "greediness" of the patternmatcher? Using
>> XML notation one could simply control
>> this behaviour by  reordering the<action>  tags.
>>
>> Thanks
>>
>> - Mounir
>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


-- 
Mounir Benzid
Systementwickler / EDV

meetingmasters.de
meetings meisterhaft managen

· Unabhängige Vermittlung von Tagungshotels
· Online-Hotelreservierungssystem zur Integration in die Veranstaltungs-Webseite
· Webbasiertes Veranstaltungs- und Teilnehmermanagement
· E-Procurement für den Tagungshoteleinkauf
· Webbasierte Anfrage und Verhandlung von Firmenraten

Max-Planck-Straße 22
D-54296 Trier

fon +49 (0)651-145789-38
fax +49 (0)651-145789-20

www.meetingmasters.de
mb@meetingmasters.de


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Maurizio Cucchiara <mc...@apache.org>.
In addition to what Dave suggested, could you check it against the latest
nightly build? IIRC I made some change recently on wildcard support.

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 7 March 2012 18:39, Mounir Benzid <mb...@meetingmasters.de> wrote:

> Here is a simple example showing two methods in the given order
>
>    /***************************************************************
> **********************************/
>    @Override
>    @Action(value="/do/some/**specificstuff/{thing}",
> results={@Result(location = "result.jsp")}),
>    public String execute() throws Exception {...}
>
>
>    /***************************************************************
> **********************************/
>    @Override
>    @Action(value="/do/some/{**thing}", results={@Result(location =
> "result.jsp")}),
>    public String input() throws Exception {...}
>
>
>
> Now if the request contains myApp/do/some/specificstuff/**eat
>
>
> which action will fire? I my case it's the input() method but it really
> should be the execute()  method.
> The parameter "thing" in the second annotation then equals
> "specificstuff/eat"
>
>
> Is it possible to control the "greediness" of the patternmatcher? Using
> XML notation one could simply control
> this behaviour by  reordering the <action> tags.
>
> Thanks
>
> - Mounir
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 07.03.2012 18:48, schrieb Dave Newton:
> I'm wondering if `struts.mapper.alwaysSelectFullNamespace` would affect
> this.
>
> Dave

Again the same code  (almost the same I removed the leading / in 
value="..." and added the namespace annotation to the example)

@Namespace("/do")
public class CRUDAction  {

    @Override
    @Action(value="some/specificstuff/{thing}",results={@Result(location = "result.jsp")})
    public String execute() throws Exception {...}


    @Override
    @Action(value="some/{thing}", results={@Result(location ="result.jsp")})
    public String input() throws Exception {...}

}


struts.mapper.alwaysSelectFullNamespace=true

and http://localhost/myApp/do/some/specificstuff/eat

gives me

There is no Action mapped for namespace [/do/some/specificstuff/] and
action name [eat] associated with context path [/myApp].


Struts is apparently trying to match the request /do/some/specificstuff/eat
against some namespace /do/some/specificstuff and action "eat"

which of cource doesn't exist.

Well I guess that's exaclty what

alwaysSelectFullNamespace

does.


btw: I'm using the convention plugin too if that matters.



>
> On Wed, Mar 7, 2012 at 12:39 PM, Mounir Benzid<mb...@meetingmasters.de>  wrote:
>
>> Here is a simple example showing two methods in the given order
>>
>>     /***************************************************************
>> **********************************/
>>     @Override
>>     @Action(value="/do/some/**specificstuff/{thing}",
>> results={@Result(location = "result.jsp")}),
>>     public String execute() throws Exception {...}
>>
>>
>>     /***************************************************************
>> **********************************/
>>     @Override
>>     @Action(value="/do/some/{**thing}", results={@Result(location =
>> "result.jsp")}),
>>     public String input() throws Exception {...}
>>
>>
>>
>> Now if the request contains myApp/do/some/specificstuff/**eat
>>
>>
>> which action will fire? I my case it's the input() method but it really
>> should be the execute()  method.
>> The parameter "thing" in the second annotation then equals
>> "specificstuff/eat"
>>
>>
>> Is it possible to control the "greediness" of the patternmatcher? Using
>> XML notation one could simply control
>> this behaviour by  reordering the<action>  tags.
>>
>> Thanks
>>
>> - Mounir
>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


-- 
Mounir Benzid
Systementwickler / EDV

meetingmasters.de
meetings meisterhaft managen

· Unabhängige Vermittlung von Tagungshotels
· Online-Hotelreservierungssystem zur Integration in die Veranstaltungs-Webseite
· Webbasiertes Veranstaltungs- und Teilnehmermanagement
· E-Procurement für den Tagungshoteleinkauf
· Webbasierte Anfrage und Verhandlung von Firmenraten

Max-Planck-Straße 22
D-54296 Trier

fon +49 (0)651-145789-38
fax +49 (0)651-145789-20

www.meetingmasters.de
mb@meetingmasters.de


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Does the orrder of wildcard-annotated methods effects greediness?

Posted by Dave Newton <da...@gmail.com>.
I'm wondering if `struts.mapper.alwaysSelectFullNamespace` would affect
this.

Dave

On Wed, Mar 7, 2012 at 12:39 PM, Mounir Benzid <mb...@meetingmasters.de> wrote:

> Here is a simple example showing two methods in the given order
>
>    /***************************************************************
> **********************************/
>    @Override
>    @Action(value="/do/some/**specificstuff/{thing}",
> results={@Result(location = "result.jsp")}),
>    public String execute() throws Exception {...}
>
>
>    /***************************************************************
> **********************************/
>    @Override
>    @Action(value="/do/some/{**thing}", results={@Result(location =
> "result.jsp")}),
>    public String input() throws Exception {...}
>
>
>
> Now if the request contains myApp/do/some/specificstuff/**eat
>
>
> which action will fire? I my case it's the input() method but it really
> should be the execute()  method.
> The parameter "thing" in the second annotation then equals
> "specificstuff/eat"
>
>
> Is it possible to control the "greediness" of the patternmatcher? Using
> XML notation one could simply control
> this behaviour by  reordering the <action> tags.
>
> Thanks
>
> - Mounir
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>