User: oberg   
  Date: 00/11/15 07:25:58

  Modified:    src/main/org/jboss/ejb/plugins BMPPersistenceManager.java
  Log:
  Fixed exception handling. Thanks to Darius D for pointing it out.
  
  Revision  Changes    Path
  1.16      +412 -367  jboss/src/main/org/jboss/ejb/plugins/BMPPersistenceManager.java
  
  Index: BMPPersistenceManager.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/BMPPersistenceManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- BMPPersistenceManager.java        2000/10/09 20:15:36     1.15
  +++ BMPPersistenceManager.java        2000/11/15 15:25:57     1.16
  @@ -36,408 +36,453 @@
   *   @see <related>
   *   @author Rickard �berg ([EMAIL PROTECTED])
   *  @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
  -*   @version $Revision: 1.15 $
  +*   @version $Revision: 1.16 $
   */
   public class BMPPersistenceManager
   implements EntityPersistenceManager
   {
  -    // Constants -----------------------------------------------------
  -    
  -    // Attributes ----------------------------------------------------
  -    EntityContainer con;
  -    
  -    Method ejbLoad;
  -    Method ejbStore;
  -    Method ejbActivate;
  -    Method ejbPassivate;
  -    Method ejbRemove;
  -     
  -     HashMap createMethods = new HashMap();
  -     HashMap postCreateMethods = new HashMap();
  -     HashMap finderMethods = new HashMap();
  -    
  -    // Static --------------------------------------------------------
  -    
  -    // Constructors --------------------------------------------------
  -    
  -    // Public --------------------------------------------------------
  -    public void setContainer(Container c)
  -    {
  -       con = (EntityContainer)c;
  -    }
  -    
  -    public void init()
  -    throws Exception
  -    {
  -       ejbLoad = EntityBean.class.getMethod("ejbLoad", new Class[0]);
  -       ejbStore = EntityBean.class.getMethod("ejbStore", new Class[0]);
  -       ejbActivate = EntityBean.class.getMethod("ejbActivate", new Class[0]);
  -       ejbPassivate = EntityBean.class.getMethod("ejbPassivate", new Class[0]);
  -       ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]);
  -        
  -        // Create cache of create methods
  -        Method[] methods = con.getHomeClass().getMethods();
  -        for (int i = 0; i < methods.length; i++)
  -        {
  -                     if (methods[i].getName().equals("create"))
  -                     {
  -                             createMethods.put(methods[i], 
con.getBeanClass().getMethod("ejbCreate", methods[i].getParameterTypes()));
  -                             postCreateMethods.put(methods[i], 
con.getBeanClass().getMethod("ejbPostCreate", methods[i].getParameterTypes()));
  -                     }
  -        }
  -        
  -        // Create cache of finder methods
  -        for (int i = 0; i < methods.length; i++)
  -        {
  -                     if (methods[i].getName().startsWith("find"))
  -                     {
  -                             finderMethods.put(methods[i], 
con.getBeanClass().getMethod("ejbF" + methods[i].getName().substring(1), 
methods[i].getParameterTypes()));
  -                     }
  -        }
  -    }
  -    
  -    public void start()
  -    {
  -    }
  -    
  -    public void stop()
  -    {
  -    }
  -    
  -    public void destroy()
  -    {
  -    }
  -    
  -    public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx)
  -    throws Exception
  -    {
  -         Method createMethod = (Method)createMethods.get(m);
  -         Method postCreateMethod = (Method)postCreateMethods.get(m);
  -         
  -         Object id = null;
  -         try {
  -          // Call ejbCreate
  -          id = createMethod.invoke(ctx.getInstance(), args);
  -         } catch (IllegalAccessException e)
  -              {
  -                     // Throw this as a bean exception...(?)
  -                     throw new EJBException(e);
  -              } catch (InvocationTargetException ite) 
  -              {
  +   // Constants -----------------------------------------------------
  +
  +   // Attributes ----------------------------------------------------
  +   EntityContainer con;
  +
  +   Method ejbLoad;
  +   Method ejbStore;
  +   Method ejbActivate;
  +   Method ejbPassivate;
  +   Method ejbRemove;
  +
  +   HashMap createMethods = new HashMap();
  +   HashMap postCreateMethods = new HashMap();
  +   HashMap finderMethods = new HashMap();
  +
  +   // Static --------------------------------------------------------
  +
  +   // Constructors --------------------------------------------------
  +
  +   // Public --------------------------------------------------------
  +   public void setContainer(Container c)
  +   {
  +      con = (EntityContainer)c;
  +   }
  +
  +   public void init()
  +   throws Exception
  +   {
  +      ejbLoad = EntityBean.class.getMethod("ejbLoad", new Class[0]);
  +      ejbStore = EntityBean.class.getMethod("ejbStore", new Class[0]);
  +      ejbActivate = EntityBean.class.getMethod("ejbActivate", new Class[0]);
  +      ejbPassivate = EntityBean.class.getMethod("ejbPassivate", new Class[0]);
  +      ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]);
  +
  +      // Create cache of create methods
  +      Method[] methods = con.getHomeClass().getMethods();
  +      for (int i = 0; i < methods.length; i++)
  +      {
  +         if (methods[i].getName().equals("create"))
  +         {
  +            createMethods.put(methods[i], con.getBeanClass().getMethod("ejbCreate", 
methods[i].getParameterTypes()));
  +            postCreateMethods.put(methods[i], 
con.getBeanClass().getMethod("ejbPostCreate", methods[i].getParameterTypes()));
  +         }
  +      }
  +
  +      // Create cache of finder methods
  +      for (int i = 0; i < methods.length; i++)
  +      {
  +         if (methods[i].getName().startsWith("find"))
  +         {
  +            finderMethods.put(methods[i], con.getBeanClass().getMethod("ejbF" + 
methods[i].getName().substring(1), methods[i].getParameterTypes()));
  +         }
  +      }
  +   }
  +
  +   public void start()
  +   {
  +   }
  +
  +   public void stop()
  +   {
  +   }
  +
  +   public void destroy()
  +   {
  +   }
  +
  +   public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx)
  +   throws Exception
  +   {
  +      Method createMethod = (Method)createMethods.get(m);
  +      Method postCreateMethod = (Method)postCreateMethods.get(m);
  +
  +      Object id = null;
  +      try 
  +      {
  +         // Call ejbCreate
  +         id = createMethod.invoke(ctx.getInstance(), args);
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite) 
  +      {
                        Throwable e = ite.getTargetException();
  -                     if (e instanceof CreateException)
  -                     {
  -                             // Rethrow exception
  -                             throw (CreateException)e;
  -                     } else if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  +         if (e instanceof CreateException)
  +         {
  +            // Rethrow exception
  +            throw (CreateException)e;
            }
  -         
  -         // set the id
  -         ctx.setId(id);
  -         
  -         // Create a new CacheKey
  -         Object cacheKey = ((EntityInstanceCache) 
con.getInstanceCache()).createCacheKey( id );
  -         
  -         // Give it to the context
  -         ctx.setCacheKey(cacheKey);
  -         
  -         // Insert in cache, it is now safe
  -         ((EntityInstanceCache) con.getInstanceCache()).insert(ctx);
  -         
  -         // Create EJBObject
  -         ctx.setEJBObject(con.getContainerInvoker().getEntityEJBObject(cacheKey));
  +         else if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         } else
  +         {
  +            // Rethrow exception
  +            throw (Exception)e;
  +         }
  +      }
            
  -         try {
  -          postCreateMethod.invoke(ctx.getInstance(), args);
  -         } catch (IllegalAccessException e)
  -              {
  -                     // Throw this as a bean exception...(?)
  -                     throw new EJBException(e);
  -              } catch (InvocationTargetException ite) 
  -              {
  -                     Throwable e = ite.getTargetException();
  -                     if (e instanceof CreateException)
  -                     {
  -                             // Rethrow exception
  -                             throw (CreateException)e;
  -                     } else if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  -         }
  -    }
  -    
  -    public Object findEntity(Method finderMethod, Object[] args, 
EntityEnterpriseContext ctx)
  -       throws Exception
  -    {
  -       // call the finder method
  -       Object objectId = callFinderMethod(finderMethod, args, ctx);
  -       
  -       // get the cache, create a new key and return this new key
  -       return ((EntityInstanceCache)con.getInstanceCache()).createCacheKey( 
objectId );
  -    }
  -    
  -    public Collection findEntities(Method finderMethod, Object[] args, 
EntityEnterpriseContext ctx)
  -    throws Exception
  -    {
  -       // call the finder method
  -       Object result = callFinderMethod(finderMethod, args, ctx);
  -       
  -       if (result == null) {
  +      // set the id
  +      ctx.setId(id);
  +
  +      // Create a new CacheKey
  +      Object cacheKey = ((EntityInstanceCache) 
con.getInstanceCache()).createCacheKey( id );
  +
  +      // Give it to the context
  +      ctx.setCacheKey(cacheKey);
  +
  +      // Insert in cache, it is now safe
  +      ((EntityInstanceCache) con.getInstanceCache()).insert(ctx);
  +
  +      // Create EJBObject
  +      ctx.setEJBObject(con.getContainerInvoker().getEntityEJBObject(cacheKey));
  +
  +      try
  +      {
  +         postCreateMethod.invoke(ctx.getInstance(), args);
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof CreateException)
  +         {
  +            // Rethrow exception
  +            throw (CreateException)e;
  +         }
  +         else if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         } else
  +         {
  +            // Rethrow exception
  +            throw (Exception)e;
  +         }
  +      }
  +   }
  +
  +   public Object findEntity(Method finderMethod, Object[] args, 
EntityEnterpriseContext ctx)
  +   throws Exception
  +   {
  +      // call the finder method
  +      Object objectId = callFinderMethod(finderMethod, args, ctx);
  +
  +      // get the cache, create a new key and return this new key
  +      return ((EntityInstanceCache)con.getInstanceCache()).createCacheKey( objectId 
);
  +   }
  +
  +   public Collection findEntities(Method finderMethod, Object[] args, 
EntityEnterpriseContext ctx)
  +   throws Exception
  +   {
  +      // call the finder method
  +      Object result = callFinderMethod(finderMethod, args, ctx);
  +
  +      if (result == null)
  +      {
            // for EJB 1.0 compliance
            // if the bean couldn't find any matching entities
            // it returns null, so we return an empty collection
            return new ArrayList();
  -       }
  -       
  -       if (result instanceof java.util.Enumeration) {
  +      }
  +
  +      if (result instanceof java.util.Enumeration)
  +      {
            // to preserve 1.0 spec compatiblity
            ArrayList array = new ArrayList();
            Enumeration enum = (Enumeration) result;
  -         while (enum.hasMoreElements() == true) {
  -          // Wrap a cache key around the given object id/primary key
  -          array.add(((EntityInstanceCache) 
con.getInstanceCache()).createCacheKey(enum.nextElement()));
  +         while (enum.hasMoreElements() == true)
  +         {
  +            // Wrap a cache key around the given object id/primary key
  +            array.add(((EntityInstanceCache) 
con.getInstanceCache()).createCacheKey(enum.nextElement()));
            }
            return array;
  -       } 
  -       else if (result instanceof java.util.Collection) {
  -         
  +      }
  +      else if (result instanceof java.util.Collection)
  +      {
  +
            ArrayList array = new ArrayList(((Collection) result).size());
            Iterator enum =  ((Collection) result).iterator();
  -         while (enum.hasNext()) {
  -          // Wrap a cache key around the given object id/primary key
  -          array.add(((EntityInstanceCache) 
con.getInstanceCache()).createCacheKey(enum.next()));
  +         while (enum.hasNext())
  +         {
  +            // Wrap a cache key around the given object id/primary key
  +            array.add(((EntityInstanceCache) 
con.getInstanceCache()).createCacheKey(enum.next()));
            }
            return array;
  -       }
  -       else {
  +      }
  +      else
  +      {
            // so we received something that's not valid
            // throw an exception reporting it
            throw new RemoteException("result of finder method is not a valid return 
type: " + result.getClass());
  -       }
  -    }
  -    
  -    public void activateEntity(EntityEnterpriseContext ctx)
  -    throws RemoteException
  -    {
  -             try
  -             {
  -                     ejbActivate.invoke(ctx.getInstance(), new Object[0]);
  -             } catch (IllegalAccessException e)
  -             {
  -                     // Throw this as a bean exception...(?)
  -                     throw new EJBException(e);
  -             } catch (InvocationTargetException ite) 
  -             {
  -                     Throwable e = ite.getTargetException();
  -                     if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  -             }
  -    }
  -    
  -    public void loadEntity(EntityEnterpriseContext ctx)
  -    throws RemoteException
  -    {
  -       try
  -       {
  +      }
  +   }
  +
  +   public void activateEntity(EntityEnterpriseContext ctx)
  +   throws RemoteException
  +   {
  +      try
  +      {
  +         ejbActivate.invoke(ctx.getInstance(), new Object[0]);
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         }
  +      }
  +   }
  +
  +   public void loadEntity(EntityEnterpriseContext ctx)
  +   throws RemoteException
  +   {
  +      try
  +      {
            ejbLoad.invoke(ctx.getInstance(), new Object[0]);
  -       } catch (IllegalAccessException e)
  -             {
  -                     // Throw this as a bean exception...(?)
  -                     throw new EJBException(e);
  -             } catch (InvocationTargetException ite) 
  -             {
  -                     Throwable e = ite.getTargetException();
  -                     if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  -             }
  -    }
  -    
  -    public void storeEntity(EntityEnterpriseContext ctx)
  -    throws RemoteException
  -    {
  -//DEBUG       Logger.debug("Store entity");
  -       try
  -       {
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         }
  +      }
  +   }
  +
  +   public void storeEntity(EntityEnterpriseContext ctx)
  +   throws RemoteException
  +   {
  +      //DEBUG       Logger.debug("Store entity");
  +      try
  +      {
            ejbStore.invoke(ctx.getInstance(), new Object[0]);
  -       } catch (IllegalAccessException e)
  -             {
  -                     // Throw this as a bean exception...(?)
  -                     throw new EJBException(e);
  -             } catch (InvocationTargetException ite) 
  -             {
  -                     Throwable e = ite.getTargetException();
  -                     if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  -             }
  -    }
  -    
  -    public void passivateEntity(EntityEnterpriseContext ctx)
  -    throws RemoteException
  -    {
  -       try
  -       {
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         }
  +      }
  +   }
  +
  +   public void passivateEntity(EntityEnterpriseContext ctx)
  +   throws RemoteException
  +   {
  +      try
  +      {
            ejbPassivate.invoke(ctx.getInstance(), new Object[0]);
  -       } catch (IllegalAccessException e)
  -             {
  -                     // Throw this as a bean exception...(?)
  -                     throw new EJBException(e);
  -             } catch (InvocationTargetException ite) 
  -             {
  -                     Throwable e = ite.getTargetException();
  -                     if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  -             }
  -    }
  -    
  -    public void removeEntity(EntityEnterpriseContext ctx)
  -    throws RemoteException, RemoveException
  -    {
  -       try
  -       {
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         }
  +      }
  +   }
  +
  +   public void removeEntity(EntityEnterpriseContext ctx)
  +   throws RemoteException, RemoveException
  +   {
  +      try
  +      {
            ejbRemove.invoke(ctx.getInstance(), new Object[0]);
  -       } catch (IllegalAccessException e)
  -             {
  -                     // Throw this as a bean exception...(?)
  -                     throw new EJBException(e);
  -             } catch (InvocationTargetException ite) 
  -             {
  -                     Throwable e = ite.getTargetException();
  -                     if (e instanceof RemoveException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoveException)e;
  -                     } else if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  -             }
  -    }
  -    // Z implementation ----------------------------------------------
  -    
  -    // Package protected ---------------------------------------------
  -    
  -    // Protected -----------------------------------------------------
  -    
  -    // Private -------------------------------------------------------
  -    private Object callFinderMethod(Method finderMethod, Object[] args, 
EntityEnterpriseContext ctx) 
  -      throws RemoteException, FinderException
  +      } catch (IllegalAccessException e)
  +      {
  +         // Throw this as a bean exception...(?)
  +         throw new EJBException(e);
  +      } catch (InvocationTargetException ite)
  +      {
  +         Throwable e = ite.getTargetException();
  +         if (e instanceof RemoveException)
  +         {
  +            // Rethrow exception
  +            throw (RemoveException)e;
  +         }
  +         else if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         } 
  +      }
  +   }
  +   // Z implementation ----------------------------------------------
  +
  +   // Package protected ---------------------------------------------
  +
  +   // Protected -----------------------------------------------------
  +
  +   // Private -------------------------------------------------------
  +   private Object callFinderMethod(Method finderMethod, Object[] args, 
EntityEnterpriseContext ctx) 
  +   throws Exception
      {
  -       // get the finder method
  -       Method callMethod = (Method)finderMethods.get(finderMethod);
  -       
  -        if (callMethod == null) {
  +      // get the finder method
  +      Method callMethod = (Method)finderMethods.get(finderMethod);
  +
  +      if (callMethod == null)
  +      {
            throw new RemoteException("couldn't find finder method in bean class. " + 
finderMethod.toString());
  -       }
  -       
  -       // invoke the finder method
  -       Object result = null;
  -       try {
  +      }
  +
  +      // invoke the finder method
  +      Object result = null;
  +      try 
  +      {
            result = callMethod.invoke(ctx.getInstance(), args);
  -       } catch (IllegalAccessException e)
  +      } catch (IllegalAccessException e)
                {
                        // Throw this as a bean exception...(?)
                        throw new EJBException(e);
  -             } catch (InvocationTargetException ite) 
  +      } catch (InvocationTargetException ite) 
                {
                        Throwable e = ite.getTargetException();
  -                     if (e instanceof FinderException)
  -                     {
  -                             // Rethrow exception
  -                             throw (FinderException)e;
  -                     } else if (e instanceof RemoteException)
  -                     {
  -                             // Rethrow exception
  -                             throw (RemoteException)e;
  -                     } else if (e instanceof EJBException)
  -                     {
  -                             // Rethrow exception
  -                             throw (EJBException)e;
  -                     } else if (e instanceof RuntimeException)
  -                     {
  -                             // Wrap runtime exceptions
  -                             throw new EJBException((Exception)e);
  -                     }
  -             }
  +         if (e instanceof FinderException)
  +         {
  +            // Rethrow exception
  +            throw (FinderException)e;
  +         }
  +         else if (e instanceof RemoteException)
  +         {
  +            // Rethrow exception
  +            throw (RemoteException)e;
  +         }
  +         else if (e instanceof EJBException)
  +         {
  +            // Rethrow exception
  +            throw (EJBException)e;
  +         }
  +         else if (e instanceof RuntimeException)
  +         {
  +            // Wrap runtime exceptions
  +            throw new EJBException((Exception)e);
  +         } else
  +         {
  +            // Rethrow exception
  +            throw (Exception)e;
  +         }
  +      }
          
  -       return result;
  -    }
  -    
  -    
  -    // Inner classes -------------------------------------------------
  +      return result;
  +   }
  +
  +
  +   // Inner classes -------------------------------------------------
   }
  +
  +
  +
   
  
  
  

Reply via email to