コード例 #1
0
 @Override
 public void callTimeout(final TimerImpl timer, final Method timeoutMethod) throws Exception {
   final EjbComponentInstance instance = acquireInstance();
   boolean discarded = false;
   try {
     instance.invokeTimeoutMethod(timeoutMethod, timer);
   } catch (Exception ex) {
     // Detect app exception
     if (ejbComponent.getApplicationException(ex.getClass(), timeoutMethod) != null) {
       // it's an application exception, just throw it back.
       throw ex;
     }
     if (ex instanceof ConcurrentAccessTimeoutException
         || ex instanceof ConcurrentAccessException) {
       throw ex;
     }
     if (ex instanceof RuntimeException || ex instanceof RemoteException) {
       discarded = true;
       if (pool != null) {
         pool.discard(instance);
       }
     }
     throw ex;
   } catch (final Error e) {
     discarded = true;
     if (pool != null) {
       pool.discard(instance);
     }
     throw e;
   } catch (final Throwable t) {
     discarded = true;
     if (pool != null) {
       pool.discard(instance);
     }
     throw new RuntimeException(t);
   } finally {
     if (!discarded) {
       releaseInstance(instance);
     }
   }
 }
コード例 #2
0
 /**
  * Returns true if the passed <code>exceptionClass</code> is an application exception. Else
  * returns false.
  *
  * @param ejbComponent The EJB component
  * @param exceptionClass The exception class
  * @return
  */
 private boolean isApplicationException(
     final EJBComponent ejbComponent, final Class<?> exceptionClass, final Method invokedMethod) {
   return ejbComponent.getApplicationException(exceptionClass, invokedMethod) != null;
 }