org.compass.gps.device.jpa.lifecycle
Class HibernateJpaEntityLifecycleInjector

java.lang.Object
  extended by org.compass.gps.device.jpa.lifecycle.HibernateJpaEntityLifecycleInjector
All Implemented Interfaces:
JpaEntityLifecycleInjector
Direct Known Subclasses:
HibernateJpaEntityCollectionLifecycleInjector

public class HibernateJpaEntityLifecycleInjector
extends Object
implements JpaEntityLifecycleInjector

Injects lifecycle listeners directly into Hibernate for mirroring operations.

By default, registers with plain insert/update/delete listeners, which will be triggered by Hibernate before committing (and up to Hibernate flushing logic). Also allows to be created with setting the registerPostCommitListeneres to true which will cause the insert/update/delete listeneres to be registered as post commit events.

Author:
kimchy

Nested Class Summary
static class HibernateJpaEntityLifecycleInjector.HibernateEventListener
           
 
Field Summary
protected  boolean registerPostCommitListeneres
           
 
Constructor Summary
HibernateJpaEntityLifecycleInjector()
           
HibernateJpaEntityLifecycleInjector(boolean registerPostCommitListeneres)
          Creates a new lifecycle injector.
 
Method Summary
protected  Object doCreateListener(JpaGpsDevice device)
           
 void injectLifecycle(javax.persistence.EntityManagerFactory entityManagerFactory, JpaGpsDevice device)
          Injects a global lifecycle listener into the concrete EntityManagerFactory implementation.
 void removeLifecycle(javax.persistence.EntityManagerFactory entityManagerFactory, JpaGpsDevice device)
          Removes (if possible) lifecycle listeners injected using the inject method.
 boolean requireRefresh()
          Does this injector requires refreshing (i.e. remove and inject) of new listeners upon CompassGpsDevice.refresh().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registerPostCommitListeneres

protected final boolean registerPostCommitListeneres
Constructor Detail

HibernateJpaEntityLifecycleInjector

public HibernateJpaEntityLifecycleInjector()

HibernateJpaEntityLifecycleInjector

public HibernateJpaEntityLifecycleInjector(boolean registerPostCommitListeneres)
Creates a new lifecycle injector. Allows to control if the insert/update/delete even listeners will be registered with post commit listeres (flag it true) or with plain post events (triggered based on Hibrenate flushing logic).

Parameters:
registerPostCommitListeneres - true if post commit listeners will be registered. false for plain listeners.
Method Detail

requireRefresh

public boolean requireRefresh()
Description copied from interface: JpaEntityLifecycleInjector
Does this injector requires refreshing (i.e. remove and inject) of new listeners upon CompassGpsDevice.refresh().

Specified by:
requireRefresh in interface JpaEntityLifecycleInjector

injectLifecycle

public void injectLifecycle(javax.persistence.EntityManagerFactory entityManagerFactory,
                            JpaGpsDevice device)
                     throws JpaGpsDeviceException
Description copied from interface: JpaEntityLifecycleInjector
Injects a global lifecycle listener into the concrete EntityManagerFactory implementation.

Specified by:
injectLifecycle in interface JpaEntityLifecycleInjector
Parameters:
entityManagerFactory - The EntityManagerFactory to inject the global lifecycle to.
device - The Jpa device calling this injector
Throws:
JpaGpsDeviceException

removeLifecycle

public void removeLifecycle(javax.persistence.EntityManagerFactory entityManagerFactory,
                            JpaGpsDevice device)
                     throws JpaGpsDeviceException
Description copied from interface: JpaEntityLifecycleInjector
Removes (if possible) lifecycle listeners injected using the inject method.

Specified by:
removeLifecycle in interface JpaEntityLifecycleInjector
Parameters:
entityManagerFactory - The EMF to remove lifecycle from
device - The Jpa device calling
Throws:
JpaGpsDeviceException

doCreateListener

protected Object doCreateListener(JpaGpsDevice device)


Copyright (c) 2004-2009 The Compass Project.