Open Source Repository

Home /hibernate/hibernate-3.2.7.ga | Repository Home


org/hibernate/intercept/javassist/JavassistHelper.java
package org.hibernate.intercept.javassist;

import org.hibernate.intercept.FieldInterceptor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.bytecode.javassist.FieldHandled;

import java.util.Set;

/**
 @author Steve Ebersole
 */
public class JavassistHelper {
  private JavassistHelper() {
  }

  public static FieldInterceptor extractFieldInterceptor(Object entity) {
    return FieldInterceptor ) ( ( FieldHandled entity ).getFieldHandler();
  }

  public static FieldInterceptor injectFieldInterceptor(
      Object entity,
          String entityName,
          Set uninitializedFieldNames,
          SessionImplementor session) {
    FieldInterceptorImpl fieldInterceptor = new FieldInterceptorImplsession, uninitializedFieldNames, entityName );
    ( ( FieldHandled entity ).setFieldHandlerfieldInterceptor );
    return fieldInterceptor;
  }
}