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.6 $
| Methods inherited from class nl.knowledgeplaza.util.jpa.EntityManagerFinder |
find, find, findEntityManager, getEMAssociation, getEMAssociation, getEntityManagerFinder, removeAssociation, removeEMAssociation, setEMAssociation, setEMAssociation, setEntityManagerFinder |
| 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(Object context)
- Overrides:
getEntityManager in class EntityManagerFinderThread
register
public static void register()
associate
public static void associate(Component c,
javax.persistence.EntityManager em)
- Parameters:
c - em -
deassociate
public static void deassociate(Component c)
- Parameters:
c -
getAssociation
public static javax.persistence.EntityManager getAssociation(Component c)
- Parameters:
c -
- Returns:
Copyright © 2012 KnowledgePlaza. All Rights Reserved.