⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serializableproxy.java

📁 用Java实现的23个常用设计模式源代码
💻 JAVA
字号:
//$Id: SerializableProxy.java,v 1.9.2.1 2003/09/11 06:25:08 oneovthafew Exp $package net.sf.hibernate.proxy;import java.io.Serializable;import java.lang.reflect.Method;import net.sf.hibernate.LazyInitializationException;import org.apache.commons.logging.LogFactory;/** * Serializable placeholder for <tt>CGLIB</tt> proxies */public final class SerializableProxy implements Serializable {		private Class persistentClass;	private Class[] interfaces;	private Serializable id;	private Class getIdentifierMethodClass;	private Class setIdentifierMethodClass;	private String getIdentifierMethodName;	private String setIdentifierMethodName;	private Class[] setIdentifierMethodParams;		public SerializableProxy() {}		public SerializableProxy(Class persistentClass, Class[] interfaces, Serializable id, Method getIdentifierMethod, Method setIdentifierMethod) {		this.persistentClass = persistentClass;		this.interfaces = interfaces;		this.id = id;		if (getIdentifierMethod!=null) {			getIdentifierMethodClass = getIdentifierMethod.getDeclaringClass();			getIdentifierMethodName = getIdentifierMethod.getName();		}		if (setIdentifierMethod!=null) {			setIdentifierMethodClass = setIdentifierMethod.getDeclaringClass();			setIdentifierMethodName = setIdentifierMethod.getName();			setIdentifierMethodParams = setIdentifierMethod.getParameterTypes();		}	}	private Object readResolve() {		try {			 Object proxy = CGLIBLazyInitializer.getProxy(				persistentClass,				interfaces,				(getIdentifierMethodName==null) ? 					null : 					getIdentifierMethodClass.getDeclaredMethod(getIdentifierMethodName, null),				(setIdentifierMethodName==null) ? 					null : 					setIdentifierMethodClass.getDeclaredMethod(setIdentifierMethodName, setIdentifierMethodParams),				id,				null			);			//LazyInitializer li = HibernateProxyHelper.getLazyInitializer( (HibernateProxy) proxy );			//li.setTarget(target);			//li.setSnapshot(snapshot);			return proxy;		}		catch (Exception e) {			LogFactory.getLog(CGLIBLazyInitializer.class).error("Exception deserializing proxy", e);			throw new LazyInitializationException("could not deserialize a proxy", e);		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -