Class Groovy


  • public abstract class Groovy
    extends Object
    Static methods for specialized Groovy integration.
    • Method Detail

      • ratpack

        public static void ratpack​(@DelegatesTo(value=Ratpack.class,strategy=1)
                                   Closure<?> closure)
        Starts a Ratpack app, defined by the given closure.

        This method is used in Ratpack scripts as the entry point.

         import ratpack.groovy.sql.SqlModule
         import static ratpack.groovy.Groovy.*
        
         ratpack {
           bindings {
             // example of registering a module
             add(new SqlModule())
           }
           handlers {
             // define the application handlers
             get("foo") {
               render "bar"
             }
           }
         }
         

        Standalone Scripts

        This method can be used by standalone scripts to start a Ratpack application. That is, you could save the above content in a file named “ratpack.groovy” (the name is irrelevant), then start the application by running `groovy ratpack.groovy` on the command line.

        Full Applications

        It's also possible to build Groovy Ratpack applications with a traditional class based entry point. The GroovyRatpackMain class provides such an entry point. In such a mode, a script like above is still used to define the application, but the script is no longer the entry point. Ratpack will manage the compilation and execution of the script internally.

        Parameters:
        closure - The definition closure, delegating to Groovy.Ratpack
      • groovyTemplate

        public static TextTemplate groovyTemplate​(String id)
        Creates a renderable Groovy based template, using no model and the default content type.
        Parameters:
        id - The id/name of the template
        Returns:
        a template
      • groovyMarkupTemplate

        public static MarkupTemplate groovyMarkupTemplate​(String id)
        Creates a renderable Groovy based markup template, using no model and the default content type.
        Parameters:
        id - The id/name of the template
        Returns:
        a template
      • groovyTemplate

        public static TextTemplate groovyTemplate​(String id,
                                                  String type)
        Creates a renderable Groovy based template, using no model.
        Parameters:
        id - The id/name of the template
        type - The content type of template
        Returns:
        a template
      • groovyMarkupTemplate

        public static MarkupTemplate groovyMarkupTemplate​(String id,
                                                          String type)
        Creates a renderable Groovy based markup template, using no model.
        Parameters:
        id - The id/name of the template
        type - The content type of template
        Returns:
        a template
      • groovyTemplate

        public static TextTemplate groovyTemplate​(Map<String,​?> model,
                                                  String id)
        Creates a renderable Groovy based template, using the default content type.
        Parameters:
        model - The template model
        id - The id/name of the template
        Returns:
        a template
      • groovyMarkupTemplate

        public static MarkupTemplate groovyMarkupTemplate​(Map<String,​?> model,
                                                          String id)
        Creates a renderable Groovy based markup template, using the default content type.
        Parameters:
        model - The template model
        id - The id/name of the template
        Returns:
        a template
      • groovyMarkupTemplate

        public static MarkupTemplate groovyMarkupTemplate​(String id,
                                                          Action<? super com.google.common.collect.ImmutableMap.Builder<String,​Object>> modelBuilder)
        Creates a renderable Groovy based markup template, using the default content type.
        Parameters:
        id - the id/name of the template
        modelBuilder - an action the builds a model map
        Returns:
        a template
      • groovyMarkupTemplate

        public static MarkupTemplate groovyMarkupTemplate​(String id,
                                                          String type,
                                                          Action<? super com.google.common.collect.ImmutableMap.Builder<String,​Object>> modelBuilder)
        Creates a renderable Groovy based markup template.
        Parameters:
        id - the id/name of the template
        type - The content type of template
        modelBuilder - an action the builds a model map
        Returns:
        a template
      • groovyTemplate

        public static TextTemplate groovyTemplate​(Map<String,​?> model,
                                                  String id,
                                                  String type)
        Creates a renderable Groovy based template.
        Parameters:
        model - The template model
        id - The id/name of the template
        type - The content type of template
        Returns:
        a template
      • groovyMarkupTemplate

        public static MarkupTemplate groovyMarkupTemplate​(Map<String,​?> model,
                                                          String id,
                                                          String type)
        Creates a renderable Groovy based template.
        Parameters:
        model - The template model
        id - The id/name of the template
        type - The content type of template
        Returns:
        a template