Return-Path: X-Original-To: apmail-aries-user-archive@www.apache.org Delivered-To: apmail-aries-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BA3F59CD0 for ; Fri, 20 Apr 2012 14:08:32 +0000 (UTC) Received: (qmail 40474 invoked by uid 500); 20 Apr 2012 14:08:32 -0000 Delivered-To: apmail-aries-user-archive@aries.apache.org Received: (qmail 40430 invoked by uid 500); 20 Apr 2012 14:08:32 -0000 Mailing-List: contact user-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@aries.apache.org Delivered-To: mailing list user@aries.apache.org Received: (qmail 40422 invoked by uid 99); 20 Apr 2012 14:08:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Apr 2012 14:08:32 +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 (nike.apache.org: domain of cmoulliard@gmail.com designates 209.85.215.50 as permitted sender) Received: from [209.85.215.50] (HELO mail-lpp01m010-f50.google.com) (209.85.215.50) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Apr 2012 14:08:26 +0000 Received: by lahm13 with SMTP id m13so8592348lah.23 for ; Fri, 20 Apr 2012 07:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=GybWod93bcdIWqAWhQkg9fhyCI6JdcvqccCVqh0/3x0=; b=WDrmJpndBLaY6VKEOmlB8/syFS+AuA+yUZ0LtJfsKdmzrVFQ/sTi0TVAcn4aPY8QeL k/4OwymteQW/zv0uoGYzpK/o//J9ZLios3Juofmbg4CMfx2umcWVbDO8nV4QvTNO6Clo U8ZrlHi4VBcQT7TTFJ4JPA7nfONbybpaJQ5moeVCOOGYFGUl/iTs7LhYQuF73Ga0aMRM nvIEcCA08Ag7R1+L8lmURzGr5Ku6gg3kiV7ZHcmCPWtRMSktFEAi4OWQtjldNYGBd1Qx iUH3Ph5/HH4SySkT5b6KDxIH5cw4eCnOpMPH6AFvVzDMHejvW0tBABotaVnEZs10a8YA IXjA== MIME-Version: 1.0 Received: by 10.152.135.104 with SMTP id pr8mr3630358lab.27.1334930886035; Fri, 20 Apr 2012 07:08:06 -0700 (PDT) Received: by 10.152.4.103 with HTTP; Fri, 20 Apr 2012 07:08:05 -0700 (PDT) In-Reply-To: <4F91667F.1070402@die-schneider.net> References: <4F91667F.1070402@die-schneider.net> Date: Fri, 20 Apr 2012 16:08:05 +0200 Message-ID: Subject: Re: Question about Blueprint Service and Bundle loading From: Charles Moulliard To: user@aries.apache.org Content-Type: multipart/alternative; boundary=f46d04426bd6430a5904be1cd1f4 --f46d04426bd6430a5904be1cd1f4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Bundle 1 and Bundle 2 export correctly the packages. This is simply the client which is not able to loads the classes according to the interface name only as we have 2 different implementations. When the bundle client starts, its classloader has to load the classes from bundle 1 or bundle 2. As we are using DynamicImport, this is not done at the starting up of the bundle but when the bean is instantiated by blueprint. Nevertheless, we have no possibilities today to tell using DynamicImport that it must loads classes implemented in Bundle 1 or Bundle 2 depending on info provided in the and the filter. That should be = a great improvement of OSGI + Blueprint if we could have that. That will allow us to really design / use OSGI as a modular platform. On Fri, Apr 20, 2012 at 3:37 PM, Christian Schneider < chris@die-schneider.net> wrote: > I don=B4t think that you can influence this... and honestly I don=B4t th= ink > you should. > > The clean way of loading impl classes for the service would be to offer > two impls of a Factory interface as an OSGi service. So you could define > the interfaces at one point and let the Factory service in Bundle1 load t= he > classes from bundle 1 and the Factory service in Bundle2 load those in > Bundle2. > > Christian > > Am 20.04.2012 13:43, schrieb Charles Moulliard: > > Hi, > > I would like to know if this is possible for a bundle to know based on > info defined in the OSGI Service registered in the OSGI Registry that it > must loads package by example com.mycompany.poc.service.Feedback from a > bundle A and not bundle B when its service definition contain a reference > to a specific filter ? > > Bundle 1 > > interface=3D"com.mycompany.poc.service.Feedback"> > > > > > > Bundle 2 > > interface=3D"com.mycompany.poc.service.Feedback"> > > > > > > Bundle 3 =3D Client consuming service > > > > filter=3D"(version=3D1)"/> > > > > Here is the definition of the Bundle 3 Manifest > > Import-Service =3D > com.xtrac.poc.service.Feedback > > DynamicImport-Package =3D > com.xtrac.poc.service > > This definition tells the bundle that it has do dynamically loads > classes but in this case, the OSGI runtime will load classes from maybe > Bundle A or bundle B. > > Regards, > > Charles Moulliard > > Apache Committer > > Blog : http://cmoulliard.blogspot.com > Twitter : http://twitter.com/cmoulliard > Linkedin : http://www.linkedin.com/in/charlesmoulliard > Skype: cmoulliard > > > > -- > Christian Schneiderhttp://www.liquid-reality.de > > Open Source Architect > Talend Application Integration Division http://www.talend.com > > --f46d04426bd6430a5904be1cd1f4 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Bundle 1 and Bundle 2 export correctly the packages. This is simply the cli= ent which is not able to loads the classes according to the interface name = only as we have 2 different implementations. When the bundle client starts,= its classloader has to load the classes from bundle 1 or bundle 2. As we a= re using DynamicImport, this is not done at the starting up of the bundle b= ut when the bean is instantiated by blueprint. Nevertheless, we have no pos= sibilities today to tell using DynamicImport that it must loads classes imp= lemented in Bundle 1 or Bundle 2 depending on info provided in the <refe= rence interface=3D"" filter=3D""/> and the filter. T= hat should be a great improvement of OSGI + Blueprint if we could have that= . That will allow us to really design / use OSGI as a modular platform.

On Fri, Apr 20, 2012 at 3:37 PM, Christian S= chneider <c= hris@die-schneider.net> wrote:
=20 =20 =20
I don=B4t think that you can influence this... and honestly I don=B4t think you should.

The clean way of loading impl classes for the service would be to offer two impls of a Factory interface as an OSGi service. So you could define the interfaces at one point and let the Factory service in Bundle1 load the classes from bundle 1 and the Factory service in Bundle2 load those in Bundle2.

Christian

Am 20.04.2012 13:43, schrieb Charles Moulliard:
Hi,

I would like to know if this is possible for a bundle to know based on info defined in the OSGI Service registered in the OSGI Registry that it must loads package by example=A0com.mycompan= y.poc.service.Feedback=A0from a bundle A and not bundle B when its service definition contain a reference to a specific filter ?=A0

Bundle 1=A0

=A0 =A0 <service ref=3D"service" interface=3D"com.mycompany.poc.service.Feedback"><= /div>
=A0 =A0 =A0 =A0 <service-properties>
=A0 =A0 =A0 =A0 =A0 =A0 <entry key=3D"version" = value=3D"1"/>
=A0 =A0 =A0 =A0 </service-properties>
=A0 =A0 </service>

Bundle 2

=A0 =A0 <service ref=3D"service" interface=3D"com.mycompany.poc.service.Feedback"&= gt;
=A0 =A0 =A0 =A0 <service-properties>
=A0 =A0 =A0 =A0 =A0 =A0 <entry key=3D"version&qu= ot; value=3D"2"/>
=A0 =A0 =A0 =A0 </service-properties>
=A0 =A0 </service>

Bundle 3 =3D Client consuming service

=A0<bean id=3D"helloBean" class=3D"com.mycompany.poc.client.HelloBean"><= /div>
=A0 =A0 =A0 <property name=3D"feedbackService&qu= ot;>
=A0 =A0 =A0 =A0 =A0 <reference interface=3D"com.xtrac.poc.service.Feedback" filter=3D"(version=3D1)"/>
=A0 =A0 =A0 </property>
=A0 </bean>

Here is the definition of the Bundle 3 Manifest

Import-Service =3D=A0
com.xtrac.poc= .service.Feedback

DynamicImport-Package =3D=A0
com.xtrac.poc= .service

This definition tells the bundle that it has do dynamically loads classes but in this case, the OSGI runtime will load classes from maybe Bundle A or bundle B.=A0

Regards,

Charles Moulliard

Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard


--=20
Christian Schneider
http://www.liqui=
d-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com 

--f46d04426bd6430a5904be1cd1f4--