org.springframework.orm.hibernate.support
Class ChainedInterceptorSupport

java.lang.Object
  extended by org.springframework.orm.hibernate.support.ChainedInterceptorSupport
All Implemented Interfaces:
net.sf.hibernate.Interceptor
Direct Known Subclasses:
DependencyInjectionInterceptorFactoryBean.DependencyInjectionInterceptor

public abstract class ChainedInterceptorSupport
extends java.lang.Object
implements net.sf.hibernate.Interceptor

Support class for Hibernate interceptors that participate in a chain. Suggested by Seth Ladd and based by code contributed by Oliver Hutchison. Necessary as Hibernate does not support native chaining of interceptors.
Implements all Interceptor methods as no ops. Abstract as it will do nothing unless a subclass overrides one or more methods. Any methods that are not handled by the subclass will delegate to the next interceptor in the chain.

Since:
1.2
Author:
Rod Johnson
See Also:
Interceptor

Field Summary
protected  org.apache.log4j.Logger log
           
 
Constructor Summary
ChainedInterceptorSupport()
           
 
Method Summary
 int[] findDirty(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.String[] propertyNames, net.sf.hibernate.type.Type[] types)
           
 net.sf.hibernate.Interceptor getNextInterceptor()
           
 java.lang.Object instantiate(java.lang.Class beanClass, java.io.Serializable id)
           
 java.lang.Boolean isUnsaved(java.lang.Object entity)
           
 void onDelete(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, net.sf.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, net.sf.hibernate.type.Type[] types)
           
 boolean onLoad(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, net.sf.hibernate.type.Type[] types)
           
 boolean onSave(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, net.sf.hibernate.type.Type[] types)
           
 void postFlush(java.util.Iterator entities)
           
 void preFlush(java.util.Iterator entities)
           
protected  void setIdOnNewEntity(net.sf.hibernate.SessionFactory sessionFactory, java.lang.Class persistentClass, java.io.Serializable id, java.lang.Object newEntity)
          Convenience methods subclasses can use to apply the id to a new entity if they override the instantiate method.
 void setNextInterceptor(net.sf.hibernate.Interceptor nextInterceptor)
          As Hibernate doesn't support chaining of interceptors natively, we add the ability for chaining via a delegate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.log4j.Logger log
Constructor Detail

ChainedInterceptorSupport

public ChainedInterceptorSupport()
Method Detail

setNextInterceptor

public void setNextInterceptor(net.sf.hibernate.Interceptor nextInterceptor)
As Hibernate doesn't support chaining of interceptors natively, we add the ability for chaining via a delegate.

Parameters:
nextInterceptor -

getNextInterceptor

public net.sf.hibernate.Interceptor getNextInterceptor()

instantiate

public java.lang.Object instantiate(java.lang.Class beanClass,
                                    java.io.Serializable id)
                             throws net.sf.hibernate.CallbackException
Specified by:
instantiate in interface net.sf.hibernate.Interceptor
Throws:
net.sf.hibernate.CallbackException
See Also:
Interceptor.instantiate(java.lang.Class, java.io.Serializable)

onLoad

public boolean onLoad(java.lang.Object entity,
                      java.io.Serializable id,
                      java.lang.Object[] state,
                      java.lang.String[] propertyNames,
                      net.sf.hibernate.type.Type[] types)
               throws net.sf.hibernate.CallbackException
Specified by:
onLoad in interface net.sf.hibernate.Interceptor
Throws:
net.sf.hibernate.CallbackException
See Also:
Interceptor.onLoad(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], net.sf.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,
                            net.sf.hibernate.type.Type[] types)
                     throws net.sf.hibernate.CallbackException
Specified by:
onFlushDirty in interface net.sf.hibernate.Interceptor
Throws:
net.sf.hibernate.CallbackException
See Also:
Interceptor.onFlushDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], net.sf.hibernate.type.Type[])

onSave

public boolean onSave(java.lang.Object entity,
                      java.io.Serializable id,
                      java.lang.Object[] state,
                      java.lang.String[] propertyNames,
                      net.sf.hibernate.type.Type[] types)
               throws net.sf.hibernate.CallbackException
Specified by:
onSave in interface net.sf.hibernate.Interceptor
Throws:
net.sf.hibernate.CallbackException
See Also:
Interceptor.onSave(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], net.sf.hibernate.type.Type[])

onDelete

public void onDelete(java.lang.Object entity,
                     java.io.Serializable id,
                     java.lang.Object[] state,
                     java.lang.String[] propertyNames,
                     net.sf.hibernate.type.Type[] types)
              throws net.sf.hibernate.CallbackException
Specified by:
onDelete in interface net.sf.hibernate.Interceptor
Throws:
net.sf.hibernate.CallbackException
See Also:
Interceptor.onDelete(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.String[], net.sf.hibernate.type.Type[])

preFlush

public void preFlush(java.util.Iterator entities)
              throws net.sf.hibernate.CallbackException
Specified by:
preFlush in interface net.sf.hibernate.Interceptor
Throws:
net.sf.hibernate.CallbackException
See Also:
Interceptor.preFlush(java.util.Iterator)

postFlush

public void postFlush(java.util.Iterator entities)
               throws net.sf.hibernate.CallbackException
Specified by:
postFlush in interface net.sf.hibernate.Interceptor
Throws:
net.sf.hibernate.CallbackException
See Also:
Interceptor.postFlush(java.util.Iterator)

isUnsaved

public java.lang.Boolean isUnsaved(java.lang.Object entity)
Specified by:
isUnsaved in interface net.sf.hibernate.Interceptor
See Also:
Interceptor.isUnsaved(java.lang.Object)

findDirty

public int[] findDirty(java.lang.Object entity,
                       java.io.Serializable id,
                       java.lang.Object[] currentState,
                       java.lang.Object[] previousState,
                       java.lang.String[] propertyNames,
                       net.sf.hibernate.type.Type[] types)
Specified by:
findDirty in interface net.sf.hibernate.Interceptor
See Also:
Interceptor.findDirty(java.lang.Object, java.io.Serializable, java.lang.Object[], java.lang.Object[], java.lang.String[], net.sf.hibernate.type.Type[])

setIdOnNewEntity

protected void setIdOnNewEntity(net.sf.hibernate.SessionFactory sessionFactory,
                                java.lang.Class persistentClass,
                                java.io.Serializable id,
                                java.lang.Object newEntity)
                         throws net.sf.hibernate.CallbackException
Convenience methods subclasses can use to apply the id to a new entity if they override the instantiate method.

Parameters:
persistentClass -
id -
newEntity -
Throws:
net.sf.hibernate.CallbackException


Copyright © 2010 Atlassian. All Rights Reserved.