2 * Copyright 2004-2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.codehaus
.groovy
.grails
.web
.servlet
.mvc
;
18 import groovy
.lang
.Closure
;
19 import groovy
.lang
.GroovyObject
;
23 import javax
.servlet
.ServletContext
;
24 import javax
.servlet
.http
.HttpServletRequest
;
25 import javax
.servlet
.http
.HttpServletResponse
;
27 import org
.codehaus
.groovy
.grails
.commons
.GrailsControllerClass
;
28 import org
.codehaus
.groovy
.grails
.web
.servlet
.GrailsApplicationAttributes
;
29 import org
.springframework
.web
.servlet
.ModelAndView
;
31 * An interface for a helper class that processes Grails controller requests and responses
33 * @author Graeme Rocher
36 * Created: Oct 27, 2005
38 public interface GrailsControllerHelper
{
41 * @return The servlet context instance
43 public abstract ServletContext
getServletContext();
45 * Retrieves a controller class for the specified class name
47 * @return The controller class or null
49 public abstract GrailsControllerClass
getControllerClassByName(String className
);
52 * Retrieves a GrailsControllerClass by URI
54 * @param uri The URI to lookup
55 * @return A GrailsControllerClass
57 public abstract GrailsControllerClass
getControllerClassByURI(String uri
);
59 * Creates a new controller instance for the specified GrailsControllerClass
60 * @param controllerClass The GrailsControllerClass
61 * @return A new controller instance
63 public abstract GroovyObject
getControllerInstance(
64 GrailsControllerClass controllerClass
);
67 * Handles a Grails URI
68 * @param uri The URI to processs
69 * @param webRequest The GrailsWebRequest
70 * @return A ModelAndView instance
72 public abstract ModelAndView
handleURI(String uri
,GrailsWebRequest webRequest
);
75 * Handles a Controller action
77 * @param action An action Closure instance
78 * @param request The request object
79 * @param response The response
81 * @return The action response
83 public abstract Object
handleAction(GroovyObject controller
,Closure action
,HttpServletRequest request
, HttpServletResponse response
);
86 * Handles a Controller action
88 * @param action An action Closure instance
89 * @param request The request object
90 * @param response The response
91 * @param params A Map of controller parameters
93 * @return The action response
95 public abstract Object
handleAction(GroovyObject controller
,Closure action
,HttpServletRequest request
, HttpServletResponse response
, Map params
);
98 * Processes an action response for the specified arguments
100 * @param controller The controller instance
101 * @param returnValue The response from the closure
102 * @param closurePropertyName The property name of the closure
103 * @param viewName The name of the view
105 * @return A ModelAndView object
107 public abstract ModelAndView
handleActionResponse(
108 GroovyObject controller
, Object returnValue
,
109 String closurePropertyName
, String viewName
);
112 * Handles a Grails URI
113 * @param uri The URI to processs
114 * @param webRequest the GrailsWebRequest instance
115 * @param params A map of controller parameters
116 * @return A ModelAndView instance
118 public abstract ModelAndView
handleURI(String uri
,
119 GrailsWebRequest webRequest
, Map params
);
124 * @return Returns the grails request attributes instance
126 GrailsApplicationAttributes
getGrailsAttributes();