Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Using EclipseLink in OSGi with Gemini JPA. Two questions.(Two questions about pooling and connection sharing)
Using EclipseLink in OSGi with Gemini JPA. Two questions. [message #871493] Mon, 14 May 2012 04:39 Go to next message
GianMaria Romanato is currently offline GianMaria Romanato
Messages: 54
Registered: July 2009
Member
Hi,

I am developing an OSGi application that will be deployed in Virgo Tomcat Server.

Persistence is implemented using EclipseLink and the database connections are instantiated via Gemini JPA and a custom DBAccess for PostgreSQL.

I noticed that even if org.osgi.service.jdbc.DataSourceFactory offers methods to create a DataSource and a ConnectionPoolDataSource, EclipseLink/Gemini is always calling createDriver(Properties) and is wrapping the driver instance within a DataSource of its own to create connections.

First question
Is it right to assume that in such a configuration the pooling will be provided by EclipseLink itself? If true, can someone confirm that pooling must be configured via EclipseLink properties such as
eclipselink.jdbc.read-connections.*
and
eclipselink.jdbc.write-connections.*
?

Second question
I understand that the OSGi bluprint specification dictates that each persistence unit should be packaged in its own bundle. I see the advantages of this approach (i.e. maximum modularity, each unity may use different connection parameters etc), but at the same time, this may be not optimal if all the persistence units in a large application must be connected to the same database, because in such case, assuming that pooling is enabled, you would have several different pools of connections to the same database.

Is there a way to overcome this limitation other than packaging all of the units in the same OSGi bundle and merging their persistence.xml files?

For example, I read that EclipseLink supports composite units. Are they usable also in an OSGi environment together with Gemini JPA? Alternatively, is there a way to tell EclipseLink to merge all pools with equal connections parameters?

Thanks a lot.
Giamma.


Re: Using EclipseLink in OSGi with Gemini JPA. Two questions. [message #871689 is a reply to message #871493] Mon, 14 May 2012 13:26 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1016
Registered: July 2009
Senior Member
If you specify the jdbc.url property, you are telling EclipseLink to obtain connections directly from the driver/ConnectionManager. EclipseLink will then use its own internal connection pools, which can be configured using the properties described here:
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_EclipseLink_JPA_Extensions_for_JDBC

Otherwise, you specify a datasource which EclipseLink will lookup from the context, which can be reused on the container.

If you want to use your own datasource, this blog has an example of passing one in:
http://onpersistence.blogspot.com/2008/04/eclipselink-and-datasources.html

As for pools, I would recommend you set one up per application anyway since you can tailor the settings on the applications requirements and usage paterns. This can be helpful as it is common to misconfigure and have one app starving others out for limited connection resources.

Best Regards,
Chris

[Updated on: Mon, 14 May 2012 13:27]

Report message to a moderator

Previous Topic:eclipselink programmatically generate persistentunit
Next Topic:JPQL Query List Parameter Exception
Goto Forum:
  


Current Time: Fri Jul 25 07:30:56 EDT 2014

Powered by FUDForum. Page generated in 0.03122 seconds