|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hibernate.EmptyInterceptor net.sf.basedb.core.log.LoggingInterceptor
public class LoggingInterceptor
Interceptor that attaches to Hibernate sessions to provide
logging of items that are updated/created/deleted. Do not attach
this interceptor to a SessionFactory
since this class is
not thread-safe.
The interceptor uses onSave
, onDelete
and
onFlushDirty
to collect information about what has happened.
The LogManagerFactory
is asked to create EntityLogger
:s
for each modified/created/deleted item. The actual logging takes place
in the postFlush
method that calls EntityLogger.logChanges(LogManager, EntityDetails)
on each entity logger.
NOTE! For new items, the ID is not available until after the flush
to the database has been done. Eg. new items has a 0 id when
LogManagerFactory.getEntityLogger(LogManager, Object)
is called.
Field Summary | |
---|---|
private List<EntityDetails> |
changes
|
private LogControl |
logControl
|
private LogManager |
logManager
|
private LogManagerFactory |
logManagerFactory
|
private static long |
serialVersionUID
|
Fields inherited from class org.hibernate.EmptyInterceptor |
---|
INSTANCE |
Constructor Summary | |
---|---|
LoggingInterceptor(LogControl logControl,
LogManagerFactory logManagerFactory)
Creates a new interceptor. |
Method Summary | |
---|---|
private void |
addChange(ChangeType action,
Object entity,
Object[] state,
Object[] previousState,
String[] propertyNames,
org.hibernate.type.Type[] types)
If the log manager factory creates an entity logger, add information about the change to the internal list. |
void |
afterTransactionCompletion(org.hibernate.Transaction tx)
Signals successful commit or rollback to the log manager. |
void |
onDelete(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
org.hibernate.type.Type[] types)
Adds a DELETE event to the log. |
boolean |
onFlushDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
org.hibernate.type.Type[] types)
Adds an UPDATE event to the log. |
boolean |
onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
org.hibernate.type.Type[] types)
Adds a CREATE event to the log. |
void |
postFlush(Iterator entities)
Collects all log events and sends them to the each EntityLogger . |
private void |
readObject(ObjectInputStream ois)
|
private void |
writeObject(ObjectOutputStream ois)
|
Methods inherited from class org.hibernate.EmptyInterceptor |
---|
afterTransactionBegin, beforeTransactionCompletion, findDirty, getEntity, getEntityName, instantiate, isTransient, onCollectionRecreate, onCollectionRemove, onCollectionUpdate, onLoad, onPrepareStatement, preFlush |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private final LogControl logControl
private final LogManagerFactory logManagerFactory
private LogManager logManager
private List<EntityDetails> changes
Constructor Detail |
---|
public LoggingInterceptor(LogControl logControl, LogManagerFactory logManagerFactory)
logControl
- The LogControl that is managing the current transactionlogManagerFactory
- The log manager factory to use for loggingMethod Detail |
---|
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)
onSave
in interface org.hibernate.Interceptor
onSave
in class org.hibernate.EmptyInterceptor
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
onFlushDirty
in interface org.hibernate.Interceptor
onFlushDirty
in class org.hibernate.EmptyInterceptor
public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)
onDelete
in interface org.hibernate.Interceptor
onDelete
in class org.hibernate.EmptyInterceptor
public void postFlush(Iterator entities)
EntityLogger
.
postFlush
in interface org.hibernate.Interceptor
postFlush
in class org.hibernate.EmptyInterceptor
public void afterTransactionCompletion(org.hibernate.Transaction tx)
afterTransactionCompletion
in interface org.hibernate.Interceptor
afterTransactionCompletion
in class org.hibernate.EmptyInterceptor
private void addChange(ChangeType action, Object entity, Object[] state, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
postFlush(Iterator)
method.
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
private void writeObject(ObjectOutputStream ois) throws IOException
IOException
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |