|
[cvs] openejb/src/main/org/openejb/core/entity EntityEjbHomeHandler.java: msg#00025java.openejb.devel
Modified: src/main/org/openejb/core/entity EntityEjbHomeHandler.java Log: Adding the same patch to the main branch By David Blevins, on 0103/02/13 17:55:48 Revision Changes Path 1.6 +183 -183 openejb/src/main/org/openejb/core/entity/EntityEjbHomeHandler.java Index: EntityEjbHomeHandler.java =================================================================== RCS file: /cvsroot/openejb/openejb/src/main/org/openejb/core/entity/EntityEjbHomeHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- EntityEjbHomeHandler.java 28 Dec 2002 19:20:47 -0000 1.5 +++ EntityEjbHomeHandler.java 14 Feb 2003 01:55:48 -0000 1.6 @@ -1,183 +1,183 @@ -/** - * Redistribution and use of this software and associated documentation - * ("Software"), with or without modification, are permitted provided - * that the following conditions are met: - * - * 1. Redistributions of source code must retain copyright - * statements and notices. Redistributions must also contain a - * copy of this document. - * - * 2. Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * 3. The name "Exolab" must not be used to endorse or promote - * products derived from this Software without prior written - * permission of Exoffice Technologies. For written permission, - * please contact info@xxxxxxxxxxx - * - * 4. Products derived from this Software may not be called "Exolab" - * nor may "Exolab" appear in their names without prior written - * permission of Exoffice Technologies. Exolab is a registered - * trademark of Exoffice Technologies. - * - * 5. Due credit should be given to the Exolab Project - * (http://www.exolab.org/). - * - * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT - * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved. - * - * $Id: EntityEjbHomeHandler.java,v 1.5 2002/12/28 19:20:47 tim273 Exp $ - */ -package org.openejb.core.entity; - -import java.lang.reflect.Method; -import java.util.Vector; - -import org.openejb.ProxyInfo; -import org.openejb.RpcContainer; -import org.openejb.core.ivm.EjbHomeProxyHandler; -import org.openejb.core.ivm.EjbObjectProxyHandler; -import org.openejb.util.proxy.ProxyManager; - - -/** - * This InvocationHandler and its proxy are serializable and can be used by - * HomeHandle, Handle, and MetaData to persist and revive handles. It maintains - * its original client identity which allows the container to be more discerning about - * allowing the revieed proxy to be used. See StatefulContaer manager for more details. - * - * @author <a href="mailto:david.blevins@xxxxxxxx">David Blevins</a> - * @author <a href="mailto:Richard@xxxxxxxxxxxxxxxxx">Richard Monson-Haefel</a> - */ -public class EntityEjbHomeHandler extends EjbHomeProxyHandler { - - public EntityEjbHomeHandler(RpcContainer container, Object pk, Object depID){ - super(container, pk, depID); - } - - protected Object createProxy(ProxyInfo proxyInfo){ - Object proxy = super.createProxy(proxyInfo); - EjbObjectProxyHandler handler = (EjbObjectProxyHandler)ProxyManager.getInvocationHandler(proxy); - - /* - * Register the handle with the BaseEjbProxyHandler.liveHandleRegistry - * If the bean is removed by its home or by an identical proxy, then the - * this proxy will be automatically invalidated because its properly registered - * with the liveHandleRegistry. - */ - registerHandler(handler.getRegistryId(),handler); - - return proxy; - - } - /** - * <P> - * Locates and returns a new EJBObject or a collection - * of EJBObjects. The EJBObject(s) is a new proxy with - * a new handler. This implementation should not be - * sent outside the virtual machine. - * </P> - * <P> - * This method propogates to the container - * system. - * </P> - * <P> - * The find method is required to be defined - * by the bean's home interface of Entity beans. - * </P> - * - * @param method - * @param args - * @param proxy - * @return Returns an new EJBObject proxy and handler - * @exception Throwable - */ - protected Object findX(Method method, Object[] args, Object proxy) throws Throwable { - Object retValue = container.invoke(deploymentID,method,args,null, getThreadSpecificSecurityIdentity()); - - if ( retValue instanceof java.util.Collection ) { - Object [] proxyInfos = ((java.util.Collection)retValue).toArray(); - Vector proxies = new Vector(); - for ( int i = 0; i < proxyInfos.length; i++ ) { - proxies.addElement( createProxy((ProxyInfo)proxyInfos[i]) ); - } - return proxies; - }else if ( retValue instanceof org.openejb.util.ArrayEnumeration ) { - org.openejb.util.ArrayEnumeration enum = (org.openejb.util.ArrayEnumeration) retValue; - for ( int i = enum.size()-1; i >=0 ; --i ) { - enum.set( i, createProxy((ProxyInfo)enum.get(i)) ); - } - return enum; - }else if ( retValue instanceof java.util.Enumeration ) { - java.util.Enumeration enum = (java.util.Enumeration) retValue; - // Don't use Vector, because it contains unnecessary synchronization - java.util.List proxies = new java.util.ArrayList(); - while ( enum.hasMoreElements() ) { - proxies.add( createProxy((ProxyInfo)enum.nextElement()) ); - } - return new org.openejb.util.ArrayEnumeration(proxies); - } else { - org.openejb.ProxyInfo proxyInfo = (org.openejb.ProxyInfo) - container.invoke(deploymentID,method,args,null, getThreadSpecificSecurityIdentity()); - - return createProxy(proxyInfo); - } - - } - /** - * <P> - * Attempts to remove an EJBObject from the - * container system. The EJBObject to be removed - * is represented by the primaryKey passed - * into the remove method of the EJBHome. - * </P> - * <P> - * This method propogates to the container system. - * </P> - * <P> - * remove(Object primary) is a method of javax.ejb.EJBHome - * </P> - * <P> - * Checks if the caller is authorized to invoke the - * javax.ejb.EJBHome.remove on the EJBHome of the - * deployment. - * </P> - * - * @param method - * @param args - * @return Returns null - * @exception Throwable - * @see javax.ejb.EJBHome - * @see javax.ejb.EJBHome#remove - */ - protected Object removeByPrimaryKey(Method method, Object[] args, Object proxy) throws Throwable{ - Object primKey = args[0]; - container.invoke(deploymentID, method, args, primKey, getThreadSpecificSecurityIdentity()); - - /* - * This operation takes care of invalidating all the EjbObjectProxyHanders associated with - * the same RegistryId. See this.createProxy(). - */ - invalidateAllHandlers(EntityEjbObjectHandler.getRegistryId(primKey,deploymentID,container)); - return null; - } - - protected EjbObjectProxyHandler newEjbObjectHandler(RpcContainer container, Object pk, Object depID) { - return new EntityEjbObjectHandler(container, pk, depID); - } - -} +/** + * Redistribution and use of this software and associated documentation + * ("Software"), with or without modification, are permitted provided + * that the following conditions are met: + * + * 1. Redistributions of source code must retain copyright + * statements and notices. Redistributions must also contain a + * copy of this document. + * + * 2. Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. The name "Exolab" must not be used to endorse or promote + * products derived from this Software without prior written + * permission of Exoffice Technologies. For written permission, + * please contact info@xxxxxxxxxxx + * + * 4. Products derived from this Software may not be called "Exolab" + * nor may "Exolab" appear in their names without prior written + * permission of Exoffice Technologies. Exolab is a registered + * trademark of Exoffice Technologies. + * + * 5. Due credit should be given to the Exolab Project + * (http://www.exolab.org/). + * + * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT + * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved. + * + * $Id: EntityEjbHomeHandler.java,v 1.6 2003/02/14 01:55:48 dblevins Exp $ + */ +package org.openejb.core.entity; + +import java.lang.reflect.Method; +import java.util.Vector; + +import org.openejb.ProxyInfo; +import org.openejb.RpcContainer; +import org.openejb.core.ivm.EjbHomeProxyHandler; +import org.openejb.core.ivm.EjbObjectProxyHandler; +import org.openejb.util.proxy.ProxyManager; + + +/** + * This InvocationHandler and its proxy are serializable and can be used by + * HomeHandle, Handle, and MetaData to persist and revive handles. It maintains + * its original client identity which allows the container to be more discerning about + * allowing the revieed proxy to be used. See StatefulContaer manager for more details. + * + * @author <a href="mailto:david.blevins@xxxxxxxx">David Blevins</a> + * @author <a href="mailto:Richard@xxxxxxxxxxxxxxxxx">Richard Monson-Haefel</a> + */ +public class EntityEjbHomeHandler extends EjbHomeProxyHandler { + + public EntityEjbHomeHandler(RpcContainer container, Object pk, Object depID){ + super(container, pk, depID); + } + + protected Object createProxy(ProxyInfo proxyInfo){ + Object proxy = super.createProxy(proxyInfo); + EjbObjectProxyHandler handler = (EjbObjectProxyHandler)ProxyManager.getInvocationHandler(proxy); + + /* + * Register the handle with the BaseEjbProxyHandler.liveHandleRegistry + * If the bean is removed by its home or by an identical proxy, then the + * this proxy will be automatically invalidated because its properly registered + * with the liveHandleRegistry. + */ + registerHandler(handler.getRegistryId(),handler); + + return proxy; + + } + /** + * <P> + * Locates and returns a new EJBObject or a collection + * of EJBObjects. The EJBObject(s) is a new proxy with + * a new handler. This implementation should not be + * sent outside the virtual machine. + * </P> + * <P> + * This method propogates to the container + * system. + * </P> + * <P> + * The find method is required to be defined + * by the bean's home interface of Entity beans. + * </P> + * + * @param method + * @param args + * @param proxy + * @return Returns an new EJBObject proxy and handler + * @exception Throwable + */ + protected Object findX(Method method, Object[] args, Object proxy) throws Throwable { + Object retValue = container.invoke(deploymentID,method,args,null, getThreadSpecificSecurityIdentity()); + + if ( retValue instanceof java.util.Collection ) { + Object [] proxyInfos = ((java.util.Collection)retValue).toArray(); + Vector proxies = new Vector(); + for ( int i = 0; i < proxyInfos.length; i++ ) { + proxies.addElement( createProxy((ProxyInfo)proxyInfos[i]) ); + } + return proxies; + }else if ( retValue instanceof org.openejb.util.ArrayEnumeration ) { + org.openejb.util.ArrayEnumeration enum = (org.openejb.util.ArrayEnumeration) retValue; + for ( int i = enum.size()-1; i >=0 ; --i ) { + enum.set( i, createProxy((ProxyInfo)enum.get(i)) ); + } + return enum; + }else if ( retValue instanceof java.util.Enumeration ) { + java.util.Enumeration enum = (java.util.Enumeration) retValue; + // Don't use Vector, because it contains unnecessary synchronization + java.util.List proxies = new java.util.ArrayList(); + while ( enum.hasMoreElements() ) { + proxies.add( createProxy((ProxyInfo)enum.nextElement()) ); + } + return new org.openejb.util.ArrayEnumeration(proxies); + } else { + org.openejb.ProxyInfo proxyInfo = (org.openejb.ProxyInfo) retValue; + + + return createProxy(proxyInfo); + } + + } + /** + * <P> + * Attempts to remove an EJBObject from the + * container system. The EJBObject to be removed + * is represented by the primaryKey passed + * into the remove method of the EJBHome. + * </P> + * <P> + * This method propogates to the container system. + * </P> + * <P> + * remove(Object primary) is a method of javax.ejb.EJBHome + * </P> + * <P> + * Checks if the caller is authorized to invoke the + * javax.ejb.EJBHome.remove on the EJBHome of the + * deployment. + * </P> + * + * @param method + * @param args + * @return Returns null + * @exception Throwable + * @see javax.ejb.EJBHome + * @see javax.ejb.EJBHome#remove + */ + protected Object removeByPrimaryKey(Method method, Object[] args, Object proxy) throws Throwable{ + Object primKey = args[0]; + container.invoke(deploymentID, method, args, primKey, getThreadSpecificSecurityIdentity()); + + /* + * This operation takes care of invalidating all the EjbObjectProxyHanders associated with + * the same RegistryId. See this.createProxy(). + */ + invalidateAllHandlers(EntityEjbObjectHandler.getRegistryId(primKey,deploymentID,container)); + return null; + } + + protected EjbObjectProxyHandler newEjbObjectHandler(RpcContainer container, Object pk, Object depID) { + return new EntityEjbObjectHandler(container, pk, depID); + } + +} ------------------------------------------------------- This SF.NET email is sponsored by: FREE SSL Guide from Thawte are you planning your Web Server Security? Click here to get a FREE Thawte SSL guide and find the answers to all your SSL security issues. http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en _______________________________________________ http://OpenEJB.sf.net OpenEJB-development mailing list OpenEJB-development@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/openejb-development
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [cvs] openejb/src/main/org/openejb/core/entity EntityEjbHomeHandler.java, David Blevins |
|---|---|
| Next by Date: | [cvs] openejb/src/doc faq_cmp.xml, David Blevins |
| Previous by Thread: | [cvs] openejb/src/main/org/openejb/core/entity EntityEjbHomeHandler.java, David Blevins |
| Next by Thread: | [cvs] openejb/src/doc faq_cmp.xml, David Blevins |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |