ELManager (EL 5.0 API Documentation - Apache Tomcat 10.1.57)
Description: declaration: package: jakarta.el, class: ELManager

# Class ELManager

java.lang.Object
jakarta.el.ELManager

public class ELManager extends Object
Provides a simplified API for managing EL context, resolvers, functions, and variables. This class maintains a `StandardELContext` and provides convenience methods for adding resolvers, mapping functions, setting variables, and managing imports. It is used internally by `ELProcessor`.

Since:
  EL 3.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ELManager()`
  Constructs an ELManager with a lazily initialized `StandardELContext`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addBeanNameResolver(BeanNameResolver beanNameResolver)`
  Adds a `BeanNameELResolver` to the resolver chain that uses the given `BeanNameResolver` to resolve top-level identifiers to managed beans.
  `void`
  `addELResolver(ELResolver resolver)`
  Adds an `ELResolver` to the front of the resolver chain in the managed EL context.
  `void`
  `addEvaluationListener(EvaluationListener listener)`
  Registers an `EvaluationListener` with the managed EL context.
  `Object`
  `defineBean(String name, Object bean)`
  Defines or removes a bean accessible by name in EL expressions.
  `StandardELContext`
  `getELContext()`
  Returns the `StandardELContext` managed by this ELManager, creating it on first access if it does not already exist.
  `static ExpressionFactory`
  `getExpressionFactory()`
  Returns the `ExpressionFactory` used to create and evaluate EL expressions.
  `void`
  `importClass(String className)`
  Imports a class so it can be referenced by its simple name in EL expressions.
  `void`
  `importPackage(String packageName)`
  Imports all classes from a package so they can be referenced by their simple names in EL expressions.
  `void`
  `importStatic(String staticMemberName)`
  Imports a static field or method so it can be referenced by its simple name in EL expressions.
  `void`
  `mapFunction(String prefix, String function, Method method)`
  Maps a static method to an EL function name with the given prefix and local name.
  `ELContext`
  `setELContext(ELContext context)`
  Replaces the current EL context with a new `StandardELContext` initialized from the given context.
  `void`
  `setVariable(String variable, ValueExpression expression)`
  Registers a variable in the EL context's variable mapper.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ELManager

    public ELManager()
    Constructs an ELManager with a lazily initialized `StandardELContext`.

- ## Method Details

  - ### getExpressionFactory

    public static ExpressionFactory getExpressionFactory()
    Returns the `ExpressionFactory` used to create and evaluate EL expressions. The factory is obtained through the standard service discovery mechanism.
    Returns:
      the ExpressionFactory instance

  - ### getELContext

    public StandardELContext getELContext()
    Returns the `StandardELContext` managed by this ELManager, creating it on first access if it does not already exist.
    Returns:
      the StandardELContext instance

  - ### setELContext

    public ELContext setELContext(ELContext context)
    Replaces the current EL context with a new `StandardELContext` initialized from the given context. The new context copies the ELResolver chain, FunctionMapper, VariableMapper, and other settings from the provided context.
    Parameters:
      `context` - the ELContext from which to initialize the new context
    Returns:
      the previous StandardELContext, or `null` if none existed

  - ### addBeanNameResolver

    public void addBeanNameResolver(BeanNameResolver beanNameResolver)
    Adds a `BeanNameELResolver` to the resolver chain that uses the given `BeanNameResolver` to resolve top-level identifiers to managed beans.
    Parameters:
      `beanNameResolver` - the resolver for bean names

  - ### addELResolver

    public void addELResolver(ELResolver resolver)
    Adds an `ELResolver` to the front of the resolver chain in the managed EL context. Resolvers added first have higher priority during property resolution.
    Parameters:
      `resolver` - the ELResolver to add

  - ### mapFunction

    public void mapFunction(String prefix, String function, Method method)
    Maps a static method to an EL function name with the given prefix and local name. The function can then be invoked in EL expressions as `prefix:function(args)`.
    Parameters:
      `prefix` - the namespace prefix for the function
      `function` - the local function name
      `method` - the static `Method` to map

  - ### setVariable

    public void setVariable(String variable, ValueExpression expression)
    Registers a variable in the EL context's variable mapper. The variable can then be referenced by name in EL expressions. Passing a `null` expression removes the variable.
    Parameters:
      `variable` - the variable name
      `expression` - the ValueExpression associated with the variable, or `null` to remove

  - ### importStatic

    public void importStatic(String staticMemberName) throws ELException
    Imports a static field or method so it can be referenced by its simple name in EL expressions. The argument must be a fully qualified name in the form `className.staticMemberName`.
    Parameters:
      `staticMemberName` - the fully qualified name of the static member to import
    Throws:
      `ELException` - if the static member cannot be found or is ambiguous

  - ### importClass

    public void importClass(String className) throws ELException
    Imports a class so it can be referenced by its simple name in EL expressions. The argument must be a fully qualified class name.
    Parameters:
      `className` - the fully qualified class name to import
    Throws:
      `ELException` - if the class name is invalid or conflicts with an existing import

  - ### importPackage

    public void importPackage(String packageName)
    Imports all classes from a package so they can be referenced by their simple names in EL expressions.
    Parameters:
      `packageName` - the package name to import

  - ### defineBean

    public Object defineBean(String name, Object bean)
    Defines or removes a bean accessible by name in EL expressions. When a non-null bean is provided, it is stored under the given name. When `null` is provided, the bean with the given name is removed.
    Parameters:
      `name` - the bean name
      `bean` - the bean object to define, or `null` to remove the bean
    Returns:
      the previous bean associated with the name, or `null` if there was none

  - ### addEvaluationListener

    public void addEvaluationListener(EvaluationListener listener)
    Registers an `EvaluationListener` with the managed EL context. The listener will be notified before and after expression evaluation, and when properties are resolved.
    Parameters:
      `listener` - the EvaluationListener to register