-
1. Re: Publishing OSGI Service with Fabric
eminkevich Oct 18, 2014 5:24 AM (in response to aunlu)Here is a blueprint example:
Exposing a service:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:enc="http://karaf.apache.org/xmlns/jasypt/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
<bean id="dbcp_pool" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="$(db.driver)"/>
<property name="url" value="$(db.URL)"/>
<property name="username" value="$(db.user)"/>
<property name="password" value="$(db.password)"/>
<property name="initialSize" value="$(db.initial)"/>
<property name="maxActive" value="$(db.max)"/>
<property name="validationQuery" value="$(db.validationQuery)"/>
<property name="connectionInitSqls">
<list>
<value>ALTER SESSION SET CURRENT_SCHEMA=$(db.schema)</value>
</list>
</property>
</bean>
<service interface="javax.sql.DataSource" ref="dbcp_pool">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/datasource"/>
</service-properties>
</service>
Consuming a service from another bundle (pay attention to ext namespace, version is important):
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:enc="http://karaf.apache.org/xmlns/jasypt/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.2.0"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
">
<reference id="datasource" ext:filter="(osgi.jndi.service.name=jdbc/datasource)" interface="javax.sql.DataSource"/>