felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clement Escoffier <clement.escoff...@gmail.com>
Subject Re: svn commit: r551894 - in /felix/trunk/ipojo: core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/ core/src/main/java/org/apache/felix/ipojo/util/ plugin/src/main/java/org/apache/felix/ipojo/plugin/
Date Fri, 29 Jun 2007 14:09:33 GMT
Felix Meschberger a écrit :
> Hi Clement,
>
> Don't want to step on your toes, but just to be sure: Are you aware, that
> Class.getMethods() only returns public methods but no protected methods ?
>
> To get the protected methods of parent classes you have to use
> getDeclaredMethods() and walk up the super class chain to find the method
> you are looking for.
Yes, to avoid this, I look inside the two arrays. I begin to look for 
the Method object inside the array returned by the getDeclaredMethods, 
if not found I look inside the array returned by the getMethods. The 
applied patch allow to invoke private, protected and public method from 
the POJO and public methods from the parent classes.

Regards,

Clement

>
>
> On 6/29/07, clement@apache.org <clement@apache.org> wrote:
>>
>> Author: clement
>> Date: Fri Jun 29 06:56:49 2007
>> New Revision: 551894
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=551894
>> Log:
>> Improve method invocation for Lifecycle Callbacks. Allow the 
>> invocation of
>> method from parent classes.(Felix-315).
>> <snip>
>> ---
>> felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java 
>>
>> (original)
>> +++
>> felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java 
>>
>> Fri Jun 29 06:56:49 2007
>> @@ -209,8 +209,31 @@
>>
>>              }
>>          }
>> +
>> +        if (m_methodObj == null) { //look at parent classes
>> +            methods = m_manager.getClazz().getMethods();
>> +            for (int i = 0; m_methodObj == null && i < methods.length;
>> i++) {
>> +                // First check the method name
>> +                if (methods[i].getName().equals(m_method)) {
>> +                    // Check arguments
>> +                    Class[] clazzes = methods[i].getParameterTypes();
>> +                    if (clazzes.length == m_args.length) { // Test size
>> to avoid useless loop
>> +                        boolean ok = true;
>> +                        for (int j = 0; ok && j < m_args.length; j++)
{
>> +                            if 
>> (!m_args[j].equals(clazzes[j].getName()))
>> {
>> +                                ok = false;
>> +                            }
>> +                        }
>> +                        if (ok) {
>> +                            m_methodObj = methods[i]; // It is the 
>> looked
>> method.
>> +                        }
>> +                    }
>> +                }
>> +            }
>> +        }
>> +
>> </snip>
>>
>


-- 
Clement Escoffier
Grenoble University
LSR - Bat. C
220, Rue de la Chimie
BP 53
38041 GRENOBLE CEDEX 9
04.76.51.40.24
http://clement.plop-plop.net


Mime
View raw message