felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From miten mehta <imi...@yahoo.com>
Subject Re: activator with dependency injection for service
Date Tue, 29 May 2012 05:06:47 GMT

Then how will I invoke the bean ? I thought that if I start/stop module the activator start/stop
happens and I can then invoke the remote method from service reference in activator.

Basically I have trying to write a client bean which can do a call to another osgi module
service (spring dm bean).



 From: Chetan Mehrotra <chetan.mehrotra@gmail.com>
To: users@felix.apache.org; miten mehta <imiten@yahoo.com> 
Sent: Tuesday, May 29, 2012 9:22 AM
Subject: Re: activator with dependency injection for service

The activator instance is created by OSGi framework itself outside of Spring. Hence you would
not be able to access services via DI. The one created through your entry in spring cofig
is a different instance. Instead you can remove activator entry from your pom.xml and rely
on Spring itself to call lifecycle methods like init and destroy

<bean id="client" class="org.springframework.
osgi.samples.ActivatorClient" scope="singleton" init="activate" destroy="deactivate">
   <property name="service" ref="simpleServiceOsgi"/>

Chetan Mehrotra

On Mon, May 28, 2012 at 10:17 PM, miten mehta <imiten@yahoo.com> wrote:

>I am trying to use spring dm in felix for doing a client module with activator in which
I wanting to do dependency injection of service.  I am not getting the service set.  It
gives Null pointer.  could one guide if I am doing things right ?
><?xml version="1.0" encoding="UTF-8"?>
><beans xmlns="http://www.springframework.org/schema/beans"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xmlns:osgi="http://www.springframework.org/schema/osgi"
>  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
>                      http://www.springframework.org/schema/osgi
>  <osgi:reference id="simpleServiceOsgi" interface="org.springframework.osgi.samples.simpleservice.MyService"></osgi:reference>
><bean id="client" class="org.springframework.osgi.samples.ActivatorClient" scope="singleton">
>   <property name="service" ref="simpleServiceOsgi"/>
>pom.xml snippet:
><plugin>    <!-- (2) START -->
>                <groupId>org.apache.felix</groupId>
>                <artifactId>maven-bundle-plugin</artifactId>
>                <extensions>true</extensions>
>                <configuration>
>                    <instructions>
>                        <!-- >Export-Package>org.springframework.osgi.samples.simpleservice</Export-Package
>                        <Private-Package>org.springframework.osgi.samples</Private-Package>
>                        <Bundle-Activator>org.springframework.osgi.samples.ActivatorClient</Bundle-Activator>
>                    </instructions>
>                </configuration>
>            </plugin> 
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message