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


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" <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 

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 

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