01: //$Id: CGLIBProxyFactory.java 9210 2006-02-03 22:15:19Z steveebersole $
02: package org.hibernate.proxy.pojo.cglib;
03:
04: import java.io.Serializable;
05: import java.lang.reflect.Method;
06: import java.util.Set;
07:
08: import org.hibernate.HibernateException;
09: import org.hibernate.proxy.ProxyFactory;
10: import org.hibernate.proxy.HibernateProxy;
11: import org.hibernate.engine.SessionImplementor;
12: import org.hibernate.type.AbstractComponentType;
13:
14: /**
15: * @author Gavin King
16: */
17: public class CGLIBProxyFactory implements ProxyFactory {
18:
19: protected static final Class[] NO_CLASSES = new Class[0];
20:
21: private Class persistentClass;
22: private String entityName;
23: private Class[] interfaces;
24: private Method getIdentifierMethod;
25: private Method setIdentifierMethod;
26: private AbstractComponentType componentIdType;
27: private Class factory;
28:
29: public void postInstantiate(final String entityName,
30: final Class persistentClass, 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,
42: this .interfaces);
43: }
44:
45: public HibernateProxy getProxy(Serializable id,
46: SessionImplementor session) throws HibernateException {
47:
48: return CGLIBLazyInitializer.getProxy(factory, entityName,
49: persistentClass, interfaces, getIdentifierMethod,
50: setIdentifierMethod, componentIdType, id, session);
51: }
52:
53: }
|