You can have a look to mytutorial --> http://camel.apache.org/tutorial-osgi-camel-part2.html

I will update it soon to use openJpa + Aries JPA + AriesTransaction instead of Spring + Hibernate

On 20/11/10 18:35, Johan Edstrom wrote:
http://camel.apache.org/tutorials.html

The second to last tutorial, Reportincident shows you all of these concepts.


On Nov 19, 2010, at 2:45 PM, Mike Van wrote:



Achim,



That's very interesting. I'd be interested in seeing examples of what your'e 
talking about, if you can point me in the right direction.



v/r,



Mike Van


----- Original Message -----
From: "Achim Nierbeck [via 
Karaf]"<[email protected]>
To: "Mike Van"<[email protected]>
Sent: Friday, November 19, 2010 4:15:59 PM
Subject: Re: Accessing database connections using SpringDM in Karaf

Hi,

if you don't want spring to start the application context, move your
spring files to another directory.
You might also take a look at the spring-dm documentation about what you
can do to influence the starting behavior.

BTW. do you know that you can let do spring take care of DataSources?
You can even
configure a datasource as a osgi-service and spring-dm or blueprint can
take care of injecting this datasource service.

greetings, achim


https://github.com/ANierbeck/jmx-webconsole
Ok,  This is a doozy.

I'm using Karaf 2.0.0,  with SpringDM.

My OSGi application has a database-access bundle which contains two
applicationContext.xml files in the META-INF/spring directory.  One of these
xml files creates a bean called myAppDataSourceController, which provides
access to our database via the associated pojo.  All this deploys properly
and I'm able to verify the database connection.

To test whether it works, I've created a simple Spring testHarness
consisting of one class (DAOTest.java) which attempts to use my
database-access bundle to connect to the database and write a column in a
table. It als has a testApplicationContext.xml file which creates a bean,
and references the method that begins the test in DAOTest.java.  This is
failing.

In my old non-osgi implementation, I had a DataSourceControllerFactory class
whose static final inner-class (named Holder) looks as such:

// non-important bits removed
private static final class Holder {

    private static final DataSourceController INSTANCE;

    static {
     final String[] contexts = {
      "META-INF/spring/ControllerAppContext.xml",
      "META-INF/spring/DataSourceAppContext.xml" };

     final ApplicationContext ctx = new
ClassPathXmlApplicationContext(contexts);
     INSTANCE = {DataSourceController}
ctx.getBean("myAppDataSourceController");

    }

}

I use this class to enforce the singleton pattern we are using.  The
enclosing class has one major method:
public static final DataSourceController getInstance() {
    try {
     return Holder.INSTANCE;
    } catch statement stuff...

}

When another part of the application tried to access the database, it would
call DataSourceControllerFactory.getInstance(), to get a copy of the
DataSourceController which would provide database access.

Is there a similar way to access a database from within Karaf?  Obviously,
this way isn't going to work as SpringDM evaluates the context.xml files,
and creates a connection before the above methods are called. In fact,
calling the above methods results in an attempt to read the context files
again, but from the module attempting to get a handle to the database
connection.

Anyhow, before this gets too long, I'm just looking for OSGi friendly
suggestions to access our database.  Can anyone help me out?

Mike Van



View message @ 
http://karaf.922171.n3.nabble.com/Accessing-database-connections-using-SpringDM-in-Karaf-tp1932916p1932992.html
To start a new topic under Karaf - User, email 
[email protected]
To unsubscribe from Karaf - User, click here .
--
View this message in context: 
http://karaf.922171.n3.nabble.com/Accessing-database-connections-using-SpringDM-in-Karaf-tp1932916p1933143.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to