Example #1
0
 // Runnable interface
 // //////////////////
 @Override
 public void run() {
   switch (mode) {
     case START_MODE:
       try {
         startSession();
       } catch (final IOException ioe) {
         log.error("START_MODE exception.", ioe);
         handleException(ioe);
       } finally {
         abort();
         if (auth != null) {
           auth.endSession();
         }
         log.info("Main thread(client->remote)stopped.");
       }
       break;
     case ACCEPT_MODE:
       try {
         doAccept();
         mode = PIPE_MODE;
         pipe_thread1.interrupt(); // Tell other thread that connection
         // have
         // been accepted.
         pipe(remote_in, out);
       } catch (final IOException ioe) {
         log.error("ACCEPT_MODE exception.", ioe);
         handleException(ioe);
       } finally {
         abort();
         log.info("Accept thread(remote->client) stopped");
       }
       break;
     case PIPE_MODE:
       try {
         pipe(remote_in, out);
       } catch (final IOException ioe) {
         log.error("PIPE_MODE error", ioe);
       } finally {
         abort();
         log.info("Support thread(remote->client) stopped");
       }
       break;
     case ABORT_MODE:
       break;
     default:
       log.warn("Unexpected MODE " + mode);
   }
 }