Return-Path: X-Original-To: apmail-felix-users-archive@minotaur.apache.org Delivered-To: apmail-felix-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C8FA9CF2A for ; Wed, 30 May 2012 10:58:10 +0000 (UTC) Received: (qmail 18315 invoked by uid 500); 30 May 2012 10:58:10 -0000 Delivered-To: apmail-felix-users-archive@felix.apache.org Received: (qmail 17695 invoked by uid 500); 30 May 2012 10:58:05 -0000 Mailing-List: contact users-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@felix.apache.org Delivered-To: mailing list users@felix.apache.org Received: (qmail 17647 invoked by uid 99); 30 May 2012 10:58:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2012 10:58:03 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of justinedelson@gmail.com designates 209.85.212.181 as permitted sender) Received: from [209.85.212.181] (HELO mail-wi0-f181.google.com) (209.85.212.181) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2012 10:57:57 +0000 Received: by wibhn14 with SMTP id hn14so3103505wib.10 for ; Wed, 30 May 2012 03:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=peZcEg39jelkql6dqIrOe6A81pGw5KFpHJMm+lRMdK4=; b=qOqmFrD4YM8Ee4udXNHTrky1TZpkmTXMlJ+TvmPKVdAJgA7aPN0cqWWbqt7c6tFx12 AockY7O334smsBq3o3Y+5j45TrXLkk0TvaDGkIk6uX+mgz1FyCHZgf9NARgSaor62FF1 KrxD9fi2FelUYUA6B1pVoMEfQv8+oPz1z6OuzGZCX0FQYpvN2fCKtkcnnzFEndjmOknq L7pTP8jSaV5pBuxAMCuzJiQMTn2PGNOmqiRJWH0F//UrGJHStpGJq2gmJKG6FgP5k87l +6UfxUQgZsvgCr3AUXFKRB6iv6uDq6HYMs9W2tfPYGsir+V244YR4J4xVCYYn01nMAim FerQ== MIME-Version: 1.0 Received: by 10.216.50.140 with SMTP id z12mr6482916web.11.1338375456072; Wed, 30 May 2012 03:57:36 -0700 (PDT) Sender: justinedelson@gmail.com Received: by 10.180.92.164 with HTTP; Wed, 30 May 2012 03:57:35 -0700 (PDT) In-Reply-To: <1338351616.83904.YahooMailNeo@web161403.mail.bf1.yahoo.com> References: <1338223666.10599.YahooMailNeo@web161406.mail.bf1.yahoo.com> <1338268007.65059.YahooMailNeo@web161403.mail.bf1.yahoo.com> <1338351616.83904.YahooMailNeo@web161403.mail.bf1.yahoo.com> Date: Wed, 30 May 2012 06:57:35 -0400 X-Google-Sender-Auth: BocyUW-hVcQvltG7A24WmAMXrwE Message-ID: Subject: Re: activator with dependency injection for service From: Justin Edelson To: users@felix.apache.org, miten mehta Content-Type: multipart/alternative; boundary=0016e6dbdeeca2a50104c13ed1b4 X-Virus-Checked: Checked by ClamAV on apache.org --0016e6dbdeeca2a50104c13ed1b4 Content-Type: text/plain; charset=ISO-8859-1 Hi, On Wed, May 30, 2012 at 12:20 AM, miten mehta 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 > To: miten mehta > Cc: "users@felix.apache.org" > 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 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 > >To: users@felix.apache.org; miten mehta > >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 > > > > destroy="deactivate"> > > > > > > > >Chetan Mehrotra > > > > > > > >On Mon, May 28, 2012 at 10:17 PM, miten mehta 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 > >>------------------------ > >> > >> > >> >> 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"> > >> > >> > >> > >> interface="org.springframework.osgi.samples.simpleservice.MyService"> > >> > >> class="org.springframework.osgi.samples.ActivatorClient" scope="singleton"> > >> > >> > >> > >> > >> > >> > >>pom.xml snippet: > >>----------------- > >> > >> org.apache.felix > >> maven-bundle-plugin > >> true > >> > >> > >> > >> > >> > org.springframework.osgi.samples > >> > org.springframework.osgi.samples.ActivatorClient > >> > >> > >> > >> > > > > > > > --0016e6dbdeeca2a50104c13ed1b4--