Top Description Methods
javax.mvc

public Interface MvcContext

Imports
javax.mvc.security.Csrf, .Encoders, javax.ws.rs.core.Configuration, .UriBuilder, java.net.URI, java.util.Locale, .Map

This class provides contextual information such as context and application paths as well as access to the JAX-RS application configuration object. In addition, it provides access to the security-related beans javax.mvc.security.Csrf and javax.mvc.security.Encoders.

Implementations of this class are injectable, must be javax.enterprise.context.RequestScoped and accessible from EL using the name mvc. For example, the CSRF token name and value can be accessed in EL using the expressions mvc.csrf.name and mvc.csrf.token, respectively.

Author
Santiago Pericas-Geertsen
Since
1.0
See Also
javax.ws.rs.core.Configuration

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the application's base path.
getBasePath
()

Get the application's base path which is defined as the concatenation of context and application paths.

public Configuration

Returns:

the configuration object.
getConfig
()

Get the JAX-RS application configuration object.

public Csrf

Returns:

the CSRF object.
getCsrf
()

Get the CSRF object.

public Encoders

Returns:

instance of encoders.
getEncoders
()

Get the built-in encoders.

public Locale

Returns:

The request locale
getLocale
()

Returns the locale of the current request.

public URI

Returns:

the constructed URI including context- and application path.
uri
(String
for the controller method.
identifier
)

Creates an URI to be matched by a controller method.

public URI

Returns:

the constructed URI including context- and application path.
uri
(String
for the controller method.
identifier
,
Map<String, Object>
a map of path-, query- and matrix parameters.
params
)

Creates an URI to be matched by a controller method.

public UriBuilder

Returns:

a reference to a UriBuilder.
uriBuilder
(String
for the controller method.
identifier
)

Returns a UriBuilder for building URIs to be matched by a controller method.

Method Detail

getBasePathback to summary
public 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:String

the application's base path.

getConfigback to summary
public Configuration getConfig()

Get the JAX-RS application configuration object. All application-defined properties are accessible via this object.

Returns:Configuration

the configuration object.

getCsrfback to summary
public Csrf getCsrf()

Get the CSRF object.

Returns:Csrf

the CSRF object.

getEncodersback to summary
public Encoders getEncoders()

Get the built-in encoders.

Returns:Encoders

instance of encoders.

getLocaleback to summary
public Locale getLocale()

Returns the locale of the current request.

Returns:Locale

The request locale

uriback to summary
public 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 javax.ws.rs.Path annotations.

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 UriRef annotation.

The created URI includes context- and application path.

This method assumes that there is no parameter in the URI-template.

For example in JSP:

${mvc.uri('MyController#myMethod')}
Parameters
identifier:String

for the controller method.

Returns:URI

the constructed URI including context- and application path.

uriback to summary
public 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 javax.ws.rs.Path annotations.

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 UriRef annotation.

The created URI includes context- and application path.

Any javax.ws.rs.PathParam, javax.ws.rs.QueryParam and javax.ws.rs.MatrixParam which 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 JSP:

${mvc.uri('MyController#myMethod', {'foo': 'bar', 'id': 42})}
Parameters
identifier:String

for the controller method.

params:Map<String, Object>

a map of path-, query- and matrix parameters.

Returns:URI

the constructed URI including context- and application path.

Exceptions
IllegalArgumentException:
if there are any URI template parameters without a supplied value, or if a value is null.
uriBuilderback to summary
public UriBuilder uriBuilder(String identifier)

Returns a UriBuilder for 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 UriRef annotation.

Parameters
identifier:String

for the controller method.

Returns:UriBuilder

a reference to a UriBuilder.