Sorry miten, I completely lost you there. I thought you were asking about exporting OSGi services to applications running in the same app server, but outside of the OSGi framework. This can be done via JNDI. I didn't understand it to be about EJBs or Spring or remoting.
My reference to DS was to Declarative Services, not Directory Server. Justin On Wed, May 30, 2012 at 7:41 AM, miten mehta <[email protected]> wrote: > Hi Justin, > > I think just as we have spring framework available under osgi framework > and both work together to let us write spring beans and deploy/consume them > as osgi services we need additional framework like ejb framework which we > understand that when spring beans are converted to services it also uses > ejb annotations to export them. > > I think spring which use ApplicationContext as a container for beans it > should use EJBApplicationContext as container for exporting spring beans > for remote access. The osgi services seems to me are process local > references only. I read some things like iPojo and remote osgi service > though did not quite get handle on them. > > I could not quite understand how you used Directory Server to convert your > spring dm beans of osgi container into remote osgi services or ejbs ? is > the service reference capable of remoting across host ? > > Regards, > > Miten. > ------------------------------ > *From:* Justin Edelson <[email protected]> > > *To:* [email protected]; miten mehta <[email protected]> > *Sent:* Wednesday, May 30, 2012 4:27 PM > > *Subject:* Re: activator with dependency injection for service > > Hi, > > On Wed, May 30, 2012 at 12:20 AM, miten mehta <[email protected]> wrote: > > Hi, > > I modified code as you suggested. Removed the activator logic and > converted it into simple bean. The bundle when starts it does activate the > spring framework which instantiates the beans and does DI. The client bean > is now POJO and its instantiated upon bundle start and destroyed on bundle > stop. Also the service reference is being set fine. > > Now I have question on usage of osgi container like felix. can I use it > as middle tier for ejbs like the service bean made available to tomcat > instance running outside felix via jndi lookup ? > > > This is possible, although I don't think you can do it with Tomcat. The > steps required are: > > 1) Have the system bundle export the packages containing any service > interfaces you are going to export via JNDI. > 2) Have some bridge code running inside Felix: > a) obtains an appropriate InitialContext object > b) finds services from the service registry and binds them in the > InitialContext > > Your bridge code will likely need to be a service listener so that it > correctly unbinds services when they go away. I used DS for this; I imagine > there's a way to do it with Spring DM as well. > > The problem with Tomcat is that its JNDI context is read-only. The steps > above obviously require a global writeable context. > > Regards, > Justin > > > > Regards, > > Miten. > > > > ________________________________ > From: Chetan Mehrotra <[email protected]> > To: miten mehta <[email protected]> > Cc: "[email protected]" <[email protected]> > Sent: Tuesday, May 29, 2012 3:54 PM > Subject: Re: activator with dependency injection for service > > > Not sure about your usecase here. But as I said you can configure Spring > call any method of the ActivatorClient class of yours upon bean factory > initialization which would happen once your bundle is activated. And in > that call you can perform required invocation > Chetan Mehrotra > > > > On Tue, May 29, 2012 at 10:36 AM, miten mehta <[email protected]> wrote: > > Hi, > > > > > >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). > > > > > >Regards, > > > > > >Miten. > > > > > > > >________________________________ > > From: Chetan Mehrotra <[email protected]> > >To: [email protected]; miten mehta <[email protected]> > >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"/> > ></bean> > > > >Chetan Mehrotra > > > > > > > >On Mon, May 28, 2012 at 10:17 PM, miten mehta <[email protected]> wrote: > > > >Hi, > >> > >>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 ? > >> > >> > >>spring/bean_config.xml > >>------------------------ > >> > >><?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 > http://www.springframework.org/schema/osgi/spring-osgi.xsd"> > >> > >> > >> > >> <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"/> > >></bean> > >> > >></beans> > >> > >> > >>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> > > > > > > > > > > >

