1 package org.apache.ojb.broker.core.proxy; 2 3 17 18 import java.lang.ref.SoftReference ; 19 import java.lang.ref.WeakReference ; 20 import java.lang.ref.Reference ; 21 22 import org.apache.ojb.broker.PBFactoryException; 23 24 30 public class ProxyHelper 31 { 32 private static Reference proxyFactoryRef; 33 34 public synchronized static ProxyFactory getProxyFactory() 35 { 36 if((proxyFactoryRef == null) || (proxyFactoryRef.get() == null)) 37 { 38 try 39 { 40 45 proxyFactoryRef = new WeakReference (AbstractProxyFactory.getProxyFactory()); 46 } 47 catch(PBFactoryException ex) 48 { 49 return new ProxyFactoryCGLIBImpl(); 52 } 53 } 54 return (ProxyFactory) proxyFactoryRef.get(); 55 } 56 57 63 public static final Object getRealObject(Object objectOrProxy) 64 { 65 return getProxyFactory().getRealObject(objectOrProxy); 66 } 67 68 74 public static final Object getRealObjectIfMaterialized(Object objectOrProxy) 75 { 76 return getProxyFactory().getRealObjectIfMaterialized(objectOrProxy); 77 } 78 79 85 public static final Class getRealClass(Object objectOrProxy) 86 { 87 return getProxyFactory().getRealClass(objectOrProxy); 88 } 89 90 95 public static boolean isNormalOjbProxy(Object proxyOrObject) 96 { 97 return getProxyFactory().isNormalOjbProxy(proxyOrObject); 98 } 99 100 105 public static boolean isVirtualOjbProxy(Object proxyOrObject) 106 { 107 return getProxyFactory().isVirtualOjbProxy(proxyOrObject); 108 } 109 110 114 public static boolean isProxy(Object proxyOrObject) 115 { 116 return getProxyFactory().isProxy(proxyOrObject); 117 } 118 119 126 public static IndirectionHandler getIndirectionHandler(Object obj) 127 { 128 return getProxyFactory().getIndirectionHandler(obj); 129 } 130 131 138 public static boolean isMaterialized(Object object) 139 { 140 return getProxyFactory().isMaterialized(object); 141 } 142 143 152 public static String toString(Object object) 153 { 154 return getProxyFactory().toString(object); 155 } 156 157 158 public static CollectionProxy getCollectionProxy(Object item) 159 { 160 return getProxyFactory().getCollectionProxy(item); 161 } 162 163 164 public static boolean isCollectionProxy(Object item) 165 { 166 return getProxyFactory().isCollectionProxy(item); 168 } 169 } 170 | Popular Tags |