Right... coding in email so I missed the different type signature.

Apparently findMethods has been deprecated in favor of
List<TransformMethod> matchMethods(Predicate<TransformMethod> predicate)
Finds all methods matched by the provided predicate.

Which returns the TransformMethod which you want to add advice. Your
predicate would be by name and hopefully only find one method!

So you want something like:

List<TransformMethod> methods = transformation.matchMethods(new
Predicate<TransformMethod>()
            {
                public boolean accept(TransformMethod object)
                {
                    return method.getName().equals("extractRequestParameters");
                }
            });

if ( methods.size() != 1 ) throw new RuntimeException("Expected 1
extractRequestParameters method, found " + methods.size();

methods.get(0).addAdvice(...)

Again, I'm doing this from email with no compiler/ide so I could be
off. There might be a smarter way to do it, but it seems like if you
know the method exists you should just find it instead of
getOrCreate'ing it.


Josh

On Tue, Sep 14, 2010 at 11:05 AM, Markus Feindler
<markus.feind...@gmx.de> wrote:
>  Sounds plausible, but how would a MethodFilter help? It can retrieve the
> TransformMethodSignature, but how to use that to create an advise?
>>
>> Hmm... just took a look at the code again and I think I see the problem.
>>
>> ///// This creates the method body if your class doesn't already implement
>> it:
>> transformation.addImplementedInterface(RequestParameterExtractor.class);
>>
>> TransformMethodSignature extractMethod = new
>> TransformMethodSignature(Modifier.PUBLIC,
>>     "Map<String, String>", "extractRequestParameters", null, null);
>>
>> /////  This is probably commented out because it always returns.
>> // if (transformation.isDeclaredMethod(extractMethod)) {
>> //    return;
>> // }
>>
>> ///// This is apparently trying to re-create the method.
>> transformation.getOrCreateMethod(extractMethod).addAdvice(new
>> ComponentMethodAdvice(){
>>
>> You should call transformation.findMethods(filter); instead of
>> getOrCreateMethod. I'm not sure why the getOrCreate is trying to
>> implement the method if it's already there, but I'd guess it has
>> something to do with your new TransformMethodSignature.
>>
>> Josh
>>
>> On Tue, Sep 14, 2010 at 10:20 AM, Markus Feindler
>> <markus.feind...@gmx.de>  wrote:
>>>
>>> �...@christoph:
>>> Same Error
>>>
>>> @Josh
>>> Yes, I also removed the Generic Map from the Interface.
>>>
>>> Just checked in debug method: the method indeed already exists
>>> (breakpoint:
>>> line 1443 InternalClassTransformationImpl). But how come? Its never added
>>> through my code.
>>>>
>>>> Did you take the type parameters off of the interface too (return a
>>>> raw map)? Have you looked at with a debugger? Stick a breakpoint right
>>>> before the exception and take a look at the methods in the ctclass.
>>>>
>>>> I can't look at it now but I'll try to reproduce the problem tonight.
>>>>
>>>> Josh
>>>>
>>>>
>>>> On Tue, Sep 14, 2010 at 9:47 AM, Markus Feindler<markus.feind...@gmx.de>
>>>>  wrote:
>>>>>
>>>>>  Just tried, does not work :(.
>>>>>>
>>>>>> Have you tried without specify Generic types ?
>>>>>>
>>>>>> 2010/9/13 Christophe Cordenier<christophe.corden...@gmail.com>
>>>>>>
>>>>>>> Oh, this is maybe due to generics...
>>>>>>>
>>>>>>> 2010/9/13 Markus Feindler<markus.feind...@gmx.de>
>>>>>>>
>>>>>>>> public interface RequestParameterExtractor {
>>>>>>>>    Map<String, String>      extractRequestParameters();
>>>>>>>> }
>>>>>>>>
>>>>>>>> is not equal to:
>>>>>>>>
>>>>>>>>
>>>>>>>>     TransformMethodSignature extractMethod = new
>>>>>>>> TransformMethodSignature(Modifier.PUBLIC,
>>>>>>>>            "Map<String, String>", "extractRequestParameters", null,
>>>>>>>> null);
>>>>>>>>
>>>>>>>> ?
>>>>>>>>
>>>>>>>>
>>>>>>>>  Everything looks good ... The only thing i see is that the method
>>>>>>>>>
>>>>>>>>> signature
>>>>>>>>> is not exactly the same as the one declared in the interface.
>>>>>>>>>
>>>>>>>>> 2010/9/13 Markus Feindler<markus.feind...@gmx.de>
>>>>>>>>>
>>>>>>>>>   Am 13.09.2010 22:18, schrieb Thiago H. de Paula Figueiredo:
>>>>>>>>>>
>>>>>>>>>>  On Mon, 13 Sep 2010 17:02:02 -0300, Christophe Cordenier<
>>>>>>>>>>
>>>>>>>>>>> christophe.corden...@gmail.com>       wrote:
>>>>>>>>>>>
>>>>>>>>>>>  Please, Can you provide your Tapestry Module class that
>>>>>>>>>>> contributes
>>>>>>>>>>> your
>>>>>>>>>>>
>>>>>>>>>>>> worker ?
>>>>>>>>>>>>
>>>>>>>>>>>>  And the worker itself? It seems two different worker instances
>>>>>>>>>>>> are
>>>>>>>>>>>
>>>>>>>>>>> trying
>>>>>>>>>>> to add the same method to the same page class.
>>>>>>>>>>>
>>>>>>>>>>>  files attached! appreciate your help.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>>>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>> --
>>>>>>> Regards,
>>>>>>> Christophe Cordenier.
>>>>>>>
>>>>>>> Committer on Apache Tapestry 5
>>>>>>> Co-creator of wooki @wookicentral.com
>>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>
>>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to