User: simone  
  Date: 00/11/09 01:41:37

  Modified:    src/main/org/jboss/util WorkerQueue.java
  Log:
  Improved logging of exceptions thrown during execution of jobs, allowing subclasses 
to override logging behavior. Thanks Oleg !
  
  Revision  Changes    Path
  1.4       +7 -19     jboss/src/main/org/jboss/util/WorkerQueue.java
  
  Index: WorkerQueue.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/util/WorkerQueue.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WorkerQueue.java  2000/11/08 16:43:29     1.3
  +++ WorkerQueue.java  2000/11/09 09:41:37     1.4
  @@ -6,20 +6,13 @@
    */
   package org.jboss.util;
   
  -
  -import javax.ejb.EJBException;
  -
  -import org.jboss.logging.Logger;
  -
  -
  -
   /**
    * Class that queues {@link Executable} jobs that are executed sequentially 
    * by a single thread.
    *
    * @see Executable
    * @author Simone Bordet ([EMAIL PROTECTED])
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class WorkerQueue
   {
  @@ -173,6 +166,11 @@
        * Override in subclasses to create a custom loop.
        */
       protected Runnable createQueueLoop() {return new QueueLoop();}
  +     /**
  +      * Logs exceptions that happens during the execution of a job.
  +      * Default implementation simply printStackTrace the exception.
  +      */
  +     protected void logJobException(Exception x) {x.printStackTrace();}
   
       // Private -------------------------------------------------------
   
  @@ -206,18 +204,8 @@
                           try {flush();}
                           catch (Exception ignored) {}
                           break;
  -                    }
  -                    catch (Exception x) {
  -                        // Log system exceptions
  -                        if (x instanceof EJBException)
  -                        {
  -                            Logger.error("BEAN EXCEPTION:"+x.getMessage());
  -                            if (((EJBException)x).getCausedByException() != null)
  -                                
Logger.exception(((EJBException)x).getCausedByException());
  -                        } else {
  -                            Logger.exception(x);
  -                        }
                       }
  +                    catch (Exception x) {logJobException(x);}
                   }
               }
               finally {clear();}
  
  
  

Reply via email to