FileDocCategorySizeDatePackage
FieldInterceptionHelper.javaAPI DocHibernate 3.2.53257Thu Aug 03 15:35:26 BST 2006org.hibernate.intercept

FieldInterceptionHelper

public class FieldInterceptionHelper extends Object
Helper class for dealing with enhanced entity classes.
author
Steve Ebersole

Fields Summary
Constructors Summary
private FieldInterceptionHelper()

	
Methods Summary
public static voidclearDirty(java.lang.Object entity)

		FieldInterceptor interceptor = extractFieldInterceptor( entity );
		if ( interceptor != null ) {
			interceptor.clearDirty();
		}
	
public static FieldInterceptorextractFieldInterceptor(java.lang.Object entity)

		if ( entity == null ) {
			return null;
		}
		Class[] definedInterfaces = entity.getClass().getInterfaces();
		for ( int i = 0; i < definedInterfaces.length; i++ ) {
			if ( "net.sf.cglib.transform.impl.InterceptFieldEnabled".equals( definedInterfaces[i].getName() ) ) {
				// we have a CGLIB enhanced entity
				return CGLIBHelper.extractFieldInterceptor( entity );
			}
			else if ( "org.hibernate.bytecode.javassist.FieldHandled".equals( definedInterfaces[i].getName() ) ) {
				// we have a Javassist enhanced entity
				return JavassistHelper.extractFieldInterceptor( entity );
			}
		}
		return null;
	
public static FieldInterceptorinjectFieldInterceptor(java.lang.Object entity, java.lang.String entityName, java.util.Set uninitializedFieldNames, org.hibernate.engine.SessionImplementor session)

		if ( entity != null ) {
			Class[] definedInterfaces = entity.getClass().getInterfaces();
			for ( int i = 0; i < definedInterfaces.length; i++ ) {
				if ( "net.sf.cglib.transform.impl.InterceptFieldEnabled".equals( definedInterfaces[i].getName() ) ) {
					// we have a CGLIB enhanced entity
					return CGLIBHelper.injectFieldInterceptor( entity, entityName, uninitializedFieldNames, session );
				}
				else if ( "org.hibernate.bytecode.javassist.FieldHandled".equals( definedInterfaces[i].getName() ) ) {
					// we have a Javassist enhanced entity
					return JavassistHelper.injectFieldInterceptor( entity, entityName, uninitializedFieldNames, session );
				}
			}
		}
		return null;
	
public static booleanisInstrumented(java.lang.Class entityClass)

		Class[] definedInterfaces = entityClass.getInterfaces();
		for ( int i = 0; i < definedInterfaces.length; i++ ) {
			if ( "net.sf.cglib.transform.impl.InterceptFieldEnabled".equals( definedInterfaces[i].getName() )
			     || "org.hibernate.bytecode.javassist.FieldHandled".equals( definedInterfaces[i].getName() ) ) {
				return true;
			}
		}
		return false;
	
public static booleanisInstrumented(java.lang.Object entity)

		return entity != null && isInstrumented( entity.getClass() );
	
public static voidmarkDirty(java.lang.Object entity)

		FieldInterceptor interceptor = extractFieldInterceptor( entity );
		if ( interceptor != null ) {
			interceptor.dirty();
		}