Package org.forgerock.http.routing
Class UriRouterContext
java.lang.Object
org.forgerock.services.context.AbstractContext
org.forgerock.http.routing.UriRouterContext
- All Implemented Interfaces:
Context
A
Context
which is created when a request has been routed. The
context includes:
- the portion of the request URI which matched the URI template
- the portion of the request URI which is remaining to be matched
- a method for obtaining the base URI, which represents the portion of the request URI which has been routed so far. This is obtained dynamically by concatenating the matched URI with matched URIs in parent router contexts
- a map which contains the parsed URI template variables, keyed on the URI template variable name.
UriRouterContext
may just redefine only the
{code matchedUri}, remainingUri
, uriTemplateVariables
as
part of their routing process.-
Nested Class Summary
-
Field Summary
Fields inherited from class org.forgerock.services.context.AbstractContext
data
-
Constructor Summary
ConstructorDescriptionUriRouterContext
(JsonValue savedContext, ClassLoader classLoader) Restore from JSON representation.UriRouterContext
(Context parent, String matchedUri, String remainingUri, Map<String, String> uriTemplateVariables) Creates a new routing context having the provided parent, URI template variables, and an ID automatically generated usingUUID.randomUUID()
.UriRouterContext
(Context parent, String matchedUri, String remainingUri, Map<String, String> uriTemplateVariables, URI originalUri) Creates a new routing context having the provided parent, URI template variables, and an ID automatically generated usingUUID.randomUUID()
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the portion of the request URI which has been routed so far.Returns the portion of the request URI which matched the URI template.Get the original URI.Returns the portion of the request URI which is remaining to be matched be the next router.Returns an unmodifiableMap
containing the parsed URI template variables, keyed on the URI template variable name.static UriRouterContext.Builder
uriRouterContext
(Context parent) Return a builder for a newUriRouterContext
.Methods inherited from class org.forgerock.services.context.AbstractContext
as, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toJsonValue, toString
-
Constructor Details
-
UriRouterContext
public UriRouterContext(Context parent, String matchedUri, String remainingUri, Map<String, String> uriTemplateVariables) Creates a new routing context having the provided parent, URI template variables, and an ID automatically generated usingUUID.randomUUID()
. The parameters provided in thisUriRouterContext
will override any parameters inherited from parentUriRouterContext
s.- Parameters:
parent
- The parent server context.matchedUri
- The matched URIremainingUri
- The remaining URI to be matched.uriTemplateVariables
- AMap
containing the parsed URI template variables, keyed on the URI template variable name.
-
UriRouterContext
public UriRouterContext(Context parent, String matchedUri, String remainingUri, Map<String, String> uriTemplateVariables, URI originalUri) Creates a new routing context having the provided parent, URI template variables, and an ID automatically generated usingUUID.randomUUID()
. The parameters provided in thisUriRouterContext
will override any parameters inherited from parentUriRouterContext
s.- Parameters:
parent
- The parent server context. (not null)matchedUri
- The matched URIremainingUri
- The remaining URI to be matched.uriTemplateVariables
- AMap
containing the parsed URI template variables, keyed on the URI template variable name. (not null)originalUri
- The original URI. If not null it will override theoriginalUri
defined in the closestUriRouterContext
referenced in the context's chain.
-
UriRouterContext
Restore from JSON representation.- Parameters:
savedContext
- The JSON representation from which this context's attributes should be parsed.classLoader
- The ClassLoader which can properly resolve the persisted class-name.
-
-
Method Details
-
getBaseUri
Returns the portion of the request URI which has been routed so far. This is obtained dynamically by concatenating the matched URI with the base URI of the parent router context if present. The base URI is nevernull
but may be "" (empty string).- Returns:
- The non-
null
portion of the request URI which has been routed so far.
-
getMatchedUri
Returns the portion of the request URI which matched the URI template. The matched URI is nevernull
but may be "" (empty string).- Returns:
- The non-
null
portion of the request URI which matched the URI template.
-
getRemainingUri
Returns the portion of the request URI which is remaining to be matched be the next router. The remaining URI is nevernull
but may be "" (empty string).- Returns:
- The non-
null
portion of the request URI which is remaining to be matched.
-
getUriTemplateVariables
Returns an unmodifiableMap
containing the parsed URI template variables, keyed on the URI template variable name.- Returns:
- The unmodifiable
Map
containing the parsed URI template variables, keyed on the URI template variable name.
-
getOriginalUri
Get the original URI.- Returns:
- The original URI
-
uriRouterContext
Return a builder for a newUriRouterContext
.- Parameters:
parent
- parent context- Returns:
- a builder for a new
UriRouterContext
.
-