Bug 8066

Summary: EL implementation should be made generic (non-Servlet specific)
Product: Taglibs Reporter: Nathan Abramson <arista>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Nathan Abramson 2002-04-14 14:12:36 UTC
There has been some talk of extracting the EL implementation from JSTL
and putting it into "commons".  Whether that happens or not, it would
still be a good idea to prepare for it by separating the EL
implementation into a part that is generic, and a part that interfaces
it to the JSTL-specific environment.  The following areas would have
to be "genericized":

  * variable lookups, including implicit objects
  * the variable lookup context (currently PageContext)
  * throw something more generic than JspException 
  * API should require "expression string", not attribute name/value
  * ditto for error messages
  * remove other JSP-specific objects (Tag) from generic implementation
Comment 1 Nathan Abramson 2002-04-14 14:32:59 UTC
The EL has been separated into a generic part and a JSTL-specific
part.  The JSTL-specific part is still called Evaluator, but it
delegates to the generic implementation called ELEvaluator.  The
following other changes were made:

  * variable lookups have been abstracted into a VariableResolver
    interface, which is passed to the constructor of the ELEvaluator.
    The JSTLVariableResolver is the JSTL-specific implementation of
    the variable resolver, which looks up variables in PageContext,
    and also handles the implicit objects.  The VariableResolver has
    to be passed to all the expressions during evaluation, which is
    why so many classes had to be changed.

  * The context passed to ELEvaluator.evaluate() is just an Object,
    not a PageContext.  That context is eventually passed to the
    VariableResolver, which is responsible for casing the context to
    whatever class it expects.

  * The notion of implicit objects has been removed from the parser -
    the parser just parses variable references, and lets the
    VariableResolver take care of implicit objects.  This means that
    there will be a slight difference in error messages - instead of
    listing the implicit objects among the expected tokens, it will
    just say <IDENTIFIER>

  * The ELEvaluator has substituted all notions of "attribute value"
    with "expression string".  The attribute name is not passed to the
    ELEvaluator.

  * ELEvaluator now throws ELException, which is no longer a subclass
    of JspException.  The Evaluator, when it delegates to ELEvaluator,
    will catch the ELException and convert it to a JspException.  It
    will also wrap the error message with the attribute name and
    value.

If there comes a time to separate the generic and JSTL-specific parts
into different packages, the following classes should be moved into
the JSTL-specific package:

  JSTLVariableResolver
  Evaluator
  ImplicitObjects
  EnumeratedMap (this is generic, but it's only used by ImplicitObjects)

These are the only classes that still contain references to servlet or
JSP api's.  There are also couple of error messages in
Resources.properties/Constants.java that should be moved - in
particular:

  ATTRIBUTE_EVALUATION_EXCEPTION
  ATTRIBUTE_PARSE_EXCEPTION