public class Bindings extends Object
Constructor and Description |
---|
Bindings() |
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
asMap()
Returns an unmodifiable
Map view of this Bindings instance. |
Bindings |
bind(Bindings source)
Binds all the bindings already bound from
source . |
Bindings |
bind(String name,
Object value)
Binds a new
value to the given name . |
static Bindings |
bindings()
Returns an empty
Bindings instance (mutable). |
static Bindings |
bindings(Context context)
|
static Bindings |
bindings(Context context,
Request request)
|
static Bindings |
bindings(Context context,
Request request,
Response response)
|
static Bindings |
bindings(String name,
Object value)
|
static Map<String,Context> |
flatten(Context leaf)
Flatten the current
leaf Context into a Map keyed by context name. |
String |
toString() |
public static Bindings bindings()
Bindings
instance (mutable).Bindings
instance.public static Bindings bindings(Context context)
Bindings
initialized with the given context
and request
.
The returned bindings contain a contexts
entry that provides easy access to visible parent
Contexts (contexts.http, contexts.client, ...
).
They also give access to the context's attributes
from the
AttributesContext
and to the session
from the SessionContext
.
context
- The context to exposeBindings
instance.public static Bindings bindings(Context context, Request request)
context
- The context to exposerequest
- The request to exposeBindings
instance.public static Bindings bindings(Context context, Request request, Response response)
context
- The context to exposerequest
- The request to exposeresponse
- The response to exposeBindings
instance.public static Bindings bindings(String name, Object value)
name
- binding namevalue
- binding valueBindings
instance.public Bindings bind(String name, Object value)
value
to the given name
.name
- binding name (must not be null
)value
- binding valueBindings
public Bindings bind(Bindings source)
source
.source
- current bindings to copy (must not be null
)Bindings
public Map<String,Object> asMap()
Map
view of this Bindings
instance.
Note that while the consumer of the Map cannot modify it, any changes done through the Bindings methods will be reflected in the returned Map.
Map
view of this instance (never null
).public static Map<String,Context> flatten(Context leaf)
leaf
Context
into a Map keyed by context name.
The Context hierarchy is walked from the given leaf
to the root context, parent after parent.
If a context's name has already been added into the Map while walking up the chain, the context will be ignored (shadowed by the previously registered context). That behaviour ensure that we'll return only the contexts that are close to the leaf.
leaf
- Context used to start the walk-throughContext.getContextName()
Copyright 2011-2017 ForgeRock AS.