Class Request.In
- All Implemented Interfaces:
Future<Boolean>,Associator,Eligible
- Direct Known Subclasses:
Request.In.Connect,Request.In.Delete,Request.In.Get,Request.In.Head,Request.In.Options,Request.In.Post,Request.In.Put,Request.In.Trace
Incoming request flow downstream and are served by the framework.
A result of true indicates that the request has been processed,
i.e. a response has been sent or will sent. Händlers MUST
check that a request has not been fulfilled() before
firing a Response event to avoid duplicate response
events. Handlers that have fired a response event and all
related Output events SHOULD stop
the request event to avoid unnecessary subsequent invocations of
handlers. Handlers that want to do “postprocessing” MUST
therefore listen for the corresponding Request.In.Completed
event instead of defining a handler for the request event
with low priority.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe associated completion event.static classRepresents a HTTP CONNECT request.static classThe Class Delete.static classRepresents a HTTP GET request.static classRepresents a HTTP HEAD request.static classRepresents a HTTP OPTIONS request.static classRepresents a HTTP POST request.static classRepresents a HTTP PUT request.static classRepresents a HTTP TRACE request.Nested classes/interfaces inherited from class org.jgrapes.http.events.Request
Request.In, Request.OutNested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Field Summary
Fields inherited from class org.jgrapes.core.internal.EventBase
completed, completionEvents, invokedFor -
Constructor Summary
ConstructorsConstructorDescriptionIn(String protocol, HttpRequest request, int matchLevels, Channel... channels) Creates a new request event with the associatedRequest.In.Completedevent. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectcreateMatchValue(Class<?> type, ResourcePattern resource) Creates the match value.The match value consists of the event class and a URI.protected URIeffectiveRequestUri(String protocol, HttpRequest request) Builds the URI that represents this request.static Request.InfromHttpRequest(HttpRequest request, boolean secure, int matchLevels) Creates the appropriate derived request event type from a givenHttpRequest.booleanChecks if the request has been processed, i.e.Returns the “raw” request as provided by the HTTP decoder.booleanisEligibleFor(Object value) Returnstrueif thecriterionis of the same class or a base class of this event’s class.final URIReturns an absolute URI of the request.protected final voidsetRequestUri(URI uri) Sets the request URI.toString()Methods inherited from class org.jgrapes.core.Event
addCompletionEvent, associated, cancel, channels, channels, completionEvents, currentResults, forChannels, get, get, handled, handlingError, isCancelled, isDone, isStopped, processedBy, results, results, resumeHandling, setAssociated, setChannels, setRequiresResult, setResult, stop, suspendHandling, suspendHandling, tieToMethods inherited from class org.jgrapes.core.internal.EventBase
disableTracking, enqueued, firstResultAssigned, isTracked, onCompletionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jgrapes.core.Associator
associated, associated, associated, associatedGetMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Constructor Details
-
In
public In(String protocol, HttpRequest request, int matchLevels, Channel... channels) throws URISyntaxException Creates a new request event with the associatedRequest.In.Completedevent.- Parameters:
protocol- the protocol as reported byrequestUri()request- the request datamatchLevels- the number of elements from the request path to use in the match value (seematchValue)channels- the channels associated with this event- Throws:
URISyntaxException
-
-
Method Details
-
effectiveRequestUri
Builds the URI that represents this request.The default implementation checks that request URI in the HTTP request is directed at this server as specified in the “Host”-header and adds the protocol, host and port if not specified in the request URI.
- Parameters:
protocol- the protocolrequest- the request- Returns:
- the URI
- Throws:
URISyntaxException- if the request is not acceptable
-
fromHttpRequest
public static Request.In fromHttpRequest(HttpRequest request, boolean secure, int matchLevels) throws URISyntaxException Creates the appropriate derived request event type from a givenHttpRequest.- Parameters:
request- the HTTP requestsecure- whether the request was received over a secure channelmatchLevels- the match levels- Returns:
- the request event
- Throws:
URISyntaxException
-
setRequestUri
Sets the request URI.- Parameters:
uri- the new request URI
-
requestUri
Returns an absolute URI of the request.For incoming requests, the URI is built from the information provided by the decoder.
- Returns:
- the URI
-
httpRequest
Returns the “raw” request as provided by the HTTP decoder.- Returns:
- the request
-
defaultCriterion
The match value consists of the event class and a URI.The URI is similar to the request URI but its path elements are shortened as specified in the constructor.
The match value is used as key in a map that speeds up the lookup of handlers. Having the complete URI in the match value would inflate this map.
- Specified by:
defaultCriterionin interfaceEligible- Overrides:
defaultCriterionin classEvent<Boolean>- Returns:
- the object
- See Also:
-
isEligibleFor
Description copied from class:EventReturnstrueif thecriterionis of the same class or a base class of this event’s class.- Specified by:
isEligibleForin interfaceEligible- Overrides:
isEligibleForin classEvent<Boolean>- Parameters:
value- the criterion- Returns:
- true if this meets the criterion
- See Also:
-
fulfilled
Checks if the request has been processed, i.e.a response has been sent.
- Returns:
- true, if fulfilled
-
toString
-
createMatchValue
Creates the match value.- Parameters:
type- the typeresource- the resource- Returns:
- the object
-