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
Modifier and TypeClassDescriptionstatic class
The associated completion event.static class
Represents a HTTP CONNECT request.static class
The Class Delete.static class
Represents a HTTP GET request.static class
Represents a HTTP HEAD request.static class
Represents a HTTP OPTIONS request.static class
Represents a HTTP POST request.static class
Represents a HTTP PUT request.static class
Represents a HTTP TRACE request.Nested classes/interfaces inherited from class org.jgrapes.http.events.Request
Request.In, Request.Out
Nested 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
ConstructorDescriptionIn
(String protocol, HttpRequest request, int matchLevels, Channel... channels) Creates a new request event with the associatedRequest.In.Completed
event. -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
createMatchValue
(Class<?> type, ResourcePattern resource) Creates the match value.The match value consists of the event class and a URI.protected URI
effectiveRequestUri
(String protocol, HttpRequest request) Builds the URI that represents this request.static Request.In
fromHttpRequest
(HttpRequest request, boolean secure, int matchLevels) Creates the appropriate derived request event type from a givenHttpRequest
.boolean
Checks if the request has been processed, i.e.Returns the “raw” request as provided by the HTTP decoder.boolean
isEligibleFor
(Object value) Returnstrue
if thecriterion
is of the same class or a base class of this event’s class.final URI
Returns an absolute URI of the request.protected final void
setRequestUri
(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, tieTo
Methods inherited from class org.jgrapes.core.internal.EventBase
disableTracking, enqueued, firstResultAssigned, isTracked, onCompletion
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jgrapes.core.Associator
associated, associated, associated, associatedGet
Methods 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.Completed
event.- 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:
defaultCriterion
in interfaceEligible
- Overrides:
defaultCriterion
in classEvent<Boolean>
- Returns:
- the object
- See Also:
-
isEligibleFor
Description copied from class:Event
Returnstrue
if thecriterion
is of the same class or a base class of this event’s class.- Specified by:
isEligibleFor
in interfaceEligible
- Overrides:
isEligibleFor
in 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
-