Interface MvcContext
-
public interface MvcContextThis class provides contextual information such as context and application paths as well as access to the Jakarta RESTful Web Services application configuration object. In addition, it provides access to the security-related beans
CsrfandEncoders.Implementations of this class are injectable, must be
RequestScopedand accessible from Jakarta Expression Language using the namemvc. For example, the CSRF token name and value can be accessed in Jakarta Expression Language using the expressionsmvc.csrf.nameandmvc.csrf.token, respectively.- Since:
- 1.0
- Author:
- Santiago Pericas-Geertsen, Ivar Grimstad
- See Also:
Configuration
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetBasePath()Get the application's base path which is defined as the concatenation of context and application paths.jakarta.ws.rs.core.ConfigurationgetConfig()Get the Jakarta RESTful Web Services application configuration object.CsrfgetCsrf()Get the CSRF object.EncodersgetEncoders()Get the built-in encoders.LocalegetLocale()Returns the locale of the current request.URIuri(String identifier)Creates an URI to be matched by a controller method.URIuri(String identifier, Map<String,Object> params)Creates an URI to be matched by a controller method.jakarta.ws.rs.core.UriBuilderuriBuilder(String identifier)Returns aUriBuilderfor building URIs to be matched by a controller method.
-
-
-
Method Detail
-
getConfig
jakarta.ws.rs.core.Configuration getConfig()
Get the Jakarta RESTful Web Services application configuration object. All application-defined properties are accessible via this object.- Returns:
- the configuration object.
-
getBasePath
String getBasePath()
Get the application's base path which is defined as the concatenation of context and application paths. It follows that the value returned by this method always starts with a slash but never ends with one.
- Returns:
- the application's base path.
-
getCsrf
Csrf getCsrf()
Get the CSRF object.- Returns:
- the CSRF object.
-
getEncoders
Encoders getEncoders()
Get the built-in encoders.- Returns:
- instance of encoders.
-
getLocale
Locale getLocale()
Returns the locale of the current request.- Returns:
- The request locale
-
uri
URI uri(String identifier)
Creates an URI to be matched by a controller method. This is aimed primarily for use in view rendering technologies to avoid duplicating the values of the
Pathannotations.The controller method can either be identified by the simple name of the controller class and the method name separated by '#' (MyController#myMethod) or by the value of the
UriRefannotation.The created URI includes context- and application path.
This method assumes that there is no parameter in the URI-template.
For example in Jakarta Server Pages:
${mvc.uri('MyController#myMethod')}- Parameters:
identifier- for the controller method.- Returns:
- the constructed URI including context- and application path.
-
uri
URI uri(String identifier, Map<String,Object> params)
Creates an URI to be matched by a controller method. This is aimed primarily for use in view rendering technologies to avoid duplicating the values of the
Pathannotations.The controller method can either be identified by the simple name of the controller class and the method name separated by '#' (MyController#myMethod) or by the value of the
UriRefannotation.The created URI includes context- and application path.
Any
PathParam,QueryParamandMatrixParamwhich could apply for given target method will be replaced if a matching key is found in the supplied Map. Please note that the map must contain values for all path parameters as they are required for building the URI. All other parameters are optional.For example in Jakarta Server Pages:
${mvc.uri('MyController#myMethod', {'foo': 'bar', 'id': 42})}- Parameters:
identifier- for the controller method.params- a map of path-, query- and matrix parameters.- Returns:
- the constructed URI including context- and application path.
- Throws:
IllegalArgumentException- if there are any URI template parameters without a supplied value, or if a value isnull.
-
uriBuilder
jakarta.ws.rs.core.UriBuilder uriBuilder(String identifier)
Returns a
UriBuilderfor building URIs to be matched by a controller method. This is aimed primarily for use in Java classes.The controller method can either be identified by the simple name of the controller class and the method name separated by '#' (MyController#myMethod) or by the value of the
UriRefannotation.- Parameters:
identifier- for the controller method.- Returns:
- a reference to a
UriBuilder.
-
-