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 E37319536 for ; Fri, 20 Apr 2012 16:23:48 +0000 (UTC) Received: (qmail 85266 invoked by uid 500); 20 Apr 2012 16:23:48 -0000 Delivered-To: apmail-aries-user-archive@aries.apache.org Received: (qmail 85234 invoked by uid 500); 20 Apr 2012 16:23:48 -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 85223 invoked by uid 99); 20 Apr 2012 16:23:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Apr 2012 16:23:48 +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 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 16:23:44 +0000 Received: by lahm13 with SMTP id m13so8720309lah.23 for ; Fri, 20 Apr 2012 09:23:22 -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=hLhFvy8n92lbXVYBTNafYq8QMCnvA3fNXC8W9QbDoSE=; b=S9WcZg8hl24jks+RAjGwnD7fYmiN7PnLlGzw1tf7LCAgojd/vN6fBoz4s0a0g972i1 yaH6x1Aun2tiDlTyXeZmHKv2vYX0f4IhWFOYvTgH+tOPRn4LCac1XwJ3etqJhDTOJ8d1 ROoWOA8TDITZjqzHH6L5BpLo1xniiD+o1AfYAkYBH7weMw/25DtdWbFwsdnrDyRqNS5g 7+tDObTMI0bos1QPYxACRDBCiNxKTiqBk/XJ989GRHgQ7WmpgS2KvN/40/YfNmx71Mm/ OIUl1Ib4J4Ka51UrldX+HDW+ydMJQgHUvFOPgozUWw8/PuDfqFYvAYAfgb3+N4sHpb8H mvjA== MIME-Version: 1.0 Received: by 10.112.83.5 with SMTP id m5mr3266804lby.10.1334939002232; Fri, 20 Apr 2012 09:23:22 -0700 (PDT) Received: by 10.152.4.103 with HTTP; Fri, 20 Apr 2012 09:23:22 -0700 (PDT) In-Reply-To: <4F918C31.7080207@die-schneider.net> References: <4F91667F.1070402@die-schneider.net> <4F9176FC.9040207@die-schneider.net> <4F918C31.7080207@die-schneider.net> Date: Fri, 20 Apr 2012 18:23:22 +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=14dae9d717ca065ff204be1eb5ea X-Virus-Checked: Checked by ClamAV on apache.org --14dae9d717ca065ff204be1eb5ea Content-Type: text/plain; charset=ISO-8859-1 e-03-06 | Error processing exchange. Exchange[Message: [Body is null]]. Caused by: [java.lang.IllegalArgumentException - java.lang.ClassCastException@2bd040e8] java.lang.IllegalArgumentException: java.lang.ClassCastException@2bd040e8 at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_31] at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_31] at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50) at org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31) at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78) at $Proxy83.sayHello(Unknown Source) at com.mycompany.poc.client.HelloBean.sayHello(HelloBean.java:10)[216:route:1.0.0] On Fri, Apr 20, 2012 at 6:17 PM, Christian Schneider < chris@die-schneider.net> wrote: > If you reference the service with a filter then OSGi will inject the > correct impl object. You will not even need to have a dynamic import as the > impl is installed by the bundle1. > > So this should simply work. What exception do you get? > > Christian > > Am 20.04.2012 17:55, schrieb Charles Moulliard: > > Bundle 1 and Bundle 2 contain a different implementation of the interface > which is exposed as OSGI service > > Bundle 1 > > class="com.mycompany.poc.service.impl.FeedbackTeamWS"/> > > interface="com.mycompany.poc.service.Feedback"> > > > > > > Bundle 2 > > > > interface="com.mycompany.poc.service.Feedback"> > > > > > > So the bundle C do an OSGI lookup to retrieve using as key the interface > name "com.mycompany.poc.service.Feedback", the class implemented in > bundle 1 or bundle 2. > > What would be great is that the bundle C when the following bean is > instantiated loads the class from the bundle 1 as the filter of the > reference to be found corresponds to it > > > filter="(version=1)"/> > > > Intrinsically we know that the class implementing this interface belongs > to bundle 1 as filter = 1 = OSGI service exposed by bundle 1 = class = > com.mycompany.poc.service.impl.FeedbackTeamWS > > > -- > Christian Schneiderhttp://www.liquid-reality.de > > Open Source Architect > Talend Application Integration Division http://www.talend.com > > --14dae9d717ca065ff204be1eb5ea Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
e-03-06 | Error processing exchange. Exchange[Messag= e: [Body is null]]. Caused by: [java.lang.IllegalArgumentException - java.l= ang.ClassCastException@2bd040e8]
java.lang.IllegalArgumentExcepti= on: java.lang.ClassCastException@2bd040e8
at su= n.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
at sun.reflect.D= elegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1= .6.0_31]
at ja= va.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_31]
at org.apache.ari= es.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
at or= g.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
at = org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
at $P= roxy83.sayHello(Unknown Source)
at com.mycompany.poc.client.HelloBean.sayHe= llo(HelloBean.java:10)[216:route:1.0.0]

On Fri, Apr 20, 2012 at 6:17 PM, Christian S= chneider <c= hris@die-schneider.net> wrote:
=20 =20 =20
If you reference the service with a filter then OSGi will inject the correct impl object. You will not even need to have a dynamic import as the impl is installed by the bundle1.

So this should simply work. What exception do you get?

Christian

Am 20.04.2012 17:55, schrieb Charles Moulliard:
Bundle 1 and Bundle 2 conta= in a different implementation of the interface which is exposed as OSGI service

Bundle 1=A0

=A0 =A0<bean id=3D"service" class=3D"com.mycompany.poc.service.impl.FeedbackTeamWS&quo= t;/>

=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 <bean id=3D"service" class=3D"= com.=A0mycompany.p= oc.service.impl.FeedbackT= eamDB"/>

=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>

So the bundle C do an OSGI lookup to retrieve using as key the interface name "com.mycompany.poc.servi= ce.Feedback", the class implemented in bundle 1 or bundle 2.=A0

What would be great is that the bundle C when the following bean is instantiated loads the class from the bundle 1 as the filter of the reference to be found corresponds to it

<property name=3D"feedbackService">
=A0 =A0 <reference interface=3D"com.mycompany.poc.service.Feedback" filter=3D"(version=3D1)"/>=A0
=A0</property>=A0

Intrinsically we know that the class implementing this interface belongs to bundle 1 as filter =3D 1 =3D OSGI service exposed by bundle 1 =3D class =3D=A0com.mycompany.poc.service= .impl.FeedbackTeamWS


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

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

--14dae9d717ca065ff204be1eb5ea--