net.sf.jzeno.model
Class AbstractInterceptor
java.lang.Object
net.sf.jzeno.model.AbstractInterceptor
- All Implemented Interfaces:
- org.hibernate.Interceptor
public class AbstractInterceptor
- extends java.lang.Object
- implements org.hibernate.Interceptor
This singleton is the general interceptor for the application and is set when
creating the session in the aspects. It simply delegates to the corresponding
operation on the entity itself, allowing us to implement hibernate events on
the entities.
It also trigger state transition checks through the use of a state manager.
Every entity can implement such a StateManager by overriding the
getStateManager() method.
It also updates the DomainCache in case of modifications made to entities
that were being cached.
Method Summary |
void |
afterTransactionBegin(org.hibernate.Transaction tx)
|
void |
afterTransactionCompletion(org.hibernate.Transaction tx)
|
void |
beforeTransactionCompletion(org.hibernate.Transaction tx)
|
static void |
clearCreatedEntities()
|
int[] |
findDirty(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] currentState,
java.lang.Object[] previousState,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
|
static java.util.List |
getCreatedEntities()
|
java.lang.Object |
getEntity(java.lang.String entityName,
java.io.Serializable id)
|
java.lang.String |
getEntityName(java.lang.Object object)
|
static AbstractInterceptor |
getInstance()
|
java.lang.Object |
instantiate(java.lang.Class clazz,
java.io.Serializable id)
|
java.lang.Object |
instantiate(java.lang.String entityName,
org.hibernate.EntityMode entityMode,
java.io.Serializable id)
|
static boolean |
isTraceCreation()
|
java.lang.Boolean |
isTransient(java.lang.Object entity)
|
java.lang.Boolean |
isUnsaved(java.lang.Object entity)
|
void |
onCollectionRecreate(java.lang.Object collection,
java.io.Serializable key)
|
void |
onCollectionRemove(java.lang.Object collection,
java.io.Serializable key)
|
void |
onCollectionUpdate(java.lang.Object collection,
java.io.Serializable key)
|
void |
onDelete(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] state,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
|
boolean |
onFlushDirty(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] currentState,
java.lang.Object[] previousState,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
|
boolean |
onLoad(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] state,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
|
java.lang.String |
onPrepareStatement(java.lang.String sql)
|
boolean |
onSave(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] state,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
|
void |
postFlush(java.util.Iterator entities)
|
void |
preFlush(java.util.Iterator entities)
|
static void |
setTraceCreation(boolean traceCreation)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
getInstance
public static AbstractInterceptor getInstance()
findDirty
public int[] findDirty(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] currentState,
java.lang.Object[] previousState,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
- Specified by:
findDirty
in interface org.hibernate.Interceptor
- See Also:
Interceptor.findDirty(java.lang.Object,
java.io.Serializable, java.lang.Object[], java.lang.Object[],
java.lang.String[], org.hibernate.type.Type[])
instantiate
public java.lang.Object instantiate(java.lang.Class clazz,
java.io.Serializable id)
throws org.hibernate.CallbackException
- Throws:
org.hibernate.CallbackException
- See Also:
org.hibernate.Interceptor#instantiate(java.lang.Class,
java.io.Serializable)
isUnsaved
public java.lang.Boolean isUnsaved(java.lang.Object entity)
- See Also:
org.hibernate.Interceptor#isUnsaved(java.lang.Object)
onDelete
public void onDelete(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] state,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
throws org.hibernate.CallbackException
- Specified by:
onDelete
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
Interceptor.onDelete(java.lang.Object,
java.io.Serializable, java.lang.Object[], java.lang.String[],
org.hibernate.type.Type[])
onFlushDirty
public boolean onFlushDirty(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] currentState,
java.lang.Object[] previousState,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
throws org.hibernate.CallbackException
- Specified by:
onFlushDirty
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
Interceptor.onFlushDirty(java.lang.Object,
java.io.Serializable, java.lang.Object[], java.lang.Object[],
java.lang.String[], org.hibernate.type.Type[])
onLoad
public boolean onLoad(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] state,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
throws org.hibernate.CallbackException
- Specified by:
onLoad
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
Interceptor.onLoad(java.lang.Object,
java.io.Serializable, java.lang.Object[], java.lang.String[],
org.hibernate.type.Type[])
onSave
public boolean onSave(java.lang.Object entity,
java.io.Serializable id,
java.lang.Object[] state,
java.lang.String[] propertyNames,
org.hibernate.type.Type[] types)
throws org.hibernate.CallbackException
- Specified by:
onSave
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
Interceptor.onSave(java.lang.Object,
java.io.Serializable, java.lang.Object[], java.lang.String[],
org.hibernate.type.Type[])
postFlush
public void postFlush(java.util.Iterator entities)
throws org.hibernate.CallbackException
- Specified by:
postFlush
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
Interceptor.postFlush(java.util.Iterator)
preFlush
public void preFlush(java.util.Iterator entities)
throws org.hibernate.CallbackException
- Specified by:
preFlush
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
- See Also:
Interceptor.preFlush(java.util.Iterator)
getCreatedEntities
public static java.util.List getCreatedEntities()
clearCreatedEntities
public static void clearCreatedEntities()
isTraceCreation
public static boolean isTraceCreation()
setTraceCreation
public static void setTraceCreation(boolean traceCreation)
onCollectionRecreate
public void onCollectionRecreate(java.lang.Object collection,
java.io.Serializable key)
throws org.hibernate.CallbackException
- Specified by:
onCollectionRecreate
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
onCollectionRemove
public void onCollectionRemove(java.lang.Object collection,
java.io.Serializable key)
throws org.hibernate.CallbackException
- Specified by:
onCollectionRemove
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
onCollectionUpdate
public void onCollectionUpdate(java.lang.Object collection,
java.io.Serializable key)
throws org.hibernate.CallbackException
- Specified by:
onCollectionUpdate
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
isTransient
public java.lang.Boolean isTransient(java.lang.Object entity)
- Specified by:
isTransient
in interface org.hibernate.Interceptor
instantiate
public java.lang.Object instantiate(java.lang.String entityName,
org.hibernate.EntityMode entityMode,
java.io.Serializable id)
throws org.hibernate.CallbackException
- Specified by:
instantiate
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
getEntityName
public java.lang.String getEntityName(java.lang.Object object)
throws org.hibernate.CallbackException
- Specified by:
getEntityName
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
getEntity
public java.lang.Object getEntity(java.lang.String entityName,
java.io.Serializable id)
throws org.hibernate.CallbackException
- Specified by:
getEntity
in interface org.hibernate.Interceptor
- Throws:
org.hibernate.CallbackException
afterTransactionBegin
public void afterTransactionBegin(org.hibernate.Transaction tx)
- Specified by:
afterTransactionBegin
in interface org.hibernate.Interceptor
beforeTransactionCompletion
public void beforeTransactionCompletion(org.hibernate.Transaction tx)
- Specified by:
beforeTransactionCompletion
in interface org.hibernate.Interceptor
afterTransactionCompletion
public void afterTransactionCompletion(org.hibernate.Transaction tx)
- Specified by:
afterTransactionCompletion
in interface org.hibernate.Interceptor
onPrepareStatement
public java.lang.String onPrepareStatement(java.lang.String sql)
- Specified by:
onPrepareStatement
in interface org.hibernate.Interceptor