1 45 package org.openejb.core.entity; 46 47 import java.lang.reflect.Method ; 48 import java.util.Vector ; 49 50 import org.openejb.ProxyInfo; 51 import org.openejb.RpcContainer; 52 import org.openejb.core.ivm.EjbHomeProxyHandler; 53 import org.openejb.core.ivm.EjbObjectProxyHandler; 54 import org.openejb.util.proxy.ProxyManager; 55 56 57 66 public class EntityEjbHomeHandler extends EjbHomeProxyHandler { 67 68 public EntityEjbHomeHandler(RpcContainer container, Object pk, Object depID){ 69 super(container, pk, depID); 70 } 71 72 protected Object createProxy(ProxyInfo proxyInfo){ 73 Object proxy = super.createProxy(proxyInfo); 74 EjbObjectProxyHandler handler = (EjbObjectProxyHandler)ProxyManager.getInvocationHandler(proxy); 75 76 82 registerHandler(handler.getRegistryId(),handler); 83 84 return proxy; 85 86 } 87 109 protected Object findX(Method method, Object [] args, Object proxy) throws Throwable { 110 Object retValue = container.invoke(deploymentID,method,args,null, getThreadSpecificSecurityIdentity()); 111 112 if ( retValue instanceof java.util.Collection ) { 113 Object [] proxyInfos = ((java.util.Collection )retValue).toArray(); 114 Vector proxies = new Vector (); 115 for ( int i = 0; i < proxyInfos.length; i++ ) { 116 proxies.addElement( createProxy((ProxyInfo)proxyInfos[i]) ); 117 } 118 return proxies; 119 }else if ( retValue instanceof org.openejb.util.ArrayEnumeration ) { 120 org.openejb.util.ArrayEnumeration enumeration = (org.openejb.util.ArrayEnumeration) retValue; 121 for ( int i = enumeration.size()-1; i >=0 ; --i ) { 122 enumeration.set( i, createProxy((ProxyInfo)enumeration.get(i)) ); 123 } 124 return enumeration; 125 }else if ( retValue instanceof java.util.Enumeration ) { 126 java.util.Enumeration enumeration = (java.util.Enumeration ) retValue; 127 java.util.List proxies = new java.util.ArrayList (); 129 while ( enumeration.hasMoreElements() ) { 130 proxies.add( createProxy((ProxyInfo)enumeration.nextElement()) ); 131 } 132 return new org.openejb.util.ArrayEnumeration(proxies); 133 } else { 134 org.openejb.ProxyInfo proxyInfo = (org.openejb.ProxyInfo) retValue; 135 136 137 return createProxy(proxyInfo); 138 } 139 140 } 141 167 protected Object removeByPrimaryKey(Method method, Object [] args, Object proxy) throws Throwable { 168 Object primKey = args[0]; 169 container.invoke(deploymentID, method, args, primKey, getThreadSpecificSecurityIdentity()); 170 171 175 invalidateAllHandlers(EntityEjbObjectHandler.getRegistryId(primKey,deploymentID,container)); 176 return null; 177 } 178 179 protected EjbObjectProxyHandler newEjbObjectHandler(RpcContainer container, Object pk, Object depID) { 180 return new EntityEjbObjectHandler(container, pk, depID); 181 } 182 183 } 184 | Popular Tags |