You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Matt Madhavan <ma...@gmail.com> on 2011/05/25 16:47:20 UTC
OSGi Fragment issue/Questions
Hello,
I have a simple datasource bundle and I created a fragment bundle called
datasourcefrg with one bean definition The datasource bundle becomes active
and the datasourcefrg fragment successfully resolves.
Problem is that the bean definition inside the fragment never gets
instantiated. Question is Can I even create a bean inside an OSGi fragment?
*My fragment definition is as follows:*
<bean id="*dataLoader*"
class="com.hcsc.itf.osgi.samples.bank.datasource.dataloadfrg.DataLoader">
<property name="dataDource" ref="*derbyDataSource*"/>
</bean>
*The dataLoader bean never gets created! My datasource bundle def is as
follows. Any ideas?*
<bean id="derbyXADataSource"
class="org.apache.derby.jdbc.EmbeddedXADataSource">
<property name="databaseName" value="memory:ITSOBANK" />
<property name="createDatabase" value="create" />
</bean>
<service id="xaDataSource" ref="derbyXADataSource"
interface="javax.sql.XADataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/bankdb" />
</service-properties>
</service>
<bean id="*derbyDataSource*"
class="org.apache.derby.jdbc.EmbeddedDataSource">
<property name="databaseName" value="memory:ITSOBANK" />
</bean>
<service ref="derbyDataSource" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/bankdbnojta" />
</service-properties>
</service>
Thanks in advance!
Matt
Re: OSGi Fragment issue/Questions
Posted by Valentin Mahrwald <vm...@googlemail.com>.
Hi Matt,
as I read section 121.3.4 of the 4.2 enterprise spec the bean definition in the fragment definitely should work. Other than a bug the only thing I can think of is that the fragment is not attached at the time the Blueprint bundle is scanned ...
Regards,
Valentin
On 25 May 2011, at 15:47, Matt Madhavan wrote:
> Hello,
> I have a simple datasource bundle and I created a fragment bundle called datasourcefrg with one bean definition The datasource bundle becomes active and the datasourcefrg fragment successfully resolves.
>
> Problem is that the bean definition inside the fragment never gets instantiated. Question is Can I even create a bean inside an OSGi fragment?
>
> My fragment definition is as follows:
>
> <bean id="dataLoader"
> class="com.hcsc.itf.osgi.samples.bank.datasource.dataloadfrg.DataLoader">
> <property name="dataDource" ref="derbyDataSource"/>
> </bean>
>
>
> The dataLoader bean never gets created! My datasource bundle def is as follows. Any ideas?
>
> <bean id="derbyXADataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource">
> <property name="databaseName" value="memory:ITSOBANK" />
> <property name="createDatabase" value="create" />
> </bean>
>
> <service id="xaDataSource" ref="derbyXADataSource" interface="javax.sql.XADataSource">
> <service-properties>
> <entry key="osgi.jndi.service.name" value="jdbc/bankdb" />
> </service-properties>
> </service>
>
>
> <bean id="derbyDataSource" class="org.apache.derby.jdbc.EmbeddedDataSource">
> <property name="databaseName" value="memory:ITSOBANK" />
> </bean>
>
> <service ref="derbyDataSource" interface="javax.sql.DataSource">
> <service-properties>
> <entry key="osgi.jndi.service.name" value="jdbc/bankdbnojta" />
> </service-properties>
> </service>
>
> Thanks in advance!
>
> Matt
Re: OSGi Fragment issue/Questions
Posted by mv...@comcast.net.
Matt,
In the past I had this issue also, and to overcome it, I converted the database access module into an OSGi service that was configured in a property (configuration) file located in the ./etc directory.
To do this, you would remove all of the hard-coded information from the fragment, and put it into a configuration file. Then, in your database access module, you would inject these as properties using either SpringDM (yuch) or Aries Blueprint (yeah, woo-hoo!) Then, if you need to make a change to your database access bundle's configuration, you simply make the change to your configuraiton file.
Any other bundle that wants to use the database connection from your database connection service would simply get a reference to the service.
Please let me know if this helps.
----- Original Message -----
From: "Matt Madhavan" <ma...@gmail.com>
To: "general" <ge...@lists.ops4j.org>, users@felix.apache.org, user@aries.apache.org
Sent: Wednesday, May 25, 2011 10:47:20 AM
Subject: OSGi Fragment issue/Questions
Hello,
I have a simple datasource bundle and I created a fragment bundle called
datasourcefrg with one bean definition The datasource bundle becomes active
and the datasourcefrg fragment successfully resolves.
Problem is that the bean definition inside the fragment never gets
instantiated. Question is Can I even create a bean inside an OSGi fragment?
*My fragment definition is as follows:*
<bean id="*dataLoader*"
class="com.hcsc.itf.osgi.samples.bank.datasource.dataloadfrg.DataLoader">
<property name="dataDource" ref="*derbyDataSource*"/>
</bean>
*The dataLoader bean never gets created! My datasource bundle def is as
follows. Any ideas?*
<bean id="derbyXADataSource"
class="org.apache.derby.jdbc.EmbeddedXADataSource">
<property name="databaseName" value="memory:ITSOBANK" />
<property name="createDatabase" value="create" />
</bean>
<service id="xaDataSource" ref="derbyXADataSource"
interface="javax.sql.XADataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/bankdb" />
</service-properties>
</service>
<bean id="*derbyDataSource*"
class="org.apache.derby.jdbc.EmbeddedDataSource">
<property name="databaseName" value="memory:ITSOBANK" />
</bean>
<service ref="derbyDataSource" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/bankdbnojta" />
</service-properties>
</service>
Thanks in advance!
Matt