Class AbstractJettyHandler

  • All Implemented Interfaces:
    adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, org.eclipse.jetty.server.Handler, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle
    Direct Known Subclasses:
    RunningFlowsHandler.CustomHandler

    public abstract class AbstractJettyHandler
    extends org.eclipse.jetty.server.handler.AbstractHandler
    implements adams.core.logging.LoggingSupporter, adams.core.logging.LoggingLevelHandler
    Handler for displaying the currently running flows.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    RunningFlowsRegistry
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler

        org.eclipse.jetty.server.handler.AbstractHandler.ErrorDispatchHandler
      • Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

        org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

        org.eclipse.jetty.util.component.Dumpable.DumpableContainer
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

        org.eclipse.jetty.util.component.LifeCycle.Listener
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] m_Favicon
      the byte array of the favicon.
      protected HashMap<String,​String> m_ImageMimeTypes
      the mimetypes cache (ext - mimetype).
      protected HashMap<String,​Long> m_ImageModified
      the modified timestamps for the images (image - timestamp).
      protected adams.core.logging.Logger m_Logger
      for logging.
      protected adams.core.logging.LoggingLevel m_LoggingLevel
      the logging level.
      protected long m_ModifiedTimestamp
      the modifued timestamp for the images.
      protected boolean m_ServeIcon
      whether to serve the icon.
      • Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        FAILED, STARTED, STARTING, STOPPED, STOPPING
      • Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

        KEY
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractJettyHandler()
      Initializes the handler.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void doHandle​(String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handles the actual request.
      protected String getImageMimeType​(String image)
      Returns the appropriate mimetype for the image.
      adams.core.logging.Logger getLogger()
      Returns the logger in use.
      adams.core.logging.LoggingLevel getLoggingLevel()
      Returns the logging level.
      void handle​(String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handles the request.
      protected void initialize()
      Initializes the members.
      boolean isLoggingEnabled()
      Returns whether logging is enabled.
      protected byte[] loadImage​(String name)
      Returns the byte array for the specified image.
      protected void serveFavicon​(String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Serves the favicon.
      protected void serveImage​(String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Serves the requested image.
      void setLoggingLevel​(adams.core.logging.LoggingLevel value)
      Sets the logging level.
      • Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler

        destroy, doError, doStart, doStop, getServer, setServer
      • Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

        addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
      • Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString
      • Methods inherited from interface org.eclipse.jetty.util.component.Container

        getCachedBeans, getEventListeners
      • Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

        dumpSelf
      • Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

        isDumpable
      • Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

        addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
    • Field Detail

      • m_ModifiedTimestamp

        protected long m_ModifiedTimestamp
        the modifued timestamp for the images.
      • m_Favicon

        protected byte[] m_Favicon
        the byte array of the favicon.
      • m_ServeIcon

        protected boolean m_ServeIcon
        whether to serve the icon.
      • m_ImageModified

        protected HashMap<String,​Long> m_ImageModified
        the modified timestamps for the images (image - timestamp).
      • m_ImageMimeTypes

        protected HashMap<String,​String> m_ImageMimeTypes
        the mimetypes cache (ext - mimetype).
      • m_Logger

        protected adams.core.logging.Logger m_Logger
        for logging.
      • m_LoggingLevel

        protected adams.core.logging.LoggingLevel m_LoggingLevel
        the logging level.
    • Constructor Detail

      • AbstractJettyHandler

        public AbstractJettyHandler()
        Initializes the handler.
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
      • getLogger

        public adams.core.logging.Logger getLogger()
        Returns the logger in use.
        Specified by:
        getLogger in interface adams.core.logging.LoggingSupporter
        Returns:
        the logger
      • isLoggingEnabled

        public boolean isLoggingEnabled()
        Returns whether logging is enabled.
        Specified by:
        isLoggingEnabled in interface adams.core.logging.LoggingSupporter
        Returns:
        true if at least Level.INFO
      • setLoggingLevel

        public void setLoggingLevel​(adams.core.logging.LoggingLevel value)
        Sets the logging level.
        Specified by:
        setLoggingLevel in interface adams.core.logging.LoggingLevelHandler
        Parameters:
        value - the level
      • getLoggingLevel

        public adams.core.logging.LoggingLevel getLoggingLevel()
        Returns the logging level.
        Specified by:
        getLoggingLevel in interface adams.core.logging.LoggingLevelHandler
        Returns:
        the level
      • loadImage

        protected byte[] loadImage​(String name)
        Returns the byte array for the specified image.
        Parameters:
        name - the name of the image (without path)
        Returns:
        the byte array, null if not found
      • getImageMimeType

        protected String getImageMimeType​(String image)
        Returns the appropriate mimetype for the image.
        Parameters:
        image - the image to get the mimetype for
        Returns:
        the mimetype
      • serveFavicon

        protected void serveFavicon​(String target,
                                    org.eclipse.jetty.server.Request baseRequest,
                                    javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response)
                             throws IOException,
                                    javax.servlet.ServletException
        Serves the favicon.
        Throws:
        IOException
        javax.servlet.ServletException
      • serveImage

        protected void serveImage​(String target,
                                  org.eclipse.jetty.server.Request baseRequest,
                                  javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response)
                           throws IOException,
                                  javax.servlet.ServletException
        Serves the requested image.
        Throws:
        IOException
        javax.servlet.ServletException
      • doHandle

        protected abstract void doHandle​(String target,
                                         org.eclipse.jetty.server.Request baseRequest,
                                         javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response)
                                  throws IOException,
                                         javax.servlet.ServletException
        Handles the actual request.
        Throws:
        IOException
        javax.servlet.ServletException
      • handle

        public void handle​(String target,
                           org.eclipse.jetty.server.Request baseRequest,
                           javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws IOException,
                           javax.servlet.ServletException
        Handles the request.
        Specified by:
        handle in interface org.eclipse.jetty.server.Handler
        Specified by:
        handle in class org.eclipse.jetty.server.handler.AbstractHandler
        Throws:
        IOException
        javax.servlet.ServletException