tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime PageContextImpl.java ProtectedFunctionMapper.java ExpressionEvaluatorImpl.java
Date Tue, 04 Feb 2003 23:38:46 GMT
luehe       2003/02/04 15:38:46

  Modified:    jasper2/src/share/org/apache/jasper/compiler JspUtil.java
               jasper2/src/share/org/apache/jasper/runtime
                        PageContextImpl.java ProtectedFunctionMapper.java
  Removed:     jasper2/src/share/org/apache/jasper/runtime
                        ExpressionEvaluatorImpl.java
  Log:
  Integrated commons-el
  
  Revision  Changes    Path
  1.30      +6 -7      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java
  
  Index: JspUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- JspUtil.java	3 Feb 2003 20:11:41 -0000	1.29
  +++ JspUtil.java	4 Feb 2003 23:38:46 -0000	1.30
  @@ -79,11 +79,10 @@
   import org.xml.sax.Attributes;
   
   // EL interpreter (subject to change)
  -import javax.servlet.jsp.el.ExpressionEvaluator;
   import javax.servlet.jsp.el.FunctionMapper;
   import javax.servlet.jsp.el.ELException;
   import javax.servlet.jsp.el.ELParseException;
  -import org.apache.jasper.runtime.ExpressionEvaluatorImpl;
  +import org.apache.commons.el.ExpressionEvaluatorImpl;
   
   /** 
    * This class has all the utility method(s).
  @@ -108,8 +107,8 @@
       private static final String CLOSE_EXPR_XML = "%";
   
       private static int tempSequenceNumber = 0;
  -    private static ExpressionEvaluatorImpl expressionEvaluator = 
  -        new ExpressionEvaluatorImpl( null );
  +    private static ExpressionEvaluatorImpl expressionEvaluator
  +	= new ExpressionEvaluatorImpl();
   
       public static char[] removeQuotes(char []chars) {
   	CharArrayWriter caw = new CharArrayWriter();
  
  
  
  1.40      +32 -52    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java
  
  Index: PageContextImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/PageContextImpl.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- PageContextImpl.java	22 Jan 2003 20:08:25 -0000	1.39
  +++ PageContextImpl.java	4 Feb 2003 23:38:46 -0000	1.40
  @@ -95,7 +95,10 @@
   
   import org.apache.jasper.Constants;
   import org.apache.jasper.compiler.Localizer;
  -import org.apache.jasper.runtime.el.jstl.JSTLVariableResolver;
  +
  +import org.apache.commons.el.VariableResolverImpl;
  +import org.apache.commons.el.ExpressionEvaluatorImpl;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -117,22 +120,14 @@
       /**
        * The expression evaluator, for evaluating EL expressions.
        */
  -    private ExpressionEvaluatorImpl expressionEvaluator = null;
  +    private static ExpressionEvaluatorImpl expressionEvaluator
  +	= new ExpressionEvaluatorImpl();
   
       /**
        * The variable resolver, for evaluating EL expressions.
        */
  -    private static JSTLVariableResolver variableResolver =
  -        new JSTLVariableResolver();
  -
  -    /**
  -     * Expression evaluator for proprietary EL evaluation.
  -     * XXX - This should be going away once the EL evaluator moves from
  -     * the JSTL implementation to its own project.
  -     */
  -    private static org.apache.jasper.runtime.el.jstl.Evaluator
  -        proprietaryEvaluator = new
  -        org.apache.jasper.runtime.el.jstl.Evaluator();
  +    private VariableResolverImpl variableResolver
  +	= new VariableResolverImpl(this);
   
       PageContextImpl(JspFactory factory) {
           this.factory = factory;
  @@ -558,13 +553,7 @@
        * ExpressionEvaluator that can parse EL expressions.
        */
       public ExpressionEvaluator getExpressionEvaluator() {
  -        if( this.expressionEvaluator == null ) {
  -            this.expressionEvaluator = new ExpressionEvaluatorImpl( this );
  -            // no need to synchronize - not a big deal even if we create
  -            // two of these.
  -        }
  -
  -        return this.expressionEvaluator;
  +        return expressionEvaluator;
       }
   
       public void handlePageException(Exception ex)
  @@ -640,16 +629,8 @@
       /**
        * VariableResolver interface
        */
  -    public Object resolveVariable( String pName )
  -        throws ELException
  -    {
  -        try {
  -            return PageContextImpl.variableResolver.resolveVariable( pName, 
  -                this );
  -        }
  -        catch( org.apache.jasper.runtime.el.jstl.ELException e ) {
  -            throw new ELException( e );
  -        }
  +    public Object resolveVariable(String pName) throws ELException {
  +	return variableResolver.resolveVariable(pName);
       }
   
       private static String XmlEscape(String s) {
  @@ -687,15 +668,14 @@
        * @param defaultPrefix Default prefix for this evaluation
        * @return The result of the evaluation
        */
  -    public static Object proprietaryEvaluate( final String expression, 
  -         final Class expectedType,  final PageContext pageContext,
  -	 final ProtectedFunctionMapper functionMap, final String defaultPrefix,
  -	 final boolean escape )
  -       throws ELException
  +    public static Object proprietaryEvaluate(final String expression, 
  +					     final Class expectedType,
  +					     final PageContext pageContext,
  +					     final ProtectedFunctionMapper functionMap,
  +					     final String defaultPrefix,
  +					     final boolean escape)
  +	throws ELException
       {
  -	final java.util.HashMap funcMap =
  -		(functionMap == null)? null: functionMap.getFnMap();
  -                
   	Object retValue;
           if (System.getSecurityManager() != null){
               try {
  @@ -703,9 +683,11 @@
   			new PrivilegedExceptionAction(){
   
                       public Object run() throws Exception{
  -                       return PageContextImpl.proprietaryEvaluator.evaluate( "<unknown>",

  -                            expression, expectedType, null, pageContext,
  -                            funcMap, defaultPrefix );
  +                        return expressionEvaluator.evaluate(expression,
  +							    expectedType,
  +							    pageContext.getVariableResolver(),
  +							    functionMap,
  +							    defaultPrefix);
                       }
                   });
               } catch( PrivilegedActionException ex ) {
  @@ -713,18 +695,16 @@
                   throw new ELException( e );
               }
           } else {
  -            try{
  -               retValue = PageContextImpl.proprietaryEvaluator.evaluate(
  -		    "<unknown>", 
  -                    expression, expectedType, null, pageContext,
  -                    funcMap, defaultPrefix );
  -            } catch(JspException e){
  -                throw new ELException( e );                
  -            }  
  +	    retValue = expressionEvaluator.evaluate(expression,
  +						    expectedType,
  +						    pageContext.getVariableResolver(),
  +						    functionMap,
  +						    defaultPrefix);
           }
   	if (escape) {
   	    retValue = XmlEscape(retValue.toString());
   	}
  +
   	return retValue;
       }
   
  
  
  
  1.4       +15 -13    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/ProtectedFunctionMapper.java
  
  Index: ProtectedFunctionMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/ProtectedFunctionMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProtectedFunctionMapper.java	22 Jan 2003 21:13:51 -0000	1.3
  +++ ProtectedFunctionMapper.java	4 Feb 2003 23:38:46 -0000	1.4
  @@ -66,6 +66,8 @@
   import java.security.PrivilegedAction;
   import java.security.PrivilegedExceptionAction;
   import java.security.PrivilegedActionException;
  +import java.lang.reflect.Method;
  +import javax.servlet.jsp.el.FunctionMapper;
   
   /**
    * Maps EL functions to their Java method counterparts.  Keeps the
  @@ -75,7 +77,7 @@
    * @author Mark Roth
    * @author Kin-man Chung
    */
  -public final class ProtectedFunctionMapper {
  +public final class ProtectedFunctionMapper implements FunctionMapper {
   
       /** 
        * Maps "prefix:name" to java.lang.Method objects.  Lazily created.
  @@ -149,16 +151,16 @@
   	this.fnmap.put( prefix + ":" + fnName, method );
       }
   
  -
       /**
  -     * Only the org.apache.jasper.runtime package can access the actual
  -     * function map.
  -     *
  -     * @return A HashMap, with keys as "name:prefix" and values as
  -     *     the corresponding java.lang.Method instances.
  -     */
  -    HashMap getFnMap() {
  -	return this.fnmap;
  +     * Resolves the specified local name and prefix into a Java.lang.Method.
  +     * Returns null if the prefix and local name are not found.
  +     * 
  +     * @param prefix the prefix of the function
  +     * @param localName the short name of the function
  +     * @return the result of the method mapping.  Null means no entry found.
  +     **/
  +    public Method resolveFunction(String prefix, String localName) {
  +	return (Method) this.fnmap.get(prefix + ":" + localName);
       }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message