KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > proxy > CGLIBProxyFactory


1 //$Id: CGLIBProxyFactory.java,v 1.5 2005/06/05 05:20:31 oneovthafew Exp $
2
package org.hibernate.proxy;
3
4 import java.io.Serializable JavaDoc;
5 import java.lang.reflect.Method JavaDoc;
6 import java.util.Set JavaDoc;
7
8 import org.hibernate.HibernateException;
9 import org.hibernate.engine.SessionImplementor;
10 import org.hibernate.type.AbstractComponentType;
11
12 /**
13  * @author Gavin King
14  */

15 public class CGLIBProxyFactory implements ProxyFactory {
16
17     protected static final Class JavaDoc[] NO_CLASSES = new Class JavaDoc[0];
18
19     private Class JavaDoc persistentClass;
20     private String JavaDoc entityName;
21     private Class JavaDoc[] interfaces;
22     private Method JavaDoc getIdentifierMethod;
23     private Method JavaDoc setIdentifierMethod;
24     private AbstractComponentType componentIdType;
25 private Class JavaDoc factory;
26
27     public void postInstantiate(
28         final String JavaDoc entityName,
29         final Class JavaDoc persistentClass,
30         final Set JavaDoc interfaces,
31         final Method JavaDoc getIdentifierMethod,
32         final Method JavaDoc setIdentifierMethod,
33         AbstractComponentType componentIdType)
34     throws HibernateException {
35         this.entityName = entityName;
36         this.persistentClass = persistentClass;
37         this.interfaces = (Class JavaDoc[]) 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 JavaDoc 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