You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Clement Escoffier <cl...@gmail.com> on 2011/10/04 10:30:28 UTC

Re: Unable to retrieve "$init" method using handlers via interceptor method calls OnEntry..etc

Hi,

I've opened : https://issues.apache.org/jira/browse/FELIX-3144

Regards,

Clement

On 30.09.2011, at 16:21, Sadish M wrote:

> 
> 
> clement escoffier wrote:
>> 
>> Hi,
>> 
>> On 27.09.2011, at 12:06, Sadish M wrote:
>> 
>>> 
>>> hi ,
>>> 
>>> I  have created an handler to intercept all the public methods of a POJO
>>> component using auto handler property.  By this way i am able to get all
>>> the
>>> method names via PojoMetadata properties as below. 
>>> 
>>> PojoMetadata pojoMeta = getPojoMetadata();
>>> MethodMetadata[] methodMetadata = pojoMeta.getMethods();
>>> String mName = methodMetadata[i].getMethodName()
>>> 
>>> In the methodMetadata[] array, I am able to  get the "$init()" method
>>> also
>>> able to register with the handler interceptors.  Everything works fine
>>> until
>>> then. 
>>> 
>>> Problem comes, when the handler intercepts the "$init()" method, via
>>> "public
>>> void onEntry(Object pojo, Method method, Object[] args) "  , the second
>>> argument, "Method method" is not able to retrieve the name of the method
>>> when I try to print the method name being intercepted; like this;
>>> 
>>> String xx =  method.getName();
>>> This throws an null pointer exception for "$init" method alone.  For the
>>> rest of all the methods, this works fine properly.
>>> 
>>> 
>>> Please clarify me, why I could not get the name of "$init" method ? in
>>> the
>>> intercepted method calls to OnEntry or OnExit or OnFinish.    This causes
>>> the iPojo could not instantiate and failing in constructor invocation.
>> 
>> Unfortunately, in the reflection API of Java,  Constructor and Method are
>> two different types. So, for constructors, iPOJO can't find the Method
>> object, so returns null.  I was thinking changing to Member (a parent
>> class of both Method and Constructor) in the near future to avoid this
>> issue. Would it help you ? Right now you can safely consider that when
>> null is given as argument you're on a constructor.
>> 
>> Regards,
>> 
>> Clement
>>> 
>>> I request you to correct me if I have done any mistakes.
>>> 
>>> Thanks,
>>> Sadish
>>> 
>>> -- 
>>> View this message in context:
>>> http://old.nabble.com/Unable-to-retrieve-%22%24init%22--method-using-handlers-via-interceptor-method-calls-OnEntry..etc-tp32523290p32523290.html
>>> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
>> 
>> 
> 
> 
> Hi clement,
> 
> Thanks for your message.  If there is a parent class of both method and
> constructor, definitely it would help us in our developments. We are
> interested in that. ! :-)
> have a nice weekend !
> 
> thanks in advance,
> Sadish
> 
> -- 
> View this message in context: http://old.nabble.com/Unable-to-retrieve-%22%24init%22--method-using-handlers-via-interceptor-method-calls-OnEntry..etc-tp32523290p32569276.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>