Skip to main content

VarResolvers and VarResolverSessions

The main class for performing variable resolution is VarResolver.

Two methods are provided for resolving variables:

VarResolverresolve(String)resolveTo(String,Writer)

Var resolvers can rely on the existence of other objects. For example, ConfigVar relies on the existence of a Config. This is accomplished through the following method:

VarResolver.Builderbean(Class<T>, T) - Specify a bean for all sessions.VarResolverSessionbean(Class<T>, T) - Specify a bean for this session.

Beans are accessible through the following method:

VarResolverSession.getBean(Class)

Var resolvers can be cloned and extended by using the VarResolver.copy() method. Cloning a resolver will copy it's Var class names and context objects.

Example
// Create a resolver that copies the default resolver and adds $C and $A vars.
VarResolver myVarResolver = VarResolver
.DEFAULT
.copy()
.vars(ConfigVar.class, ArgsVar.class)
.build();