|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.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,
Type[] types)
If the log manager factory creates an entity logger, add information about the change to the internal list. |
void |
afterTransactionCompletion(Transaction tx)
Signals successful commit or rollback to the log manager. |
void |
onDelete(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
Adds a DELETE event to the log. |
boolean |
onFlushDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types)
Adds an UPDATE event to the log. |
boolean |
onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
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 logging| Method Detail |
|---|
public boolean onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
onSave in interface InterceptoronSave in class EmptyInterceptor
public boolean onFlushDirty(Object entity,
Serializable id,
Object[] currentState,
Object[] previousState,
String[] propertyNames,
Type[] types)
onFlushDirty in interface InterceptoronFlushDirty in class EmptyInterceptor
public void onDelete(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types)
onDelete in interface InterceptoronDelete in class EmptyInterceptorpublic void postFlush(Iterator entities)
EntityLogger.
postFlush in interface InterceptorpostFlush in class EmptyInterceptorpublic void afterTransactionCompletion(Transaction tx)
afterTransactionCompletion in interface InterceptorafterTransactionCompletion in class EmptyInterceptor
private void addChange(ChangeType action,
Object entity,
Object[] state,
Object[] previousState,
String[] propertyNames,
Type[] types)
postFlush(Iterator) method.
private void readObject(ObjectInputStream ois)
throws ClassNotFoundException,
IOException
ClassNotFoundException
IOException
private void writeObject(ObjectOutputStream ois)
throws IOException
IOException
|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||