camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject Re: Accessing an osgi service interface from another bundle
Date Thu, 13 Mar 2014 13:59:02 GMT
If Spring DM is able to resolve the OSGi reference correctly,
'mappingservice' becomes a local bean in the Spring Context of the second
bundle.

This means that you can inject it around like any other bean.

For example:

    <bean id="abcd" class="com.ab.mypgm" init-method="init"
destroy-method="destroy">
        <property name="service" ref="mappingservice" />
    </bean>

... provided that com.ab.mypgm has a setter for property "service", e.g.
public void setService(MappingInterface service).

Or you could use it from Camel:

   .to("bean:mappingservice?method=blabla").

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Thu, Mar 13, 2014 at 1:22 PM, vs_mahesh <vsmahesh111@yahoo.co.in> wrote:

> Hi ,
>
> I have created 2 bundles
> 1)osgi service bundle
> *whose camel-context.xml i*s
>
>  <bean id="incidentService"
> class="com.outotec.uom.mapping.MappingInterfaceImpl">
>
>     </bean>
>
> <osgi:service id="mappingservice"
> interface="com.outotec.uom.mapping.MappingInterface" ref="incidentService"
> />
>
> pom.xml includes maven bundle plugin with export option
>
>
>       <plugin>
>         <groupId>org.apache.felix</groupId>
>         <artifactId>maven-bundle-plugin</artifactId>
>         <version>2.3.4</version>
>         <extensions>true</extensions>
>         <configuration>
>
>         <instructions>
>         <Private-Package>
>    com.outotec.uom.mapping.MappingInterfaceImpl
>     </Private-Package>
>     <Export-Package>
>
>   com.outotec.uom.mapping*
>     </Export-Package>
>                 <Import-Package>*,
>                 </Import-Package>
>                 <DynamicImport-Package> *</DynamicImport-Package>
>
>                 <osgiManifest>
>
>     <bundleActivator>auto-detect</bundleActivator>
>   </osgiManifest>
>
>                 </instructions>
>         </configuration>
>       </plugin>
>
> 2)from the second bundle am trying to acess the interface in the first osgi
> bundle
>
> the camel-context.xml contains a reference to the service
>
>   <osgi:reference id="mappingservice" interface="com..MappingInterface"  />
>
> I have a bean which needs to access the interface from the first bundle
>
>  <bean id="abcd"
>       class="com.ab.mypgm"
>      init-method="init" destroy-method="destroy">
>    >
>
> <bI want to know How to access the interface of the first bundle which is
> exposed as a service  from the bean class of the second bundle ?</b>
>
> The pom file for the second file contains the following bundle plugin
> config
>  <plugin>
>         <groupId>org.apache.felix</groupId>
>         <artifactId>maven-bundle-plugin</artifactId>
>         <version>2.3.4</version>
>         <extensions>true</extensions>
>         <configuration>
>
>         <instructions>
>                 <Import-Package>*,
>                 com.outotec.uom.mapping,
>                 </Import-Package>
>                 </instructions>
>         </configuration>
>       </plugin>
>
> Thanks,
> Mahesh
>
>
>
>
> -----
> Thanks And regards,
> Mahesh
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Accessing-an-osgi-service-interface-from-another-bundle-tp5748769.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message