Class EagerContentHandler
java.lang.Object
- All Implemented Interfaces:
Handler
,Handler.Container
,Handler.Singleton
,Request.Handler
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,Invocable
- Direct Known Subclasses:
DelayedHandler
A ConditionalHandler
that can eagerly load content asynchronously before calling the
next handler
. Typically this handler is deployed before an application that uses
blocking IO to read the request body. By using this handler, such an application can be run in a way so that it
never (or seldom) blocks on request content. This gives many of the benefits of asynchronous IO without the
need to write an asynchronous application.
The handler uses the configured EagerContentHandler.FormContentLoaderFactory
instances to eagerly load specific content types.
By default, this handler supports eager loading of:
FormFields
- Loaded and parsed in full by the
EagerContentHandler.FormContentLoaderFactory
MultiPartFormData
- Loaded and parsed in full by the
EagerContentHandler.MultiPartContentLoaderFactory
Content.Chunk
- Retained by the
EagerContentHandler.RetainedContentLoaderFactory
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
An eager content processor, created by aEagerContentHandler.ContentLoaderFactory
to asynchronous load content from aRequest
before calling theRequest.Handler.handle(Request, Response, Callback)
method of the passedHandler
.static interface
A factory to create newEagerContentHandler.ContentLoader
instances for a specific mime type.static class
AnEagerContentHandler.ContentLoaderFactory
forMimeTypes.Type.FORM_ENCODED
content, that usesFormFields.onFields(Request, Charset, int, int, Promise.Invocable)
to asynchronously load and parse the content.static class
AnEagerContentHandler.ContentLoaderFactory
forMimeTypes.Type.MULTIPART_FORM_DATA
content, that usesMultiPartFormData.onParts(Content.Source, Attributes, String, MultiPartConfig, Promise.Invocable)
to asynchronously load and parse the content.static class
AnEagerContentHandler.ContentLoaderFactory
for any content, that usesRetainable.retain()
to eagerly load content with zero copies, until all content is read or a maximum size is exceeded.Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.ConditionalHandler
ConditionalHandler.Abstract, ConditionalHandler.ConnectorPredicate, ConditionalHandler.DontHandle, ConditionalHandler.ElseNext, ConditionalHandler.InetAddressPatternPredicate, ConditionalHandler.MethodPredicate, ConditionalHandler.PathSpecPredicate, ConditionalHandler.PredicateSet, ConditionalHandler.Reject, ConditionalHandler.SkipNext
Nested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract
Handler.Abstract.NonBlocking
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendable
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler
Handler.AbstractContainer, Handler.Collection, Handler.Container, Handler.Sequence, Handler.Singleton, Handler.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Request.Handler
Request.Handler.AbortException
-
Field Summary
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct anEagerContentHandler
with the defaultEagerContentHandler.ContentLoaderFactory
setEagerContentHandler
(Handler handler) Construct anEagerContentHandler
with the defaultEagerContentHandler.ContentLoaderFactory
setEagerContentHandler
(EagerContentHandler.ContentLoaderFactory... factories) Construct anEagerContentHandler
with the specificEagerContentHandler.ContentLoaderFactory
instancesEagerContentHandler
(Handler handler, EagerContentHandler.ContentLoaderFactory... factories) Construct anEagerContentHandler
with the specificEagerContentHandler.ContentLoaderFactory
instances -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
onConditionsMet
(Request request, Response response, Callback callback) Handle a request that has met the conditions.Methods inherited from class org.eclipse.jetty.server.handler.ConditionalHandler.ElseNext
onConditionsNotMet
Methods inherited from class org.eclipse.jetty.server.handler.ConditionalHandler
clear, doStart, dump, exclude, exclude, exclude, excludeInetAddressPattern, excludeMethod, excludePath, from, from, handle, include, include, include, includeInetAddressPattern, includeMethod, includePath, nextHandler
Methods inherited from class org.eclipse.jetty.server.Handler.Wrapper
getHandler, getInvocationType, setHandler
Methods inherited from class org.eclipse.jetty.server.Handler.AbstractContainer
findContainerOf, getDescendant, getDescendants, isDynamic, setDynamic, setServer
Methods inherited from class org.eclipse.jetty.server.Handler.Abstract
destroy, doStop, getServer
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, 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
Methods inherited from interface org.eclipse.jetty.util.component.Destroyable
destroy
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.server.Handler.Container
getContainer, getDescendant, getDescendants, getDescendants
Methods inherited from interface org.eclipse.jetty.server.Handler.Singleton
getHandlers, getTail, insertHandler, setHandler
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
EagerContentHandler
public EagerContentHandler()Construct anEagerContentHandler
with the defaultEagerContentHandler.ContentLoaderFactory
set -
EagerContentHandler
Construct anEagerContentHandler
with the defaultEagerContentHandler.ContentLoaderFactory
set- Parameters:
handler
- The next handler (also can be set withHandler.Wrapper.setHandler(Handler)
-
EagerContentHandler
Construct anEagerContentHandler
with the specificEagerContentHandler.ContentLoaderFactory
instances- Parameters:
factories
- TheEagerContentHandler.ContentLoaderFactory
instances used to eagerly load content.
-
EagerContentHandler
Construct anEagerContentHandler
with the specificEagerContentHandler.ContentLoaderFactory
instances- Parameters:
handler
- The next handler (also can be set withHandler.Wrapper.setHandler(Handler)
factories
- TheEagerContentHandler.ContentLoaderFactory
instances used to eagerly load content.
-
-
Method Details
-
onConditionsMet
protected boolean onConditionsMet(Request request, Response response, Callback callback) throws Exception Description copied from class:ConditionalHandler
Handle a request that has met the conditions. Typically, the implementation will provide optional handling and then call theConditionalHandler.nextHandler(Request, Response, Callback)
method to continue handling.- Specified by:
onConditionsMet
in classConditionalHandler
- Parameters:
request
- The request to handleresponse
- The response to generatecallback
- The callback for completion- Returns:
- True if this handler will complete the callback
- Throws:
Exception
- If there is a problem handling- See Also:
-