nl.knowledgeplaza.util.jpa
Class EntityManagerFinderSwing
java.lang.Object
nl.knowledgeplaza.util.jpa.EntityManagerFinder
nl.knowledgeplaza.util.jpa.EntityManagerFinderThread
nl.knowledgeplaza.util.jpa.EntityManagerFinderSwing
public class EntityManagerFinderSwing
- extends EntityManagerFinderThread
This is a combination of a focus based and thread based.
First a check is done if there is a EM associated with this thread.
If not and the current thread is the EDT, then a check is done if a EM is associated with the component that currently has the focus.
If not, then its parent component is checked.
This does require some special coding in the application, when using threads:
final EntityManager lEntityManager = EntityManagerFinder.find();
new Thread( new Runnable() { public void run()
{
EntityManagerFinderSwing.associateWithCurrentThread(lEntityManager);
//...
SwingUtilities.invokeLater( new Runnable() { public void run()
{
EntityManagerFinderSwing.associateWithCurrentThread(lEntityManager);
// ...
EntityManagerFinderSwing.deassociateFromCurrentThread(); // reused threads need explicit deassociations
} } );
//...
}}).start();
- Version:
- $Revision: 1.2 $
|
Method Summary |
static void |
associate(java.awt.Component c,
javax.persistence.EntityManager em)
|
static void |
deassociate(java.awt.Component c)
|
static javax.persistence.EntityManager |
getAssociation(java.awt.Component c)
|
javax.persistence.EntityManager |
getEntityManager(java.lang.Object context)
|
static void |
register()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EntityManagerFinderSwing
public EntityManagerFinderSwing()
getEntityManager
public javax.persistence.EntityManager getEntityManager(java.lang.Object context)
- Overrides:
getEntityManager in class EntityManagerFinderThread
register
public static void register()
associate
public static void associate(java.awt.Component c,
javax.persistence.EntityManager em)
deassociate
public static void deassociate(java.awt.Component c)
getAssociation
public static javax.persistence.EntityManager getAssociation(java.awt.Component c)
Copyright © 2010. All Rights Reserved.