sharing persistence unit between apps

View: New views
3 Messages — Rating Filter:   Alert me  

sharing persistence unit between apps

by ymajoros :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

We have several applications which used to share a toplink server session, so they shared the cache. They are all running on the same server and need to know about each other's changes.

Is the same possible with EclipseLink? I'd expect that sharing a persistence unit could do the trick. Is this possible? Or is there another way to share the server session? This stops us from migrating from toplink 10 (non-jpa) to eclipselink (jpa) for now, I'd really like to find some solution.

Re: sharing persistence unit between apps

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This should work fine if you put the persistence unit of the server's applib (server's shared classpath) and access it as application managed (i.e. Persistence.class).  I don't think there is any way to access it as container managed, (i.e. injection), (although you could try, it might work).

Weaving will most likely not occur, so you could statically weave your jar.


ymajoros wrote:
Hi,

We have several applications which used to share a toplink server session, so they shared the cache. They are all running on the same server and need to know about each other's changes.

Is the same possible with EclipseLink? I'd expect that sharing a persistence unit could do the trick. Is this possible? Or is there another way to share the server session? This stops us from migrating from toplink 10 (non-jpa) to eclipselink (jpa) for now, I'd really like to find some solution.

Re: sharing persistence unit between apps

by ymajoros () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, I'm not sure. We really need some injection, and I'd need to be sure it's a feature and we don't get it by accident. So, I look at the sources. I'm not quite sure, but I found this in EntityManagerSetupImpl.java:

line 712:
            session = new ServerSession(new Project(new DatabaseLogin()));            

(comment before try-block:         // state is INITIAL, PREDEPLOY_FAILED or UNDEPLOYED )

 I checked all non-null assignments of the session field, and it seems it's the only one we should be concerned with, the other one being in an "if (isSessionLoadedFromSessionsXML)"-block. Or could sessions.xml help?

 Any more information?

 Anyway, I'll keep you informed of the progress I'll make; I'll rewrite some classes if needed, I know it's a bad idea, but we need that feature. Should someone know some better way, please let me know ;-)

James Sutherland wrote:
This should work fine if you put the persistence unit of the server's applib (server's shared classpath) and access it as application managed (i.e. Persistence.class).  I don't think there is any way to access it as container managed, (i.e. injection), (although you could try, it might work).

Weaving will most likely not occur, so you could statically weave your jar.