Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » ejb » plugins » local » [javadoc | source]
    1   /*
    2   * JBoss, Home of Professional Open Source
    3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
    4   * by the @authors tag. See the copyright.txt in the distribution for a
    5   * full listing of individual contributors.
    6   *
    7   * This is free software; you can redistribute it and/or modify it
    8   * under the terms of the GNU Lesser General Public License as
    9   * published by the Free Software Foundation; either version 2.1 of
   10   * the License, or (at your option) any later version.
   11   *
   12   * This software is distributed in the hope that it will be useful,
   13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   15   * Lesser General Public License for more details.
   16   *
   17   * You should have received a copy of the GNU Lesser General Public
   18   * License along with this software; if not, write to the Free
   19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   21   */
   22   package org.jboss.ejb.plugins.local;
   23   
   24   import java.lang.reflect.InvocationHandler;
   25   import java.lang.reflect.Method;
   26   
   27   /** The EJBLocal proxy for an entity
   28   
   29    @author  <a href="mailto:scott.stark@jboss.org">Scott Stark</a>
   30    @version $Revision: 37459 $
   31    */
   32   class EntityProxy extends LocalProxy
   33      implements InvocationHandler
   34   {
   35      static final long serialVersionUID = 5196148608172665115L;
   36      private Object cacheKey;
   37      private boolean removed;
   38   
   39      EntityProxy(String jndiName, Object id, BaseLocalProxyFactory factory)
   40      {
   41         super(jndiName, factory);
   42         cacheKey = id;
   43      }
   44   
   45      protected Object getId()
   46      {
   47         return cacheKey;
   48      }
   49   
   50      public final Object invoke(final Object proxy, final Method m, Object[] args)
   51         throws Throwable
   52      {
   53         if(removed)
   54         {
   55            throw new javax.ejb.NoSuchObjectLocalException("The instance has been removed: " + toStringImpl());
   56         }
   57   
   58         if (args == null)
   59            args = EMPTY_ARGS;
   60   
   61         Object retValue = super.invoke( proxy, m, args );
   62         if( retValue == null )
   63         {
   64            // If not taken care of, go on and call the container
   65            retValue = factory.invoke(cacheKey, m, args);
   66         }
   67   
   68         if(m.equals(REMOVE))
   69         {
   70            removed = true;
   71         }
   72   
   73         return retValue;
   74      }
   75   
   76   }

Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » ejb » plugins » local » [javadoc | source]