Package org.grails.web.mapping
Class DefaultUrlMappingsHolder
- java.lang.Object
-
- org.grails.web.mapping.DefaultUrlMappingsHolder
-
- All Implemented Interfaces:
UrlMappings,UrlMappingsHolder
public class DefaultUrlMappingsHolder extends java.lang.Object implements UrlMappings
Default implementation of the UrlMappingsHolder interface that takes a list of mappings and then sorts them according to their precedence rules as defined in the implementation of Comparable.- Since:
- 0.4
- See Also:
UrlMapping,Comparable
-
-
Field Summary
Fields Modifier and Type Field Description static UrlMappingInfo[]EMPTY_RESULTS-
Fields inherited from interface grails.web.mapping.UrlMappingsHolder
BEAN_ID
-
-
Constructor Summary
Constructors Constructor Description DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings)DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings, java.util.List excludePatterns)DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings, java.util.List excludePatterns, boolean doNotCallInit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<UrlMapping>addMappings(groovy.lang.Closure mappings)Adds URL mappings to the current definition for the given closurejava.util.Set<org.springframework.http.HttpMethod>allowedMethods(java.lang.String uri)Return the allowed HTTP methods for the given URIjava.util.ListgetExcludePatterns()Retrieves the held Exclude Pattern instances as a list, could be null if there is no excludeUrlCreatorgetReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parametersUrlCreatorgetReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parametersUrlCreatorgetReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parametersUrlCreatorgetReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parametersUrlCreatorgetReverseMapping(java.lang.String controller, java.lang.String action, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parametersUrlCreatorgetReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parameters or null if non could be found.UrlCreatorgetReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parameters or null if non could be found.UrlCreatorgetReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.util.Map params)Retrieves the best guess of a URI for the given controller, action and parameters or null if non could be found.UrlMapping[]getUrlMappings()Retrieves the held UrlMapping instances as an arrayvoidinitialize()protected UrlMappinglookupMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)Performs a match uses reverse mappings to looks up a mapping from the controller, action and params.UrlMappingInfomatch(java.lang.String uri)Match and return the first UrlMappingInfo instance possibleUrlMappingInfo[]matchAll(java.lang.String uri)Matches all possible UrlMappingInfo instances to the given URI and returns them allUrlMappingInfo[]matchAll(java.lang.String uri, java.lang.String httpMethod)Match all possible UrlMappingInfo instances to the given URI and HTTP methodUrlMappingInfo[]matchAll(java.lang.String uri, java.lang.String httpMethod, java.lang.String version)Match all possible UrlMappingInfo instances to the given URI and HTTP methodUrlMappingInfo[]matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod)Match all possible UrlMappingInfo instances to the given URI and HTTP methodUrlMappingInfo[]matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod, java.lang.String version)Match all possible UrlMappingInfo instances to the given URI and HTTP methodUrlMappingInfomatchStatusCode(int responseCode)Match and return the first UrlMappingInfo instance possibleUrlMappingInfomatchStatusCode(int responseCode, java.lang.Throwable e)Match and return for first UrlMappingInfo for the give response code and exceptionvoidsetMaxWeightedCacheCapacity(int maxWeightedCacheCapacity)voidsetUrlCreatorMaxWeightedCacheCapacity(int urlCreatorMaxWeightedCacheCapacity)java.lang.StringtoString()
-
-
-
Field Detail
-
EMPTY_RESULTS
public static final UrlMappingInfo[] EMPTY_RESULTS
-
-
Constructor Detail
-
DefaultUrlMappingsHolder
public DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings)
-
DefaultUrlMappingsHolder
public DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings, java.util.List excludePatterns)
-
DefaultUrlMappingsHolder
public DefaultUrlMappingsHolder(java.util.List<UrlMapping> mappings, java.util.List excludePatterns, boolean doNotCallInit)
-
-
Method Detail
-
addMappings
public java.util.Collection<UrlMapping> addMappings(groovy.lang.Closure mappings)
Description copied from interface:UrlMappingsAdds URL mappings to the current definition for the given closure- Specified by:
addMappingsin interfaceUrlMappings- Parameters:
mappings- The mappings- Returns:
- Only the added mappings. To obtain all mappings use
UrlMappingsHolder.getUrlMappings()
-
initialize
public void initialize()
-
getUrlMappings
public UrlMapping[] getUrlMappings()
Description copied from interface:UrlMappingsHolderRetrieves the held UrlMapping instances as an array- Specified by:
getUrlMappingsin interfaceUrlMappingsHolder- Returns:
- An array of UrlMapping instances
-
getExcludePatterns
public java.util.List getExcludePatterns()
Description copied from interface:UrlMappingsHolderRetrieves the held Exclude Pattern instances as a list, could be null if there is no exclude- Specified by:
getExcludePatternsin interfaceUrlMappingsHolder- Returns:
- An list of String
-
getReverseMapping
public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters- Specified by:
getReverseMappingin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullparams- The parameters or null- Returns:
- A URI for the given arguments
-
getReverseMapping
public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters- Specified by:
getReverseMappingin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullpluginName- the name of the plugin which provides the controllerparams- The parameters or null- Returns:
- A URI for the given arguments
-
getReverseMapping
public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters- Specified by:
getReverseMappingin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullnamespace- The controller namespacepluginName- the name of the plugin which provides the controllerhttpMethod- The HTTP method to reverse mapparams- The parameters or null- Returns:
- A URI for the given arguments
-
getReverseMapping
public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters- Specified by:
getReverseMappingin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullnamespace- The controller namespacepluginName- the name of the plugin which provides the controllerhttpMethod- The HTTP method to reverse mapversion- The version of the mappingparams- The parameters or null- Returns:
- A URI for the given arguments
-
getReverseMapping
public UrlCreator getReverseMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters- Specified by:
getReverseMappingin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullnamespace- The controller namespace or nullpluginName- the name of the plugin which provides the controllerparams- The parameters or null- Returns:
- A URI for the given arguments
- See Also:
UrlMappingsHolder.getReverseMapping(String, String, java.util.Map)
-
getReverseMappingNoDefault
public UrlCreator getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters or null if non could be found.- Specified by:
getReverseMappingNoDefaultin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullparams- The parameters or null- Returns:
- A URI for the given arguments
-
getReverseMappingNoDefault
public UrlCreator getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters or null if non could be found.- Specified by:
getReverseMappingNoDefaultin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullnamespace- The controller namespace or nullpluginName- the name of the plugin which provides the controllerhttpMethod- the HTTP methodparams- The parameters or null- Returns:
- A URI for the given arguments
-
getReverseMappingNoDefault
public UrlCreator getReverseMappingNoDefault(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)
Description copied from interface:UrlMappingsHolderRetrieves the best guess of a URI for the given controller, action and parameters or null if non could be found.- Specified by:
getReverseMappingNoDefaultin interfaceUrlMappingsHolder- Parameters:
controller- The name of the controlleraction- The name of the action or nullnamespace- The controller namespace or nullpluginName- the name of the plugin which provides the controllerhttpMethod- the HTTP methodparams- The parameters or null- Returns:
- A URI for the given arguments
-
lookupMapping
protected UrlMapping lookupMapping(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.lang.String httpMethod, java.lang.String version, java.util.Map params)
Performs a match uses reverse mappings to looks up a mapping from the controller, action and params. This is refactored to use a list of mappings identified by only controller and action and then matches the mapping to select the mapping that best matches the params (most possible matches).- Parameters:
controller- The controller nameaction- The action namehttpMethod- The HTTP methodversion-params- The params @return A UrlMapping instance or null
-
match
public UrlMappingInfo match(java.lang.String uri)
Description copied from interface:UrlMappingsHolderMatch and return the first UrlMappingInfo instance possible- Specified by:
matchin interfaceUrlMappingsHolder- Parameters:
uri- The URI to match- Returns:
- A UrlMappingInfo or null
- See Also:
UrlMappingsHolder.match(String)
-
matchAll
public UrlMappingInfo[] matchAll(java.lang.String uri)
Description copied from interface:UrlMappingsHolderMatches all possible UrlMappingInfo instances to the given URI and returns them all- Specified by:
matchAllin interfaceUrlMappingsHolder- Parameters:
uri- The URI to match- Returns:
- An array of 0 or many UrlMappngInfo instances
-
matchAll
public UrlMappingInfo[] matchAll(java.lang.String uri, java.lang.String httpMethod)
Description copied from interface:UrlMappingsHolderMatch all possible UrlMappingInfo instances to the given URI and HTTP method- Specified by:
matchAllin interfaceUrlMappingsHolder- Parameters:
uri- The URI to matchhttpMethod- The HTTP method (GET,POST,PUT,DELETE etc.)- Returns:
- An array of 0 or many UrlMappingInfo instances
-
matchAll
public UrlMappingInfo[] matchAll(java.lang.String uri, java.lang.String httpMethod, java.lang.String version)
Description copied from interface:UrlMappingsHolderMatch all possible UrlMappingInfo instances to the given URI and HTTP method- Specified by:
matchAllin interfaceUrlMappingsHolder- Parameters:
uri- The URI to matchhttpMethod- The HTTP method (GET,POST,PUT,DELETE etc.)version- The version of the API- Returns:
- An array of 0 or many UrlMappingInfo instances
-
matchAll
public UrlMappingInfo[] matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod)
Description copied from interface:UrlMappingsHolderMatch all possible UrlMappingInfo instances to the given URI and HTTP method- Specified by:
matchAllin interfaceUrlMappingsHolder- Parameters:
uri- The URI to matchhttpMethod- The HTTP method (GET,POST,PUT,DELETE etc.)- Returns:
- An array of 0 or many UrlMappingInfo instances
-
matchAll
public UrlMappingInfo[] matchAll(java.lang.String uri, org.springframework.http.HttpMethod httpMethod, java.lang.String version)
Description copied from interface:UrlMappingsHolderMatch all possible UrlMappingInfo instances to the given URI and HTTP method- Specified by:
matchAllin interfaceUrlMappingsHolder- Parameters:
uri- The URI to matchhttpMethod- The HTTP method (GET,POST,PUT,DELETE etc.)version- The version- Returns:
- An array of 0 or many UrlMappingInfo instances
-
matchStatusCode
public UrlMappingInfo matchStatusCode(int responseCode)
Description copied from interface:UrlMappingsHolderMatch and return the first UrlMappingInfo instance possible- Specified by:
matchStatusCodein interfaceUrlMappingsHolder- Parameters:
responseCode- The responseCode to match- Returns:
- A UrlMappingInfo or null
-
allowedMethods
public java.util.Set<org.springframework.http.HttpMethod> allowedMethods(java.lang.String uri)
Description copied from interface:UrlMappingsHolderReturn the allowed HTTP methods for the given URI- Specified by:
allowedMethodsin interfaceUrlMappingsHolder- Parameters:
uri- The URI- Returns:
- The allowed methods
-
matchStatusCode
public UrlMappingInfo matchStatusCode(int responseCode, java.lang.Throwable e)
Description copied from interface:UrlMappingsHolderMatch and return for first UrlMappingInfo for the give response code and exception- Specified by:
matchStatusCodein interfaceUrlMappingsHolder- Parameters:
responseCode- The response codee- The exception- Returns:
- The UrlMappingInfo instance
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setMaxWeightedCacheCapacity
public void setMaxWeightedCacheCapacity(int maxWeightedCacheCapacity)
-
setUrlCreatorMaxWeightedCacheCapacity
public void setUrlCreatorMaxWeightedCacheCapacity(int urlCreatorMaxWeightedCacheCapacity)
-
-