Package ratpack.groovy.handling
Class GroovyChainAction
- java.lang.Object
-
- ratpack.groovy.handling.GroovyChainAction
-
- All Implemented Interfaces:
Action<Chain>,GroovyChain,Chain
public abstract class GroovyChainAction extends java.lang.Object implements GroovyChain, Action<Chain>
A convenience super class for a standalone implementation of aAction<GroovyChain>.Subclasses implement the
execute()method, and implicitly program against theGroovyChainDSL.import ratpack.groovy.handling.GroovyChainAction import ratpack.groovy.test.embed.GroovyEmbeddedApp class Handlers extends GroovyChainAction { public void execute() throws Exception { path { render "root" } prefix("foo") { path("bar") { render "foobar" } } } } GroovyEmbeddedApp.of { handlers new Handlers() } test { assert getText() == "root" assert getText("foo/bar") == "foobar" }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ratpack.func.Action
Action.ConditionalSpec<I>
-
-
Constructor Summary
Constructors Constructor Description GroovyChainAction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description GroovyChainall(Handler handler)Adds the given handler to this.abstract voidexecute()Defines the handler chain.voidexecute(Chain chain)Invokesexecute()while setting the given chain as the implicit receiver.RegistrygetRegistry()The registry that backs this chain.ServerConfiggetServerConfig()The server config of the application that this chain is being created for.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ratpack.func.Action
append, curry, prepend, toConsumer, uncheckedWith, with
-
Methods inherited from interface ratpack.groovy.handling.GroovyChain
all, all, chain, delete, delete, delete, delete, delete, delete, files, files, files, fileSystem, fileSystem, fileSystem, get, get, get, get, get, get, host, host, host, insert, insert, insert, notFound, onlyIf, onlyIf, onlyIf, onlyIf, onlyIf, onlyIf, options, options, options, options, options, options, patch, patch, patch, patch, patch, patch, path, path, path, path, path, path, post, post, post, post, post, post, prefix, prefix, prefix, put, put, put, put, put, put, redirect, register, register, register, register, register, register, register, register, register, when, when, when, when, when, when, when, when, when, when, when, when, when, when, when, when, when, when
-
-
-
-
Method Detail
-
execute
public abstract void execute() throws java.lang.ExceptionDefines the handler chain.- Throws:
java.lang.Exception- any
-
execute
public final void execute(Chain chain) throws java.lang.Exception
Invokesexecute()while setting the given chain as the implicit receiver.
-
all
public GroovyChain all(Handler handler)
Adds the given handler to this.- Specified by:
allin interfaceChain- Specified by:
allin interfaceGroovyChain- Parameters:
handler- the handler to add- Returns:
- this
-
getServerConfig
public ServerConfig getServerConfig()
The server config of the application that this chain is being created for.- Specified by:
getServerConfigin interfaceChain- Returns:
- The server config of the application that this chain is being created for.
-
getRegistry
public Registry getRegistry() throws java.lang.IllegalStateException
The registry that backs this chain.What the registry is depends on how the chain was created. The
Handlers.chain(ServerConfig, Registry, Action)allows the registry to be specified. For a Guice based application, the registry is backed by Guice.- Specified by:
getRegistryin interfaceChain- Returns:
- The registry that backs this
- Throws:
java.lang.IllegalStateException- if there is no backing registry for this chain- See Also:
Handlers.chain(ServerConfig, Registry, Action)
-
-