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
AContextwhich 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.
UriRouterContextmay just redefine only the {code matchedUri},remainingUri,uriTemplateVariablesas part of their routing process.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUriRouterContext.BuilderEaseUriRouterContextconstruction.
-
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 StringgetBaseUri()Returns the portion of the request URI which has been routed so far.StringgetMatchedUri()Returns the portion of the request URI which matched the URI template.URIgetOriginalUri()Get the original URI.StringgetRemainingUri()Returns the portion of the request URI which is remaining to be matched be the next router.Map<String,String>getUriTemplateVariables()Returns an unmodifiableMapcontaining the parsed URI template variables, keyed on the URI template variable name.static UriRouterContext.BuilderuriRouterContext(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 thisUriRouterContextwill override any parameters inherited from parentUriRouterContexts.- Parameters:
parent- The parent server context.matchedUri- The matched URIremainingUri- The remaining URI to be matched.uriTemplateVariables- AMapcontaining 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 thisUriRouterContextwill override any parameters inherited from parentUriRouterContexts.- Parameters:
parent- The parent server context. (not null)matchedUri- The matched URIremainingUri- The remaining URI to be matched.uriTemplateVariables- AMapcontaining the parsed URI template variables, keyed on the URI template variable name. (not null)originalUri- The original URI. If not null it will override theoriginalUridefined in the closestUriRouterContextreferenced 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 nevernullbut may be "" (empty string).- Returns:
- The non-
nullportion 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 nevernullbut may be "" (empty string).- Returns:
- The non-
nullportion 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 nevernullbut may be "" (empty string).- Returns:
- The non-
nullportion of the request URI which is remaining to be matched.
-
getUriTemplateVariables
public Map<String,String> getUriTemplateVariables()
Returns an unmodifiableMapcontaining the parsed URI template variables, keyed on the URI template variable name.- Returns:
- The unmodifiable
Mapcontaining 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.
-
-