1 25 package org.objectweb.easybeans.tests.common.resources; 26 27 import javax.persistence.EntityManager; 28 import javax.persistence.EntityManagerFactory; 29 import javax.persistence.PersistenceUnit; 30 31 import org.objectweb.easybeans.log.JLog; 32 import org.objectweb.easybeans.log.JLogFactory; 33 34 39 public class EMFactoryTester { 40 41 44 private static JLog logger = JLogFactory.getLog(EMFactoryTester.class); 45 46 49 public static final String NAME = "Toto"; 50 51 54 @PersistenceUnit(unitName = "testEntity00") 55 private EntityManagerFactory entityFactory = null; 56 57 60 public EMFactoryTester() { 61 } 62 63 67 protected void access00() throws Exception { 68 checkInstance(entityFactory, NAME); 69 } 70 71 77 public static void checkInstance(final EntityManagerFactory ref, final String name) throws Exception { 78 EntityManager entityManager = ref.createEntityManager(); 79 logger.debug("Checking an entity manager factory reference."); 80 81 if (entityManager == null) { 82 logger.debug("The method createEntityManager() returned null."); 83 throw new IllegalStateException ("Error checking an entity manager factory reference."); 84 } 85 86 EntityManagerTester.checkInstance(entityManager, name); 87 88 logger.debug("Entity manager factory reference is working properly."); 89 } 90 } 91 | Popular Tags |