You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Harunobu Oyama <ho...@telensa.com> on 2016/07/21 14:27:36 UTC

iPOJO annotation based service provider

Hi,


I have just started learning iPojo as the component framework for my karaf
application.

I tried their maven tutorial, which has three bundles, interface, service
provider, and client.
It uses metadata.xml to provide meta data for iPojo. It worked fine as
expected.

When I moved onto annotation based approach, I did the followings.
  - removed metadata.xml from service provider and client
  - added dependency to ipojo annotation package
  - added annotations to the service provider source code and client source
code

However, it did not work.

By having a closer look, it turned out that the client was working fine but
the service
provider was not working properly.

The annotations I added to the service provider class were
  - @Component      and
  - @Provides
as shown on their annotation tutorial.


The bundle state on the web client showed some difference between xml based
service
provider and the annotation based service provider.

XML based service provider's status shows:

Service ID 183 Types: org.apache.felix.ipojo.extender.TypeDeclaration
Service ID 184 Types: org.apache.felix.ipojo.extender.InstanceDeclaration
Service ID 185 Types: org.apache.felix.ipojo.Factory
                Service PID: HelloProviderrr
Service ID 186 Types: org.apache.felix.ipojo.architecture.Architecture
Service ID 187 Types: ipojo.example.hello.Hello


while Annotation based one does not show Service ID 183, 186, or 187.
And also iPOJO-Components does not have instance attribute, which exists in
XML based version. It looks like the instance attribute was created from
<instance> element of the metadata.xml.


Could somebody tell me how to fix the difference?

thank you,
Harunobu Oyama

Re: iPOJO annotation based service provider

Posted by Harunobu Oyama <ho...@telensa.com>.
all,


Adding @Instantiate annotation to the service provider component fixed the
issue.
I hope it will be added to the official annotation tutorial page in the
future.


thank you,
nobu



On 21 July 2016 at 15:27, Harunobu Oyama <ho...@telensa.com> wrote:

> Hi,
>
>
> I have just started learning iPojo as the component framework for my karaf
> application.
>
> I tried their maven tutorial, which has three bundles, interface, service
> provider, and client.
> It uses metadata.xml to provide meta data for iPojo. It worked fine as
> expected.
>
> When I moved onto annotation based approach, I did the followings.
>   - removed metadata.xml from service provider and client
>   - added dependency to ipojo annotation package
>   - added annotations to the service provider source code and client
> source code
>
> However, it did not work.
>
> By having a closer look, it turned out that the client was working fine
> but the service
> provider was not working properly.
>
> The annotations I added to the service provider class were
>   - @Component      and
>   - @Provides
> as shown on their annotation tutorial.
>
>
> The bundle state on the web client showed some difference between xml
> based service
> provider and the annotation based service provider.
>
> XML based service provider's status shows:
>
> Service ID 183 Types: org.apache.felix.ipojo.extender.TypeDeclaration
> Service ID 184 Types: org.apache.felix.ipojo.extender.InstanceDeclaration
> Service ID 185 Types: org.apache.felix.ipojo.Factory
>                 Service PID: HelloProviderrr
> Service ID 186 Types: org.apache.felix.ipojo.architecture.Architecture
> Service ID 187 Types: ipojo.example.hello.Hello
>
>
> while Annotation based one does not show Service ID 183, 186, or 187.
> And also iPOJO-Components does not have instance attribute, which exists
> in XML based version. It looks like the instance attribute was created from
> <instance> element of the metadata.xml.
>
>
> Could somebody tell me how to fix the difference?
>
> thank you,
> Harunobu Oyama
>
>
>
>
>
>