Package com.sun.faces.util
Class ScopedRunner
- java.lang.Object
-
- com.sun.faces.util.ScopedRunner
-
public class ScopedRunner extends Object
This class helps in letting code run within its own scope. Such scope is defined by specific variables being available to EL within it. The request scope is used to store the variables.- Author:
- Arjan Tijms
-
-
Constructor Summary
Constructors Constructor Description ScopedRunner(FacesContext context)
ScopedRunner(FacesContext context, Map<String,Object> scopedVariables)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
invoke(Runnable callback)
Invokes the callback within the scope of the variables being given in the constructor.ScopedRunner
with(String key, Object value)
Adds the given variable to this instance.
-
-
-
Constructor Detail
-
ScopedRunner
public ScopedRunner(FacesContext context)
-
ScopedRunner
public ScopedRunner(FacesContext context, Map<String,Object> scopedVariables)
-
-
Method Detail
-
with
public ScopedRunner with(String key, Object value)
Adds the given variable to this instance. Can be used in a builder-pattern.- Parameters:
key
- the key name of the variablevalue
- the value of the variable- Returns:
- this ScopedRunner, so adding variables and finally calling invoke can be chained.
-
invoke
public void invoke(Runnable callback)
Invokes the callback within the scope of the variables being given in the constructor.- Parameters:
callback
- The callback.
-
-