org.codehaus.groovy.grails.commons
Class DefaultGrailsControllerClass

java.lang.Object
  extended by org.codehaus.groovy.grails.commons.AbstractGrailsClass
      extended by org.codehaus.groovy.grails.commons.AbstractInjectableGrailsClass
          extended by org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
All Implemented Interfaces:
GrailsClass, GrailsControllerClass, InjectableGrailsClass

public class DefaultGrailsControllerClass
extends AbstractInjectableGrailsClass
implements GrailsControllerClass

A class that evaluates the conventions contained within controllers to perform auto-configuration

Since:
0.1 Created: Jul 2, 2005
Author:
Graeme Rocher, Steven Devijver

Field Summary
static String CONTROLLER
           
 
Fields inherited from class org.codehaus.groovy.grails.commons.AbstractGrailsClass
LOG
 
Fields inherited from interface org.codehaus.groovy.grails.commons.GrailsControllerClass
AFTER_INTERCEPTOR, BEFORE_INTERCEPTOR, INDEX_ACTION
 
Constructor Summary
DefaultGrailsControllerClass(Class clazz)
           
 
Method Summary
 groovy.lang.Closure getAfterInterceptor(groovy.lang.GroovyObject controller)
          Retrieves the after interceptor for the specified controller instance
 groovy.lang.Closure getBeforeInterceptor(groovy.lang.GroovyObject controller)
          Retrieves the before interceptor for the specified controller instance
 String getClosurePropertyName(String uri)
          Returns a closure property name for a specific URI or null if the URI does not map to a closure.
 Set getCommandObjectActions()
           
 Set getCommandObjectClasses()
           
 String getDefaultAction()
          Returns the default action for this Controller
 Map getFlows()
          Returns a map of the flows for this controller.
 String[] getURIs()
          Gets the list of all possible URI's available in this controller.
 String getViewByName(String viewName)
          Retrieves the view name for the specified closure name
 String getViewByURI(String uri)
          Retrieves the view name for the specified URI
 boolean isFlowAction(String actionName)
          Returns true if the given action name is a flow action
 boolean isHttpMethodAllowedForAction(groovy.lang.GroovyObject controller, String httpMethod, String actionName)
          Checks to see if an action is accessible via a particular http method
 boolean isInterceptedAfter(groovy.lang.GroovyObject controller, String action)
          Checks whether the specified action is intercepted after for the specified controller instance
 boolean isInterceptedBefore(groovy.lang.GroovyObject controller, String action)
          Checks whether the specified action is intercepted for the specified controller instance
 boolean mapsToURI(String uri)
          Tests if a controller maps to a given URI.
 void registerMapping(String actionName)
          Registers a new mapping onto this controller for the given actionName
 void setDefaultActionName(String defaultActionName)
          Sets the name of the default action
 
Methods inherited from class org.codehaus.groovy.grails.commons.AbstractInjectableGrailsClass
byName, byType, getAvailable
 
Methods inherited from class org.codehaus.groovy.grails.commons.AbstractGrailsClass
getClazz, getFullName, getLogicalPropertyName, getMetaClass, getName, getNaturalName, getPackageName, getPropertyDescriptors, getPropertyName, getPropertyOrStaticPropertyOrFieldValue, getPropertyType, getPropertyValue, getPropertyValue, getPropertyValueObject, getReference, getReferenceInstance, getShortName, hasMetaMethod, hasMetaMethod, hasMetaProperty, hasProperty, isReadableProperty, newInstance, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.codehaus.groovy.grails.commons.InjectableGrailsClass
byName, byType, getAvailable
 
Methods inherited from interface org.codehaus.groovy.grails.commons.GrailsClass
getClazz, getFullName, getLogicalPropertyName, getMetaClass, getName, getNaturalName, getPackageName, getPropertyName, getPropertyValue, getPropertyValue, getReference, getReferenceInstance, getShortName, hasProperty, newInstance
 

Field Detail

CONTROLLER

public static final String CONTROLLER
See Also:
Constant Field Values
Constructor Detail

DefaultGrailsControllerClass

public DefaultGrailsControllerClass(Class clazz)
Method Detail

setDefaultActionName

public void setDefaultActionName(String defaultActionName)
Description copied from interface: GrailsControllerClass
Sets the name of the default action

Specified by:
setDefaultActionName in interface GrailsControllerClass
Parameters:
defaultActionName - The default action name

getURIs

public String[] getURIs()
Description copied from interface: GrailsControllerClass

Gets the list of all possible URI's available in this controller.

Specified by:
getURIs in interface GrailsControllerClass
Returns:
list of all possible URI's

mapsToURI

public boolean mapsToURI(String uri)
Description copied from interface: GrailsControllerClass

Tests if a controller maps to a given URI.

Specified by:
mapsToURI in interface GrailsControllerClass
Returns:
true if controller maps to URI

getViewByURI

public String getViewByURI(String uri)
Description copied from interface: GrailsControllerClass
Retrieves the view name for the specified URI

Specified by:
getViewByURI in interface GrailsControllerClass
Parameters:
uri - the name of URI
Returns:
the view name of null if not found

getClosurePropertyName

public String getClosurePropertyName(String uri)
Description copied from interface: GrailsControllerClass

Returns a closure property name for a specific URI or null if the URI does not map to a closure.

Specified by:
getClosurePropertyName in interface GrailsControllerClass
Parameters:
uri - the URI of the request
Returns:
the closure property name mapped to the URI or null is no closure was found

getViewByName

public String getViewByName(String viewName)
Description copied from interface: GrailsControllerClass
Retrieves the view name for the specified closure name

Specified by:
getViewByName in interface GrailsControllerClass
Parameters:
viewName - The name of the closure
Returns:
The view for the specified closure action

isInterceptedBefore

public boolean isInterceptedBefore(groovy.lang.GroovyObject controller,
                                   String action)
Description copied from interface: GrailsControllerClass
Checks whether the specified action is intercepted for the specified controller instance

Specified by:
isInterceptedBefore in interface GrailsControllerClass
Parameters:
controller - The instance of the controller
action - The action to check
Returns:
True if it is intercepted

isHttpMethodAllowedForAction

public boolean isHttpMethodAllowedForAction(groovy.lang.GroovyObject controller,
                                            String httpMethod,
                                            String actionName)
Description copied from interface: GrailsControllerClass
Checks to see if an action is accessible via a particular http method

Specified by:
isHttpMethodAllowedForAction in interface GrailsControllerClass
Parameters:
controller - The instance of the controller
httpMethod - The http request method
actionName - The action to check
Returns:
true if the action is accessible via the specified http method

isInterceptedAfter

public boolean isInterceptedAfter(groovy.lang.GroovyObject controller,
                                  String action)
Description copied from interface: GrailsControllerClass
Checks whether the specified action is intercepted after for the specified controller instance

Specified by:
isInterceptedAfter in interface GrailsControllerClass
Parameters:
controller - The controller instance
action - The action to check
Returns:
True if it is intercepted

getBeforeInterceptor

public groovy.lang.Closure getBeforeInterceptor(groovy.lang.GroovyObject controller)
Description copied from interface: GrailsControllerClass
Retrieves the before interceptor for the specified controller instance

Specified by:
getBeforeInterceptor in interface GrailsControllerClass
Parameters:
controller - The controller instance
Returns:
The before interceptor as a Closure or null if non exists

getAfterInterceptor

public groovy.lang.Closure getAfterInterceptor(groovy.lang.GroovyObject controller)
Description copied from interface: GrailsControllerClass
Retrieves the after interceptor for the specified controller instance

Specified by:
getAfterInterceptor in interface GrailsControllerClass
Parameters:
controller - The controller instance
Returns:
The after interceptor as a Closure or null if non exists

getCommandObjectActions

public Set getCommandObjectActions()
Specified by:
getCommandObjectActions in interface GrailsControllerClass
Returns:
A Set of names of actions with command objects presented in this controller

getCommandObjectClasses

public Set getCommandObjectClasses()
Specified by:
getCommandObjectClasses in interface GrailsControllerClass
Returns:
A Set of command object classes used by this controller

getFlows

public Map getFlows()
Description copied from interface: GrailsControllerClass

Returns a map of the flows for this controller. A flow is an action that ends with the convention "Flow". The keys in the map are the flow ids which are the text before the "Flow" suffix. For example a flow called "bookFlow" would have a key of "book"

The values within the Map are Groovy closures (@see groovy.lang.Closure) which represent the flow definition

Specified by:
getFlows in interface GrailsControllerClass
Returns:
A Map of flows for this controller

isFlowAction

public boolean isFlowAction(String actionName)
Description copied from interface: GrailsControllerClass
Returns true if the given action name is a flow action

Specified by:
isFlowAction in interface GrailsControllerClass
Parameters:
actionName - The name of the action
Returns:
True if it is a flow action

getDefaultAction

public String getDefaultAction()
Description copied from interface: GrailsControllerClass
Returns the default action for this Controller

Specified by:
getDefaultAction in interface GrailsControllerClass
Returns:
The default action

registerMapping

public void registerMapping(String actionName)
Description copied from interface: GrailsControllerClass
Registers a new mapping onto this controller for the given actionName

Specified by:
registerMapping in interface GrailsControllerClass
Parameters:
actionName - The actionName


Copyright (c) 2005-2009 The Grails project