Using EclipseLink in OSGi with Gemini JPA. Two questions. [message #871493] |
Mon, 14 May 2012 04:39  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.24790 seconds