Search in sources :

Example 1 with OpenJPAEntityManagerSPI

use of org.apache.openjpa.persistence.OpenJPAEntityManagerSPI in project tomee by apache.

the class JpaCmpEngine method registerListener.

private synchronized void registerListener(final EntityManager entityManager) {
    if (entityManager instanceof OpenJPAEntityManagerSPI) {
        final OpenJPAEntityManagerSPI openjpaEM = (OpenJPAEntityManagerSPI) entityManager;
        final OpenJPAEntityManagerFactorySPI openjpaEMF = (OpenJPAEntityManagerFactorySPI) openjpaEM.getEntityManagerFactory();
        if (entityManagerListener == null) {
            entityManagerListener = new OpenJPALifecycleListener();
        }
        openjpaEMF.addLifecycleListener(entityManagerListener, (Class[]) null);
        return;
    }
    final Object delegate = entityManager.getDelegate();
    if (delegate != entityManager && delegate instanceof EntityManager) {
        registerListener((EntityManager) delegate);
    }
}
Also used : OpenJPAEntityManagerSPI(org.apache.openjpa.persistence.OpenJPAEntityManagerSPI) EntityManager(javax.persistence.EntityManager) OpenJPAEntityManagerFactorySPI(org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject)

Aggregations

EJBLocalObject (javax.ejb.EJBLocalObject)1 EJBObject (javax.ejb.EJBObject)1 EntityManager (javax.persistence.EntityManager)1 OpenJPAEntityManagerFactorySPI (org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI)1 OpenJPAEntityManagerSPI (org.apache.openjpa.persistence.OpenJPAEntityManagerSPI)1