Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-dev] Compass Interatino with Eclipse Link

Shay,

Thanks for your efforts and the feedback provided. I have commented on your requests below.

Cheers,

Doug

-----Original Message-----
From: eclipselink-dev-bounces@xxxxxxxxxxx
[mailto:eclipselink-dev-bounces@xxxxxxxxxxx]On Behalf Of Shay Banon
Sent: Saturday, January 19, 2008 2:56 PM
To: eclipselink-dev@xxxxxxxxxxx
Subject: [eclipselink-dev] Compass Interatino with Eclipse Link



Hi,

   First, I wanted to share with you the fact that Compass now integrates
with EclipseLink. Aside from its generic support for EclipseLink, it also
support "Embedded EclipseLink", have a look here:
http://www.opensymphony.com/compass/versions/2.0M1-SNAPSHOT/html/gps-embeddedeclipselink.html

   With the embedded support I had to hack around several places that I wish
would be nicer. So, I am asking if what I did and what I purpose make sense.
The integration itself uses EclipseLink support for SessionCustomizer where
I can get a hold of the Session and then Configure Compass with it. This is
the best "embedded" integration point that I could find. Doing so, I found a
few problems that I would like to solve better:

1. I need to get a hold of the properties defined within the persistence.xml
file in order to read Compass configuration properties.
Session#getProeprties() only returns properties passed programatically. Is
there a chance to add Session#getMergedProperties() to return all of them?

DOUG: I have asked in the past to have the properties provided for the creation of the EntityManagerFactory to be included in the server session's properties. This is also true of properties provided to create an EntityManager as well as Query hints. Having access to these values increases extensibility.

See: http://bugs.eclipse.org/216554

2. I need to know if the transaction type is JTA or RESOURCE_LOCAL so I can
configure Compass with the correct transaction mechanism.

The easiest way to do this is to access the shared Server session and ask it: server.hasExternalTransactionController()

http://www.eclipse.org/eclipselink/api/1.0/org/eclipse/persistence/sessions/Session.html#hasExternalTransactionController()

1 and 2 were solved by using the
EntityManagerFactoryProvider#getEntityManagerSetupImpl, and based on
knowledge of how a session name is constructed to extract the persistence
unit name :). Not nice, and won't work when a custom session name will be
provided.

DOUG: If you have an EclipseLink EntityManager or EntityManagerFactory we have simplified accessing the underlying EclipseLink implementation classes using static methods on JpaHelper(org.eclipse.persistence.jpa).

http://www.eclipse.org/eclipselink/api/1.0/org/eclipse/persistence/jpa/JpaHelper.html

If you have the EMF simply call JpaHelper.getServerSession(EMF)

3. I add a SessionEventListener in order to hook into transaction lifecycle
methods. It would be nice if there was an onClose event where I can also
shutdown Compass correctly. Currently, I am doing it in the finalize method
(not nice at all). Is there another way to know that a session was closed?

DOUG: I thought there was a pre/postLogout event on the SessionEventListener. Can you file a bug that covers your requirements for this?

Last, it would be great if you had, in the same manner that you have
JpaEntityManager, also a JpaEntityManagerFactory interface, which at least
returns the ServerSession. This way, I can work with it without resulting
into openning and closing an EntityManager, and also be able to work in
environments where the EntityManagerFactory is proxied.

DOUG: I am hoping that JpaHelper addresses much of the requirements here. In the case where a container is providing an EntityManager proxy there may not be a real EntityManager behind the scene. In the case of non-transactional reads the EntityManager only exists within the proxy when needed. If you require an EntityManger and none is returned from JpaHelper you should access the EntityManagerFactory and create an EM that you manage and close when finished.

Another last, though a bigger change. The best thing for the integration
would be the ability to store custom "attributes" on both the
EntityManagerFactory and EntityManager. This will allow me to associate a
Compass instance with the EMF and a CompassSession with the EM without
resulting into instnaceof checks of event listeners. This would make the
integration so much nicer... .

DOUG: I believe the above mentioned enhancement request (http://bugs.eclipse.org/216554) will address this requirement. If you have more specific needs please add them to the bug description.

What say you?

Cheers,
Shay Banon
--
View this message in context: http://www.nabble.com/Compass-Interatino-with-Eclipse-Link-tp14974470p14974470.html
Sent from the EclipseLink - Dev mailing list archive at Nabble.com.

_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev



Back to the top