Stapler Web Framework
Request Handling
Jenkins classes are bound to URLs by using Stapler.
The singleton jenkinsdoc:Jenkins[]
instance is bound to the context root (most of the time "/") URL, and the rest of the objects are bound according to their reachability from this root object.
Stapler uses reflection to recursively determine how to process any given URL.
A few examples of how the URL /foo/bar
could be processed:
-
A
getFoo(String)
is defined on theJenkins
object, and Stapler passesbar
as a parameter. The object returned has a method calleddoIndex(…)
that gets called and renders the response. -
getFoo()
is defined and returns an object that has agetBar
ordoBar
method. The object returned from that has an associatedindex.jelly
orindex.groovy
view. -
getFoo()
is defined and the returned object has a view namedbar.jelly
orbar.groovy
defined. -
doFoo()
is defined.
A number of additional ways to handle requests exist, but these are the most common.