Class DataHandler
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.server.handler.AbstractHandler
-
- edu.wpi.grip.core.http.GenericHandler
-
- edu.wpi.grip.core.http.PedanticHandler
-
- edu.wpi.grip.core.operations.network.http.DataHandler
-
- All Implemented Interfaces:
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.LifeCycle
public final class DataHandler extends PedanticHandler
Jetty handler for sending HTTP publishing data to a client. Only one instance of this class should exist at a time.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
-
-
Field Summary
-
Fields inherited from class edu.wpi.grip.core.http.GenericHandler
CONTENT_TYPE_HTML, CONTENT_TYPE_JSON, CONTENT_TYPE_PLAIN_TEXT, context
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDataSupplier(java.lang.String name, java.util.function.Supplier<?> supplier)Adds a supplier for data with the given name.protected voidhandleIfPassed(java.lang.String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Handles an HTTP request if the target is the same as the one for this handler.voidonPipelineStart(RunStartedEvent e)voidonPipelineStop(RunStoppedEvent e)voidremoveDataSupplier(java.lang.String name)Removes the supplier for data with the given name.-
Methods inherited from class edu.wpi.grip.core.http.PedanticHandler
handle
-
Methods inherited from class edu.wpi.grip.core.http.GenericHandler
getContext, isGet, isPost, releaseContext, sendTextContent
-
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
destroy, doStart, doStop, dumpThis, getServer, setServer
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
-
-
-
Method Detail
-
handleIfPassed
protected void handleIfPassed(java.lang.String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletExceptionDescription copied from class:PedanticHandlerHandles an HTTP request if the target is the same as the one for this handler.- Specified by:
handleIfPassedin classPedanticHandler- Parameters:
target- the target of the HTTP request (e.g. a request on "localhost:8080/foo/bar" has a target of "foo/bar")baseRequest- the base HTTP requestrequest- the request after being wrapped or filtered by other handlersresponse- the HTTP response to send to the client- Throws:
java.io.IOException- if an I/O error occurred while handling the requestjavax.servlet.ServletException- if the request could not be handled- See Also:
Handler.handle(String, Request, HttpServletRequest, HttpServletResponse)
-
addDataSupplier
public void addDataSupplier(java.lang.String name, java.util.function.Supplier<?> supplier)Adds a supplier for data with the given name. The data will be published to/GRIP/dataon the internal HTTP server.- Parameters:
name- the name of the datasupplier- a supplier for the data
-
removeDataSupplier
public void removeDataSupplier(@Nullable java.lang.String name)Removes the supplier for data with the given name. Will do nothing if no such data exists, or ifnameis null.- Parameters:
name- the name of the data to remove
-
onPipelineStart
public void onPipelineStart(@Nullable RunStartedEvent e)
-
onPipelineStop
public void onPipelineStop(@Nullable RunStoppedEvent e)
-
-