Module jakarta.el
Package jakarta.el

Class ELContext

java.lang.Object
jakarta.el.ELContext
Direct Known Subclasses:
ELContextImpl, FaceletContext, NoOpELContext, StandardELContext

public abstract class ELContext extends Object
Context information for expression parsing and evaluation.

To parse or evaluate an Expression, an ELContext must be provided. The ELContext holds:

  • a reference to FunctionMapper that will be used to resolve Jakarta Expression Language Functions. This is used only in parsing.
  • a reference to VariableMapper that will be used to resolve Jakarta Expression Language Variables. This is used only in parsing.
  • a reference to the base ELResolver that will be consulted to resolve model objects and their properties
  • a collection of all the relevant context objects for use by ELResolvers
  • state information during the evaluation of an expression, such as whether a property has been resolved yet
  • a reference to ImportHandler that will be consulted to resolve classes that have been imported
  • a reference to the arguments for the active LambdaExpressions
  • a reference to the list of registered evaluation listeners

The collection of context objects is necessary because each ELResolver may need access to a different context object. For example, Jakarta Server Pages and Jakarta Faces resolvers need access to a jakarta.servlet.jsp.JspContext and a jakarta.faces.context.FacesContext, respectively.

When used in a web container, the creation of ELContext objects is controlled through the underlying technology. For example, in Jakarta Server Pages the JspContext.getELContext() factory method is used. Some technologies provide the ability to add an ELContextListener so that applications and frameworks can ensure their own context objects are attached to any newly created ELContext.

When used in a stand-alone environment, StandardELContext provides a default ELContext, which is managed and modified by ELManager.

Because it stores state during expression evaluation, an ELContext object is not thread-safe. Care should be taken to never share an ELContext instance between two or more threads.

Since:
Jakarta Expression Language 2.1 and Jakarta Expression Language 3.0
See Also: