org.codehaus.groovy.grails.web.servlet
Class DefaultGrailsApplicationAttributes

java.lang.Object
  extended by org.codehaus.groovy.grails.web.servlet.DefaultGrailsApplicationAttributes
All Implemented Interfaces:
ApplicationAttributes, GrailsApplicationAttributes

public class DefaultGrailsApplicationAttributes
extends Object
implements GrailsApplicationAttributes

Implementation of the GrailsApplicationAttributes interface that holds knowledge about how to obtain certain attributes from either the ServletContext or the HttpServletRequest instance.

Since:
0.3 Created: 17-Jan-2006
Author:
Graeme Rocher
See Also:
GrailsWebRequest

Field Summary
 
Fields inherited from interface org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
ACTION_NAME_ATTRIBUTE, CONTENT_FORMAT, CONTROLLER, CONTROLLER_NAME_ATTRIBUTE, ERRORS, FLASH_SCOPE, GSP_TEMPLATE_ENGINE, GSP_TMP_WRITER, GSP_TO_RENDER, ID_PARAM, MODEL_AND_VIEW, OUT, PAGE_SCOPE, PARAMS_OBJECT, PATH_TO_VIEWS, PROPERTY_REGISTRY, REQUEST_FORMATS, REQUEST_REDIRECTED_ATTRIBUTE, TAG_CACHE, WEB_REQUEST
 
Fields inherited from interface org.codehaus.groovy.grails.commons.ApplicationAttributes
APPLICATION_CONTEXT, PARENT_APPLICATION_CONTEXT, PLUGIN_MANAGER, REQUEST_SCOPE_ID
 
Constructor Summary
DefaultGrailsApplicationAttributes(ServletContext context)
           
 
Method Summary
 ApplicationContext getApplicationContext()
           
 String getApplicationUri(ServletRequest request)
           
 groovy.lang.GroovyObject getController(ServletRequest request)
           
 String getControllerActionUri(ServletRequest request)
           
 String getControllerUri(ServletRequest request)
           
 Errors getErrors(ServletRequest request)
           
 FlashScope getFlashScope(ServletRequest request)
          Retrieves the flash scope instance for the given requeste
 GrailsApplication getGrailsApplication()
           
 Writer getOut(HttpServletRequest request)
          Holds the current response write for the request
 GroovyPagesTemplateEngine getPagesTemplateEngine()
           
 String getPluginContextPath(HttpServletRequest request)
          Retrieves the plugin context path for the current request.
 ServletContext getServletContext()
          Retrieves the servlet context instance
 groovy.lang.GroovyObject getTagLibraryForTag(HttpServletRequest request, HttpServletResponse response, String tagName)
          Retrieves a Grails tag library from the request for the named tag in the default namespace GroovyPage.DEFAULT_NAMESPACE
 groovy.lang.GroovyObject getTagLibraryForTag(HttpServletRequest request, HttpServletResponse response, String tagName, String namespace)
          Retrieves a Grails tag library from the request for the named tag in a given namespace.
 String getTemplateUri(String templateName, ServletRequest request)
           
 String getViewUri(String viewName, HttpServletRequest request)
          Retrieves the uri of a named view
 void setOut(HttpServletRequest request, Writer out2)
          Sets the current write for the request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGrailsApplicationAttributes

public DefaultGrailsApplicationAttributes(ServletContext context)
Method Detail

getApplicationContext

public ApplicationContext getApplicationContext()
Specified by:
getApplicationContext in interface ApplicationAttributes
Returns:
The application context for servlet

getPluginContextPath

public String getPluginContextPath(HttpServletRequest request)
Description copied from interface: GrailsApplicationAttributes
Retrieves the plugin context path for the current request. The plugin context path is the path used by plugins to reference resources such as javascript, CSS and so forth It is established by evaluating the current controller, if the current controller is plugin provided then it will attempt to evaluate the path based on the plugin the controller came from

Specified by:
getPluginContextPath in interface GrailsApplicationAttributes
Returns:
The plugin context path

getController

public groovy.lang.GroovyObject getController(ServletRequest request)
Specified by:
getController in interface GrailsApplicationAttributes
Returns:
The controller for the request

getControllerUri

public String getControllerUri(ServletRequest request)
Specified by:
getControllerUri in interface GrailsApplicationAttributes
Returns:
The uri of the controller within the request

getApplicationUri

public String getApplicationUri(ServletRequest request)
Specified by:
getApplicationUri in interface GrailsApplicationAttributes
Returns:
The uri of the application relative to the server root

getServletContext

public ServletContext getServletContext()
Description copied from interface: GrailsApplicationAttributes
Retrieves the servlet context instance

Specified by:
getServletContext in interface GrailsApplicationAttributes
Returns:
The servlet context instance

getFlashScope

public FlashScope getFlashScope(ServletRequest request)
Description copied from interface: GrailsApplicationAttributes
Retrieves the flash scope instance for the given requeste

Specified by:
getFlashScope in interface GrailsApplicationAttributes
Returns:
The FlashScope instance

getTemplateUri

public String getTemplateUri(String templateName,
                             ServletRequest request)
Specified by:
getTemplateUri in interface GrailsApplicationAttributes
Returns:
The uri of a named template for the current controller

getControllerActionUri

public String getControllerActionUri(ServletRequest request)
Specified by:
getControllerActionUri in interface GrailsApplicationAttributes
Returns:
The uri of the action called within the controller

getErrors

public Errors getErrors(ServletRequest request)
Specified by:
getErrors in interface GrailsApplicationAttributes
Returns:
The errors instance contained within the request

getPagesTemplateEngine

public GroovyPagesTemplateEngine getPagesTemplateEngine()
Specified by:
getPagesTemplateEngine in interface GrailsApplicationAttributes
Returns:
Retrieves the shared GSP template engine

getGrailsApplication

public GrailsApplication getGrailsApplication()
Specified by:
getGrailsApplication in interface ApplicationAttributes
Returns:
Retrieves the grails application instance

getTagLibraryForTag

public groovy.lang.GroovyObject getTagLibraryForTag(HttpServletRequest request,
                                                    HttpServletResponse response,
                                                    String tagName)
Description copied from interface: GrailsApplicationAttributes
Retrieves a Grails tag library from the request for the named tag in the default namespace GroovyPage.DEFAULT_NAMESPACE

Specified by:
getTagLibraryForTag in interface GrailsApplicationAttributes
Parameters:
request - the request instance
response - the response instancte
tagName - The name of the tag that contains the tag library
Returns:
An instance of the tag library or null if not found

getTagLibraryForTag

public groovy.lang.GroovyObject getTagLibraryForTag(HttpServletRequest request,
                                                    HttpServletResponse response,
                                                    String tagName,
                                                    String namespace)
Description copied from interface: GrailsApplicationAttributes
Retrieves a Grails tag library from the request for the named tag in a given namespace.

Specified by:
getTagLibraryForTag in interface GrailsApplicationAttributes
Parameters:
request - the request instance
response - the response instancte
tagName - The name of the tag that contains the tag library
namespace - The namespace of the tag
Returns:
An instance of the tag library or null if not found

getViewUri

public String getViewUri(String viewName,
                         HttpServletRequest request)
Description copied from interface: GrailsApplicationAttributes
Retrieves the uri of a named view

Specified by:
getViewUri in interface GrailsApplicationAttributes
Parameters:
viewName - The name of the view
request - The request instance
Returns:
The name of the view

getOut

public Writer getOut(HttpServletRequest request)
Description copied from interface: GrailsApplicationAttributes
Holds the current response write for the request

Specified by:
getOut in interface GrailsApplicationAttributes
Returns:
The held response writer

setOut

public void setOut(HttpServletRequest request,
                   Writer out2)
Description copied from interface: GrailsApplicationAttributes
Sets the current write for the request

Specified by:
setOut in interface GrailsApplicationAttributes
Parameters:
request - The request
out2 - The writer


Copyright (c) 2005-2009 The Grails project