Search in sources :

Example 91 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class RunGroovyTest method testClosureWithDefaultParam.

public void testClosureWithDefaultParam() throws Exception {
    GroovyObject object = compile("src/test/groovy/ClosureWithDefaultParamTest.groovy");
    object.invokeMethod("methodWithDefaultParam", null);
}
Also used : GroovyObject(groovy.lang.GroovyObject)

Example 92 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class RunGroovyTest method testMap.

public void testMap() throws Exception {
    GroovyObject object = compile("src/test/groovy/MapTest.groovy");
    object.invokeMethod("testMap", null);
}
Also used : GroovyObject(groovy.lang.GroovyObject)

Example 93 with GroovyObject

use of groovy.lang.GroovyObject in project groovy-core by groovy.

the class RunGroovyTest method testClosure.

public void testClosure() throws Exception {
    GroovyObject object = compile("src/test/groovy/ClosureMethodTest.groovy");
    object.invokeMethod("testListCollect", null);
}
Also used : GroovyObject(groovy.lang.GroovyObject)

Example 94 with GroovyObject

use of groovy.lang.GroovyObject in project grails-core by grails.

the class DefaultGrailsApplicationAttributes method getControllerName.

private String getControllerName(ServletRequest request) {
    String controllerName = (String) request.getAttribute(GrailsApplicationAttributes.CONTROLLER_NAME_ATTRIBUTE);
    if (controllerName == null || controllerName.length() == 0) {
        GroovyObject controller = getController(request);
        if (controller != null) {
            controllerName = (String) controller.getProperty("controllerName");
            request.setAttribute(GrailsApplicationAttributes.CONTROLLER_NAME_ATTRIBUTE, controllerName);
            if (controller instanceof GrailsControllerClass) {
                String namespace = ((GrailsControllerClass) controller).getNamespace();
                if (namespace != null) {
                    request.setAttribute(GrailsApplicationAttributes.CONTROLLER_NAMESPACE_ATTRIBUTE, namespace);
                }
            }
        }
    }
    return controllerName != null ? controllerName : "";
}
Also used : GrailsControllerClass(grails.core.GrailsControllerClass) GroovyObject(groovy.lang.GroovyObject)

Example 95 with GroovyObject

use of groovy.lang.GroovyObject in project grails-core by grails.

the class GroovyPageViewResolver method createGrailsView.

protected View createGrailsView(String viewName) throws Exception {
    // try GSP if res is null
    GroovyObject controller = null;
    GrailsWebRequest webRequest = GrailsWebRequest.lookup();
    if (webRequest != null) {
        HttpServletRequest request = webRequest.getCurrentRequest();
        controller = webRequest.getAttributes().getController(request);
    }
    GroovyPageScriptSource scriptSource;
    if (controller == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Locating GSP view for path {}", viewName);
        }
        scriptSource = groovyPageLocator.findViewByPath(viewName);
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Locating GSP view for controller {} and path {}", controller, viewName);
        }
        scriptSource = groovyPageLocator.findView(controller, viewName);
    }
    if (scriptSource != null) {
        return createGroovyPageView(scriptSource.getURI(), scriptSource);
    }
    return createFallbackView(viewName);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) GroovyPageScriptSource(org.grails.gsp.io.GroovyPageScriptSource) GrailsWebRequest(org.grails.web.servlet.mvc.GrailsWebRequest) GroovyObject(groovy.lang.GroovyObject)

Aggregations

GroovyObject (groovy.lang.GroovyObject)142 GroovyClassLoader (groovy.lang.GroovyClassLoader)15 Closure (groovy.lang.Closure)11 File (java.io.File)8 Map (java.util.Map)8 Decorator (com.opensymphony.module.sitemesh.Decorator)7 GroovyRuntimeException (groovy.lang.GroovyRuntimeException)7 MetaClass (groovy.lang.MetaClass)7 HashMap (java.util.HashMap)7 GrailsWebRequest (org.grails.web.servlet.mvc.GrailsWebRequest)7 Page (com.opensymphony.module.sitemesh.Page)5 HTMLPageParser (com.opensymphony.module.sitemesh.parser.HTMLPageParser)5 Config (grails.config.Config)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ServletContext (javax.servlet.ServletContext)5 PropertySourcesConfig (org.grails.config.PropertySourcesConfig)5 MockApplicationContext (org.grails.support.MockApplicationContext)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 MockServletConfig (org.springframework.mock.web.MockServletConfig)5 ArrayList (java.util.ArrayList)4