Package adams.flow.standalone.webserver
Class AbstractJettyHandler
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.server.handler.AbstractHandler
-
- adams.flow.standalone.webserver.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
-
-
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.
-
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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
-
-
-
-
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.
-
-
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 interfaceadams.core.logging.LoggingSupporter
- Returns:
- the logger
-
isLoggingEnabled
public boolean isLoggingEnabled()
Returns whether logging is enabled.- Specified by:
isLoggingEnabled
in interfaceadams.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 interfaceadams.core.logging.LoggingLevelHandler
- Parameters:
value
- the level
-
getLoggingLevel
public adams.core.logging.LoggingLevel getLoggingLevel()
Returns the logging level.- Specified by:
getLoggingLevel
in interfaceadams.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 interfaceorg.eclipse.jetty.server.Handler
- Specified by:
handle
in classorg.eclipse.jetty.server.handler.AbstractHandler
- Throws:
IOException
javax.servlet.ServletException
-
-