felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mvangeert...@comcast.net
Subject Re: OSGi Fragment issue/Questions
Date Wed, 25 May 2011 20:04:47 GMT


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" <mattmadhavan@gmail.com> 
To: "general" <general@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 

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*" 
<property name="dataDource" ref="*derbyDataSource*"/> 

*The dataLoader bean never gets created! My datasource bundle def is as 
follows. Any ideas?* 

<bean id="derbyXADataSource" 
<property name="databaseName" value="memory:ITSOBANK" /> 
<property name="createDatabase" value="create" /> 

<service id="xaDataSource" ref="derbyXADataSource" 
<entry key="osgi.jndi.service.name" value="jdbc/bankdb" /> 

<bean id="*derbyDataSource*" 
<property name="databaseName" value="memory:ITSOBANK" /> 

<service ref="derbyDataSource" interface="javax.sql.DataSource"> 
<entry key="osgi.jndi.service.name" value="jdbc/bankdbnojta" /> 

Thanks in advance! 


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