Package freemarker.core
Interface TemplateClassResolver
-
- All Known Implementing Classes:
OptInTemplateClassResolver
public interface TemplateClassResolverUsed by built-ins and other template language features that get a class based on a string. This can be handy both for implementing security restrictions and for working around local class-loader issues. The implementation should be thread-safe, unless an instance is always only used in a singleEnvironmentobject.- Since:
- 2.3.17
- See Also:
Configurable.setNewBuiltinClassResolver(TemplateClassResolver)
-
-
Field Summary
Fields Modifier and Type Field Description static TemplateClassResolverALLOWS_NOTHING_RESOLVERDoesn't allow resolving any classes.static TemplateClassResolverSAFER_RESOLVERSame asUNRESTRICTED_RESOLVER, except that it doesn't allow resolvingObjectConstructorandExecuteandfreemarker.template.utility.JythonRuntime.static TemplateClassResolverUNRESTRICTED_RESOLVERSimply callsClassUtil.forName(String).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Classresolve(java.lang.String className, Environment env, Template template)Gets aClassbased on the class name.
-
-
-
Field Detail
-
UNRESTRICTED_RESOLVER
static final TemplateClassResolver UNRESTRICTED_RESOLVER
Simply callsClassUtil.forName(String).
-
SAFER_RESOLVER
static final TemplateClassResolver SAFER_RESOLVER
Same asUNRESTRICTED_RESOLVER, except that it doesn't allow resolvingObjectConstructorandExecuteandfreemarker.template.utility.JythonRuntime.
-
ALLOWS_NOTHING_RESOLVER
static final TemplateClassResolver ALLOWS_NOTHING_RESOLVER
Doesn't allow resolving any classes.
-
-
Method Detail
-
resolve
java.lang.Class resolve(java.lang.String className, Environment env, Template template) throws TemplateExceptionGets aClassbased on the class name.- Parameters:
className- the full-qualified class nameenv- the environment in which the template executestemplate- the template where the operation that require the class resolution resides in. This isnullif the call doesn't come from a template.- Throws:
TemplateException- if the class can't be found or shouldn't be accessed from a template for security reasons.
-
-