User: oberg   
  Date: 00/10/09 13:15:36

  Modified:    src/main/org/jboss/ejb EnterpriseContext.java
                        EntityContainer.java EntityPersistenceManager.java
                        EntityPersistenceStore.java InstanceCache.java
                        InstancePool.java StatefulSessionContainer.java
                        StatefulSessionPersistenceManager.java
                        StatelessSessionEnterpriseContext.java
  Log:
  Updated exception handling. Thanks to Paul Austin for insights on this!
  
  Revision  Changes    Path
  1.17      +1 -4      jboss/src/main/org/jboss/ejb/EnterpriseContext.java
  
  Index: EnterpriseContext.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/EnterpriseContext.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- EnterpriseContext.java    2000/10/08 08:04:00     1.16
  +++ EnterpriseContext.java    2000/10/09 20:15:34     1.17
  @@ -36,7 +36,7 @@
    *   @author Rickard �berg ([EMAIL PROTECTED])
    *  @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
    *  @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
  - *   @version $Revision: 1.16 $
  + *   @version $Revision: 1.17 $
    */
   public abstract class EnterpriseContext
   {
  @@ -112,7 +112,6 @@
          //new Exception().printStackTrace();
          
   //DEBUG              Logger.debug("EnterpriseContext.lock() "+hashCode()+" 
"+locked);
  -        Logger.debug("EnterpriseContext.lock() "+hashCode()+" "+locked);    
       }
       
       public void unlock() {
  @@ -124,13 +123,11 @@
          if (locked <0) new Exception().printStackTrace();
          
   //DEBUG              Logger.debug("EnterpriseContext.unlock() "+hashCode()+" 
"+locked);
  -        Logger.debug("EnterpriseContext.unlock() "+hashCode()+" "+locked);
       }
       
       public boolean isLocked() {
               
   //DEBUG       Logger.debug("EnterpriseContext.isLocked() "+hashCode()+" at 
"+locked);
  -            Logger.debug("EnterpriseContext.isLocked() "+hashCode()+" at "+locked);
          return locked != 0;
      }
      
  
  
  
  1.29      +3 -3      jboss/src/main/org/jboss/ejb/EntityContainer.java
  
  Index: EntityContainer.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/EntityContainer.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- EntityContainer.java      2000/09/29 21:25:16     1.28
  +++ EntityContainer.java      2000/10/09 20:15:34     1.29
  @@ -36,7 +36,7 @@
   *   @author Rickard �berg ([EMAIL PROTECTED])
   *   @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
   *   @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
  -*   @version $Revision: 1.28 $
  +*   @version $Revision: 1.29 $
   */
   public class EntityContainer
   extends Container
  @@ -373,7 +373,7 @@
       */
       
       public Object find(MethodInvocation mi)
  -    throws java.rmi.RemoteException, FinderException
  +    throws Exception
       {
           
           // Multi-finder?
  @@ -420,7 +420,7 @@
       */
       
       public EJBObject createHome(MethodInvocation mi)
  -    throws java.rmi.RemoteException, CreateException
  +    throws Exception
       {
          
          // The persistence manager takes care of the wiring and creating the 
EJBObject
  
  
  
  1.3       +4 -10     jboss/src/main/org/jboss/ejb/EntityPersistenceManager.java
  
  Index: EntityPersistenceManager.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/EntityPersistenceManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EntityPersistenceManager.java     2000/05/30 18:32:16     1.2
  +++ EntityPersistenceManager.java     2000/10/09 20:15:34     1.3
  @@ -24,7 +24,7 @@
    *
    *   @see EntityContainer
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.2 $
  + *   @version $Revision: 1.3 $
    */
   public interface EntityPersistenceManager
      extends ContainerPlugin
  @@ -39,11 +39,9 @@
         * @param   m  the create method in the home interface that was called
         * @param   args  any create parameters
         * @param   instance  the instance being used for this create call
  -      * @exception   RemoteException  thrown if some system exception occurs
  -      * @exception   CreateException  thrown if some heuristic problem occurs
         */
      public void createEntity(Method m, Object[] args, EntityEnterpriseContext 
instance)
  -      throws RemoteException, CreateException;
  +      throws Exception;
   
        /**
         *      This method is called when single entities are to be found. The 
persistence manager must find out
  @@ -54,11 +52,9 @@
         * @param   args  any finder parameters
         * @param   instance  the instance to use for the finder call
         * @return     an EJBObject representing the found entity
  -      * @exception   RemoteException  thrown if some system exception occurs
  -      * @exception   FinderException  thrown if some heuristic problem occurs
         */
      public Object findEntity(Method finderMethod, Object[] args, 
EntityEnterpriseContext instance)
  -      throws RemoteException, FinderException;
  +      throws Exception;
   
        /**
         *      This method is called when collections of entities are to be found. 
The persistence manager must find out
  @@ -69,11 +65,9 @@
         * @param   args  any finder parameters
         * @param   instance  the instance to use for the finder call
         * @return     an EJBObject collection representing the found entities
  -      * @exception   RemoteException  thrown if some system exception occurs
  -      * @exception   FinderException  thrown if some heuristic problem occurs
         */
      public Collection findEntities(Method finderMethod, Object[] args, 
EntityEnterpriseContext instance)
  -      throws RemoteException, FinderException;
  +      throws Exception;
   
   
        /**
  
  
  
  1.2       +6 -7      jboss/src/main/org/jboss/ejb/EntityPersistenceStore.java
  
  Index: EntityPersistenceStore.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/EntityPersistenceStore.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EntityPersistenceStore.java       2000/07/14 18:32:16     1.1
  +++ EntityPersistenceStore.java       2000/10/09 20:15:34     1.2
  @@ -27,7 +27,7 @@
    *   @see EntityPersistenceManager
    *   @author Rickard �berg ([EMAIL PROTECTED])
    *  @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public interface EntityPersistenceStore
   extends ContainerPlugin
  @@ -46,11 +46,10 @@
         * @param   args  any create parameters
         * @param   instance  the instance being used for this create call
         * @return  Object, the primary key computed by CMP PM or null for BMP
  -      * @exception   RemoteException  thrown if some system exception occurs
  -      * @exception   CreateException  thrown if some heuristic problem occurs
  +      * @exception   Exception  
         */
      public Object createEntity(Method m, Object[] args, EntityEnterpriseContext 
instance)
  -      throws RemoteException, CreateException;
  +      throws Exception;
   
        /**
         *      This method is called when single entities are to be found. The 
persistence manager must find out
  @@ -65,8 +64,8 @@
         * @exception   FinderException  thrown if some heuristic problem occurs
         */
      public Object findEntity(Method finderMethod, Object[] args, 
EntityEnterpriseContext instance)
  -      throws RemoteException, FinderException;
  -
  +      throws Exception;
  +   
        /**
         *      This method is called when collections of entities are to be found. 
The persistence manager must find out
         *      whether the wanted instances are available in the persistence store, 
and if so 
  @@ -80,7 +79,7 @@
         * @exception   FinderException  thrown if some heuristic problem occurs
         */
      public Collection findEntities(Method finderMethod, Object[] args, 
EntityEnterpriseContext instance)
  -      throws RemoteException, FinderException;
  +      throws Exception;
   
   
        /**
  
  
  
  1.3       +2 -2      jboss/src/main/org/jboss/ejb/InstanceCache.java
  
  Index: InstanceCache.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/InstanceCache.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InstanceCache.java        2000/09/26 18:32:50     1.2
  +++ InstanceCache.java        2000/10/09 20:15:34     1.3
  @@ -14,7 +14,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.2 $
  + *   @version $Revision: 1.3 $
    */
   public interface InstanceCache
      extends ContainerPlugin
  @@ -40,7 +40,7 @@
       * @exception   RemoteException  
       */
      public EnterpriseContext get(Object id)
  -      throws RemoteException, NoSuchEntityException;
  +      throws Exception;
   
      /**
       *   Insert an active instance after creation or activation. Write-lock is 
required.
  
  
  
  1.2       +2 -2      jboss/src/main/org/jboss/ejb/InstancePool.java
  
  Index: InstancePool.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/InstancePool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InstancePool.java 2000/04/22 14:30:12     1.1
  +++ InstancePool.java 2000/10/09 20:15:35     1.2
  @@ -13,7 +13,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public interface InstancePool
      extends ContainerPlugin
  @@ -35,7 +35,7 @@
       * @exception   RemoteException  
       */
      public EnterpriseContext get()
  -      throws RemoteException;
  +      throws Exception;
      
      /**
       *   Return an anonymous instance after invocation.
  
  
  
  1.19      +2 -2      jboss/src/main/org/jboss/ejb/StatefulSessionContainer.java
  
  Index: StatefulSessionContainer.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/StatefulSessionContainer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- StatefulSessionContainer.java     2000/09/29 21:25:16     1.18
  +++ StatefulSessionContainer.java     2000/10/09 20:15:35     1.19
  @@ -32,7 +32,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.18 $
  + *   @version $Revision: 1.19 $
    */
   public class StatefulSessionContainer
      extends Container
  @@ -364,7 +364,7 @@
      
      // Home interface implementation ---------------------------------
      public EJBObject createHome(MethodInvocation mi)
  -      throws java.rmi.RemoteException, CreateException
  +      throws Exception
      {
         getPersistenceManager().createSession(mi.getMethod(), mi.getArguments(), 
(StatefulSessionEnterpriseContext)mi.getEnterpriseContext());
        return 
((StatefulSessionEnterpriseContext)mi.getEnterpriseContext()).getEJBObject();
  
  
  
  1.2       +2 -2      
jboss/src/main/org/jboss/ejb/StatefulSessionPersistenceManager.java
  
  Index: StatefulSessionPersistenceManager.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/StatefulSessionPersistenceManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StatefulSessionPersistenceManager.java    2000/04/22 14:30:10     1.1
  +++ StatefulSessionPersistenceManager.java    2000/10/09 20:15:35     1.2
  @@ -19,7 +19,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public interface StatefulSessionPersistenceManager
      extends ContainerPlugin
  @@ -34,7 +34,7 @@
      
      // Public --------------------------------------------------------
      public void createSession(Method m, Object[] args, 
StatefulSessionEnterpriseContext ctx)
  -      throws RemoteException, CreateException;
  +      throws Exception;
         
      public void activateSession(StatefulSessionEnterpriseContext ctx)
         throws RemoteException;
  
  
  
  1.4       +13 -7     
jboss/src/main/org/jboss/ejb/StatelessSessionEnterpriseContext.java
  
  Index: StatelessSessionEnterpriseContext.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/StatelessSessionEnterpriseContext.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StatelessSessionEnterpriseContext.java    2000/09/26 18:38:04     1.3
  +++ StatelessSessionEnterpriseContext.java    2000/10/09 20:15:35     1.4
  @@ -15,6 +15,7 @@
   import javax.ejb.EJBObject;
   import javax.ejb.SessionContext;
   import javax.ejb.SessionBean;
  +import javax.ejb.EJBException;
   
   /**
    *   <description> 
  @@ -22,7 +23,7 @@
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
    *  @author <a href="[EMAIL PROTECTED]">Sebastien Alborini</a>
  - *   @version $Revision: 1.3 $
  + *   @version $Revision: 1.4 $
    */
   public class StatelessSessionEnterpriseContext
      extends EnterpriseContext
  @@ -37,7 +38,7 @@
      
      // Constructors --------------------------------------------------
      public StatelessSessionEnterpriseContext(Object instance, Container con)
  -      throws RemoteException
  +      throws Exception
      {
         super(instance, con);
         ctx = new SessionContextImpl();
  @@ -48,12 +49,17 @@
         {
            Method ejbCreate = instance.getClass().getMethod("ejbCreate", new 
Class[0]);
            ejbCreate.invoke(instance, new Object[0]);
  -      } catch (InvocationTargetException e)
  +      } catch (InvocationTargetException e) 
         {
  -         throw new ServerException("Could not call ejbCreate", 
(Exception)e.getTargetException());
  -      } catch (Exception e)
  -      {
  -         throw new ServerException("Could not call ejbCreate", e);
  +          Throwable ex = e.getTargetException();
  +          if (ex instanceof EJBException)
  +             throw (Exception)ex;
  +          else if (ex instanceof RuntimeException)
  +             throw new EJBException((Exception)ex); // Transform runtime exception 
into what a bean *should* have thrown
  +          else if (ex instanceof Exception)
  +             throw (Exception)ex;
  +          else
  +             throw (Error)ex;
         }
      }
      
  
  
  

Reply via email to