camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Westermann <MarWesterm...@gmx.de>
Subject Re: Accessing an osgi service interface from another bundle
Date Thu, 13 Mar 2014 14:02:44 GMT
Hi Mahesh,

bundle 1 looks good so far. in your second bundle do the following:

ad an instance variable to your bean which is of type of the interface like:

class mypgm {

private com.outotec.uom.mapping.MappingInterface mappingService = null;

// here getter + setter for mappingService
}

then add a property to your bean definition in blueprint

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

</bean>

Now when the bean com.ab.mypgm is instanciated the impl. of the service is injected to the
bean.

regards, Marco






Am 13.03.2014 14:22, schrieb vs_mahesh:
> 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 ?&lt;/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
View raw message