Package org.forgerock.http.routing
Class UriRouterContext
- java.lang.Object
-
- org.forgerock.services.context.AbstractContext
-
- org.forgerock.http.routing.UriRouterContext
-
- All Implemented Interfaces:
Context
public final class UriRouterContext extends AbstractContext
AContext
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
Nested Classes Modifier and Type Class Description static class
UriRouterContext.Builder
EaseUriRouterContext
construction.
-
Field Summary
-
Fields inherited from class org.forgerock.services.context.AbstractContext
data
-
-
Constructor Summary
Constructors Constructor Description UriRouterContext(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBaseUri()
Returns the portion of the request URI which has been routed so far.String
getMatchedUri()
Returns the portion of the request URI which matched the URI template.URI
getOriginalUri()
Get the original URI.String
getRemainingUri()
Returns the portion of the request URI which is remaining to be matched be the next router.Map<String,String>
getUriTemplateVariables()
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 Detail
-
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
public UriRouterContext(JsonValue savedContext, ClassLoader classLoader)
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 Detail
-
getBaseUri
public String 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
public String 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
public String 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
public Map<String,String> 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
public URI getOriginalUri()
Get the original URI.- Returns:
- The original URI
-
uriRouterContext
public static UriRouterContext.Builder uriRouterContext(Context parent)
Return a builder for a newUriRouterContext
.- Parameters:
parent
- parent context- Returns:
- a builder for a new
UriRouterContext
.
-
-