You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Michiel Vermandel <mv...@yahoo.com> on 2013/05/02 13:46:41 UTC

[iPOJO] My own runtime annotations get lost (proxied)

Hi,

I have some custom annotations with retention == runtime.
Now, when I use these annotations on an object that is also annotated as iPOJO component, I cannot access my annotations anymore on a created instance of the component.
If I list the annotations on such annotated field, I get something like $Proxy17 as class instead of my custom annotation class.

This how I try to get to the annotations:

(simplified example:)

my iPOJO with custom annotation:

@Component
@Provides
public class DeviceService{
    
    @Channel(payload = DeviceBean.class, type= VOLUME_STATE_CHANGED) // <= custom annotation
    EventLogger volumeStateChanged;

...

When I get hold of the component instance, I get to the original(manipulated) object like this:
Object instancePojo = ((InstanceManager) instance).getPojoObject();
Then I get the field volumeStateChanged and try to get the @Channel annotation.
Which fails => field.getAnnotation(Channel.class) == null


Is there a way to keep/get the original annotation on my field?
(The code should work outside iPOJO as well, So I need my custom - non iPOJO - annotations)

Thanks!

 
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials

Re: [iPOJO] My own runtime annotations get lost (proxied)

Posted by Michiel Vermandel <mv...@yahoo.com>.
Hmm...Then why do I get a Proxy class for my field annotated with my custom Annotation?
Thanks

 
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials


________________________________
 From: Guillaume Sauthier (OW2/GMail) <gu...@gmail.com>
To: users@felix.apache.org 
Sent: Friday, May 3, 2013 10:14 AM
Subject: Re: [iPOJO] My own runtime annotations get lost (proxied)
 

The manipulator do not create proxy on his own.
this is the job of the handler to perform that task.
With @Requires and @Bind, this is the iPOJO 'requires' handler

With your own annotation, this is the job of your own handler


2013/5/3 Michiel Vermandel <mv...@yahoo.com>

> Hi,
>
>
> I do not use @Requires on that field. I use my own @Channel.
> The @Channel is how ever declared in a bundle which goes through the
> manipulator.
> Will the manipulator create a proxy for this annotation?
> (I cannot user proxy=false since the annotation is custom, not @Requires)
>
> Thanks
>
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials
>
>
> ________________________________
>  From: Clement Escoffier <cl...@gmail.com>
> To: users@felix.apache.org; Michiel Vermandel <mv...@yahoo.com>
> Sent: Thursday, May 2, 2013 8:07 PM
> Subject: Re: [iPOJO] My own runtime annotations get lost (proxied)
>
>
> Hi,
>
> If you try to grab the object from a @Requires injected field, you are
> getting a proxy. Disable the proxy to get a direct reference on the object.
>
> Regards,
>
> Clement
>
> On 2 mai 2013, at 13:46, Michiel Vermandel <mv...@yahoo.com> wrote:
>
> > Hi,
> >
> > I have some custom annotations with retention ==
>  runtime.
> > Now, when I use these annotations on an object that is also annotated as
> iPOJO component, I cannot access my annotations anymore on a created
> instance of the component.
> > If I list the annotations on such annotated field, I get something like
> $Proxy17 as class instead of my custom annotation class.
> >
> > This how I try to get to the annotations:
> >
> > (simplified example:)
> >
> > my iPOJO with custom annotation:
> >
> > @Component
> > @Provides
> > public class DeviceService{
> >
> >     @Channel(payload = DeviceBean.class, type= VOLUME_STATE_CHANGED) //
> <= custom annotation
> >     EventLogger volumeStateChanged;
> >
> > ...
> >
> > When I get hold of the component instance, I get to the
> original(manipulated) object like this:
> > Object instancePojo = ((InstanceManager) instance).getPojoObject();
> > Then
>  I get the field volumeStateChanged and try to get the @Channel annotation.
> > Which fails => field.getAnnotation(Channel.class) == null
> >
> >
> > Is there a way to keep/get the original annotation on my field?
> > (The code should work outside iPOJO as well, So I need my custom - non
> iPOJO - annotations)
> >
> > Thanks!
> >
> >
> > -----------------
> > http://www.codessentials.com - Your essential software, for free!
> > Follow us at http://twitter.com/#!/Codessentials
>

Re: [iPOJO] My own runtime annotations get lost (proxied)

Posted by "Guillaume Sauthier (OW2/GMail)" <gu...@gmail.com>.
The manipulator do not create proxy on his own.
this is the job of the handler to perform that task.
With @Requires and @Bind, this is the iPOJO 'requires' handler

With your own annotation, this is the job of your own handler


2013/5/3 Michiel Vermandel <mv...@yahoo.com>

> Hi,
>
>
> I do not use @Requires on that field. I use my own @Channel.
> The @Channel is how ever declared in a bundle which goes through the
> manipulator.
> Will the manipulator create a proxy for this annotation?
> (I cannot user proxy=false since the annotation is custom, not @Requires)
>
> Thanks
>
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials
>
>
> ________________________________
>  From: Clement Escoffier <cl...@gmail.com>
> To: users@felix.apache.org; Michiel Vermandel <mv...@yahoo.com>
> Sent: Thursday, May 2, 2013 8:07 PM
> Subject: Re: [iPOJO] My own runtime annotations get lost (proxied)
>
>
> Hi,
>
> If you try to grab the object from a @Requires injected field, you are
> getting a proxy. Disable the proxy to get a direct reference on the object.
>
> Regards,
>
> Clement
>
> On 2 mai 2013, at 13:46, Michiel Vermandel <mv...@yahoo.com> wrote:
>
> > Hi,
> >
> > I have some custom annotations with retention ==
>  runtime.
> > Now, when I use these annotations on an object that is also annotated as
> iPOJO component, I cannot access my annotations anymore on a created
> instance of the component.
> > If I list the annotations on such annotated field, I get something like
> $Proxy17 as class instead of my custom annotation class.
> >
> > This how I try to get to the annotations:
> >
> > (simplified example:)
> >
> > my iPOJO with custom annotation:
> >
> > @Component
> > @Provides
> > public class DeviceService{
> >
> >     @Channel(payload = DeviceBean.class, type= VOLUME_STATE_CHANGED) //
> <= custom annotation
> >     EventLogger volumeStateChanged;
> >
> > ...
> >
> > When I get hold of the component instance, I get to the
> original(manipulated) object like this:
> > Object instancePojo = ((InstanceManager) instance).getPojoObject();
> > Then
>  I get the field volumeStateChanged and try to get the @Channel annotation.
> > Which fails => field.getAnnotation(Channel.class) == null
> >
> >
> > Is there a way to keep/get the original annotation on my field?
> > (The code should work outside iPOJO as well, So I need my custom - non
> iPOJO - annotations)
> >
> > Thanks!
> >
> >
> > -----------------
> > http://www.codessentials.com - Your essential software, for free!
> > Follow us at http://twitter.com/#!/Codessentials
>

[iPOJO] My own runtime annotations get lost (proxied)

Posted by Michiel Vermandel <mv...@yahoo.com>.
Hi,


I do not use @Requires on that field. I use my own @Channel.
The @Channel is how ever declared in a bundle which goes through the manipulator.
Will the manipulator create a proxy for this annotation?
(I cannot user proxy=false since the annotation is custom, not @Requires)

Thanks
 
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials


________________________________
 From: Clement Escoffier <cl...@gmail.com>
To: users@felix.apache.org; Michiel Vermandel <mv...@yahoo.com> 
Sent: Thursday, May 2, 2013 8:07 PM
Subject: Re: [iPOJO] My own runtime annotations get lost (proxied)
 

Hi,

If you try to grab the object from a @Requires injected field, you are getting a proxy. Disable the proxy to get a direct reference on the object.

Regards,

Clement

On 2 mai 2013, at 13:46, Michiel Vermandel <mv...@yahoo.com> wrote:

> Hi,
> 
> I have some custom annotations with retention ==
 runtime.
> Now, when I use these annotations on an object that is also annotated as iPOJO component, I cannot access my annotations anymore on a created instance of the component.
> If I list the annotations on such annotated field, I get something like $Proxy17 as class instead of my custom annotation class.
> 
> This how I try to get to the annotations:
> 
> (simplified example:)
> 
> my iPOJO with custom annotation:
> 
> @Component
> @Provides
> public class DeviceService{
>    
>     @Channel(payload = DeviceBean.class, type= VOLUME_STATE_CHANGED) // <= custom annotation
>     EventLogger volumeStateChanged;
> 
> ...
> 
> When I get hold of the component instance, I get to the original(manipulated) object like this:
> Object instancePojo = ((InstanceManager) instance).getPojoObject();
> Then
 I get the field volumeStateChanged and try to get the @Channel annotation.
> Which fails => field.getAnnotation(Channel.class) == null
> 
> 
> Is there a way to keep/get the original annotation on my field?
> (The code should work outside iPOJO as well, So I need my custom - non iPOJO - annotations)
> 
> Thanks!
> 
>  
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials

Re: [iPOJO] My own runtime annotations get lost (proxied)

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,

If you try to grab the object from a @Requires injected field, you are getting a proxy. Disable the proxy to get a direct reference on the object.

Regards,

Clement

On 2 mai 2013, at 13:46, Michiel Vermandel <mv...@yahoo.com> wrote:

> Hi,
> 
> I have some custom annotations with retention == runtime.
> Now, when I use these annotations on an object that is also annotated as iPOJO component, I cannot access my annotations anymore on a created instance of the component.
> If I list the annotations on such annotated field, I get something like $Proxy17 as class instead of my custom annotation class.
> 
> This how I try to get to the annotations:
> 
> (simplified example:)
> 
> my iPOJO with custom annotation:
> 
> @Component
> @Provides
> public class DeviceService{
>     
>     @Channel(payload = DeviceBean.class, type= VOLUME_STATE_CHANGED) // <= custom annotation
>     EventLogger volumeStateChanged;
> 
> ...
> 
> When I get hold of the component instance, I get to the original(manipulated) object like this:
> Object instancePojo = ((InstanceManager) instance).getPojoObject();
> Then I get the field volumeStateChanged and try to get the @Channel annotation.
> Which fails => field.getAnnotation(Channel.class) == null
> 
> 
> Is there a way to keep/get the original annotation on my field?
> (The code should work outside iPOJO as well, So I need my custom - non iPOJO - annotations)
> 
> Thanks!
> 
>  
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org