Class Reactor

  • All Implemented Interfaces:
    java.lang.Runnable
    Direct Known Subclasses:
    SSLStompReactor, StompReactor

    public abstract class Reactor
    extends java.lang.Thread
    Provides Reactor abstraction which reacts on incoming messages and let ReactorClient process them.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean isRunning  
      private static org.slf4j.Logger LOG  
      private ReactorScheduler scheduler  
      private java.nio.channels.spi.AbstractSelector selector  
      private static int TIMEOUT  
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      Reactor()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkActions​(java.util.Set<java.nio.channels.SelectionKey> keys)  
      void close()  
      ReactorClient createClient​(java.lang.String hostname, int port)  
      protected abstract ReactorClient createClient​(Reactor reactor, java.nio.channels.Selector selector, java.lang.String hostname, int port)  
      protected abstract ReactorClient createConnectedClient​(Reactor reactor, java.nio.channels.Selector selector, java.lang.String hostname, int port, java.nio.channels.SocketChannel channel)  
      java.util.concurrent.Future<ReactorListener> createListener​(java.lang.String hostname, int port, ReactorListener.EventListener owner)  
      protected abstract java.lang.String getReactorName()  
      private void handleException​(java.lang.Throwable t, ReactorClient client, java.nio.channels.SelectionKey key, java.lang.String message)  
      private void processChannels()
      Processing channels.
      void queueFuture​(java.util.concurrent.Future<?> f)  
      void run()
      Main loop for message processing.
      private void select()  
      void wakeup()  
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.slf4j.Logger LOG
      • selector

        private final java.nio.channels.spi.AbstractSelector selector
      • isRunning

        private boolean isRunning
    • Constructor Detail

      • Reactor

        public Reactor()
                throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • select

        private void select()
      • run

        public void run()
        Main loop for message processing.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • processChannels

        private void processChannels()
        Processing channels.
      • checkActions

        private void checkActions​(java.util.Set<java.nio.channels.SelectionKey> keys)
      • handleException

        private void handleException​(java.lang.Throwable t,
                                     ReactorClient client,
                                     java.nio.channels.SelectionKey key,
                                     java.lang.String message)
      • queueFuture

        public void queueFuture​(java.util.concurrent.Future<?> f)
      • wakeup

        public void wakeup()
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getReactorName

        protected abstract java.lang.String getReactorName()