Example #1
0
 public Object invoke(final Object proxy, final Method method, final Object[] args)
     throws Throwable {
   if (method.equals(CLOSE_METHOD)) {
     close();
     return null;
   } else if (method.equals(SHUTDOWN_METHOD)) {
     shutdown();
     return null;
   } else if (method.equals(IS_OPEN_METHOD)) {
     return Boolean.valueOf(isOpen());
   } else if (method.equals(IS_STALE_METHOD)) {
     return Boolean.valueOf(isStale());
   } else {
     final HttpClientConnection conn = getConnection();
     if (conn == null) {
       throw new ConnectionShutdownException();
     }
     try {
       return method.invoke(conn, args);
     } catch (final InvocationTargetException ex) {
       final Throwable cause = ex.getCause();
       if (cause != null) {
         throw cause;
       } else {
         throw ex;
       }
     }
   }
 }