1 package org.hibernate.proxy; 3 4 import java.io.Serializable ; 5 import java.lang.reflect.Method ; 6 import java.util.Set ; 7 8 import org.hibernate.HibernateException; 9 import org.hibernate.engine.SessionImplementor; 10 import org.hibernate.type.AbstractComponentType; 11 12 15 public class CGLIBProxyFactory implements ProxyFactory { 16 17 protected static final Class [] NO_CLASSES = new Class [0]; 18 19 private Class persistentClass; 20 private String entityName; 21 private Class [] interfaces; 22 private Method getIdentifierMethod; 23 private Method setIdentifierMethod; 24 private AbstractComponentType componentIdType; 25 private Class factory; 26 27 public void postInstantiate( 28 final String entityName, 29 final Class persistentClass, 30 final Set interfaces, 31 final Method getIdentifierMethod, 32 final Method setIdentifierMethod, 33 AbstractComponentType componentIdType) 34 throws HibernateException { 35 this.entityName = entityName; 36 this.persistentClass = persistentClass; 37 this.interfaces = (Class []) interfaces.toArray(NO_CLASSES); 38 this.getIdentifierMethod = getIdentifierMethod; 39 this.setIdentifierMethod = setIdentifierMethod; 40 this.componentIdType = componentIdType; 41 factory = CGLIBLazyInitializer.getProxyFactory(persistentClass, this.interfaces); 42 } 43 44 public HibernateProxy getProxy(Serializable id, SessionImplementor session) 45 throws HibernateException { 46 47 return CGLIBLazyInitializer.getProxy( 48 factory, 49 entityName, 50 persistentClass, 51 interfaces, 52 getIdentifierMethod, 53 setIdentifierMethod, 54 componentIdType, 55 id, 56 session 57 ); 58 } 59 60 } 61 | Popular Tags |