felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michiel Vermandel <mverm...@yahoo.com>
Subject Re: [iPOJO] using External Handler
Date Fri, 03 May 2013 09:43:13 GMT
I changed my Handler to this:

   @Handler(name = "ScanCustom", namespace = "com.ce.flowbeans.channels")
   public class EventChannelHandler extends PrimitiveHandler {

Created the new Annotation:

   package com.ce.flowbeans.channels;

   import java.lang.annotation.ElementType;
   import java.lang.annotation.Retention;
   import java.lang.annotation.RetentionPolicy;
   import java.lang.annotation.Target;

   @Target(ElementType.TYPE)
   @Retention(RetentionPolicy.SOURCE)
   public @interface ScanCustom {}

And changed my DeviceService class:

   @Component
   @Provides
   @ScanCustom
   public class DeviceService{
    
       public static final String VOLUME_STATE_CHANGED="com/ce/flowbeans/io/VOLUME_STATE_CHANGED";

      private DeviceWatcher deviceWatcher = null;

       @Requires
      EventService flowService;
    
       @Channel(payload = DeviceBean.class, topic = VOLUME_STATE_CHANGED)
      EventSender volumeStateChanged;

       ...
    }

No change however...

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


________________________________
 From: Guillaume Sauthier (OW2/GMail) <guillaume.ow2@gmail.com>
To: users@felix.apache.org 
Sent: Friday, May 3, 2013 10:48 AM
Subject: Re: [iPOJO] using External Handler
 

Looking at your factory description, you can see that your handler is not
in the required handler's list.

Hmm I think I got it.

This is probably because of FELIX-3889
Runtime visible annotations cannot be iPOJO handler's markers.

Maybe you can simply have a class level marker annotation (not runtime
visible, probably no attributes, depending on what you need to read in your
handler). this annotation will enable your own handler.
And this handler will be able to read your own @Channel annotation


https://issues.apache.org/jira/browse/FELIX-3889


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

> Handler com.ce.flowbeans.channels:Channel  (VALID)
>
> @Component
> @Provides
> public class DeviceService{
>
>     public static final String
> VOLUME_STATE_CHANGED="com/ce/flowbeans/io/VOLUME_STATE_CHANGED";
>
>     private DeviceWatcher deviceWatcher = null;
>
>     @Requires
>     EventService flowService;
>
>     @Channel(payload = DeviceBean.class, topic = VOLUME_STATE_CHANGED)
>     EventSender volumeStateChanged;
>
> ...
> }
>
>
> g! Factory com.ce.flowbeans.io.DeviceService
> factory name="com.ce.flowbeans.io.DeviceService" bundle="30" state="valid"
> implementation-class="com.ce.flowbeans.io.DeviceService"
>     requiredhandlers list="[org.apache.felix.ipojo:requires,
> org.apache.felix.ipojo:callback, org.apache.felix.ipojo:provides,
> org.apache.felix.ipojo:architecture]"
>     missinghandlers list="[]"
>     provides specification="com.ce.flowbeans.io.DeviceService"
>     inherited interfaces="[]" superclasses="[]"
>
> g! Instance com.ce.flowbeans.io.DeviceService-0
> instance name="com.ce.flowbeans.io.DeviceService-0" state="valid"
> bundle="30" component.type="com.ce.flowbeans.io.DeviceService"
>     handler name="org.apache.felix.ipojo:requires" state="valid"
>         requires specification="com.ce.flowbeans.EventService"
> id="com.ce.flowbeans.EventService" optional="false" aggregate="false"
> proxy="true" binding-policy="dynamic" state="resolved"
>     handler name="org.apache.felix.ipojo:callback" state="valid"
>     handler name="org.apache.felix.ipojo:provides" state="valid"
>         provides specifications="[com.ce.flowbeans.io.DeviceService]"
> state="registered" service.id="59"
>             property name="factory.name"
> value="com.ce.flowbeans.io.DeviceService"
>             property name="instance.name"
> value="com.ce.flowbeans.io.DeviceService-0"
>     handler name="org.apache.felix.ipojo:architecture" state="valid"
>     object name="com.ce.flowbeans.io.DeviceService@662f743b"
>
>
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials
>
>
> ________________________________
>  From: Guillaume Sauthier (OW2/GMail) <guillaume.ow2@gmail.com>
> To: users@felix.apache.org
> Sent: Friday, May 3, 2013 10:11 AM
> Subject: Re: [iPOJO] using External Handler
>
>
> Can you show me the details of the following commands:
> >$ factory com.ce.flowbeans.io.DeviceService
> >$ instance com.ce.flowbeans.io.DeviceService-0
>
> Thanks
>
>
> 2013/5/3 Michiel Vermandel <mvermand@yahoo.com>
>
> > Hi,
> >
> >
> > I did not do that yet.
> > I just wanted to see the Handler getting invoked.
> > I have added a System.out in the constructor of the handler and in the
> > start method but I do not see any of these comments in the console.
> >
> > When exactly is/should the Handler be instantiated?
> >
> > Thanks
> >
> > -----------------
> > http://www.codessentials.com - Your essential software, for free!
> > Follow us at http://twitter.com/#!/Codessentials
> >
> >
> > ________________________________
> >  From: Clement Escoffier <clement.escoffier@gmail.com>
> > To: users@felix.apache.org; Michiel Vermandel <mvermand@yahoo.com>
> > Sent: Thursday, May 2, 2013 8:06 PM
> > Subject: Re: [iPOJO] using External Handler
> >
> >
> > Hi,
> >
> > Did you implement the configure method and parsed the given metadata ?
> You
> > must register a field interceptor for each field you need to inject.
> >
> > Regards,
> >
> > Clement
> >
> > On 2 mai 2013, at 17:10, Michiel Vermandel <mvermand@yahoo.com> wrote:
> >
> > > Hi,
> > >
> > > In my previous post I mentioned an issue with my custom annotations.
> > > Now I'm trying to write a iPOJO Handler to inject these dependencies.
> > >
> > > I have created a class implementing PrimitiveHandler:
> > >
> > > @Handler(name = "Channel", namespace = "com.ce.flowbeans.channels")
> > > public class EventChannelHandler extends PrimitiveHandler {
> > >
> > > I have implemented the required methods, but have only put some
> > system.out for the moment.
> > >
> > > I also have my annotation @Channel in the package
> > "com.ce.flowbeans.channels".
> > >
> > > When I startup the framework I see the handler:
> > >
> > >> handlers
> > > Handler org.apache.felix.ipojo:properties (VALID)
> > > Handler org.apache.felix.ipojo:requires (VALID)
> > > Handler org.apache.felix.ipojo:architecture (VALID)
> > > Handler
> >  org.apache.felix.ipojo:callback (VALID)
> > > Handler org.apache.felix.ipojo:controller (VALID)
> > > Handler org.apache.felix.ipojo:provides (VALID)
> > > Handler com.ce.flowbeans.channels:Channel (VALID)    <==
> > >
> > > But when a field in a component is annotated with the @Channel
> > annotation, it gets not injected.
> > > Neither do I see any call to the initializeComponentFactory(...) or
> > configure(...) or start() methods of the handler.
> > >
> > > Do I need to specifically attach the handler to the component instance
> > in some way?
> > >
> > > Thanks
> > >
> > >
> > >
> > > -----------------
> > > http://www.codessentials.com - Your essential software, for free!
> > > Follow us at http://twitter.com/#!/Codessentials
> >
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message