tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r1402855 - in /tomcat/trunk/java/org/apache/jasper: el/JasperELResolver.java runtime/JspApplicationContextImpl.java
Date Tue, 13 Nov 2012 09:38:52 GMT
2012/10/27  <markt@apache.org>:
> Author: markt
> Date: Sat Oct 27 19:44:52 2012
> New Revision: 1402855
>
> URL: http://svn.apache.org/viewvc?rev=1402855&view=rev
> Log:
> Use an optimised CompositeELResolver for Jasper that skips resolvers that are known to
be unable to resolve the value.
> Patch by Jarek Gawor.
>
> Added:
>     tomcat/trunk/java/org/apache/jasper/el/JasperELResolver.java   (with props)
> Modified:
>     tomcat/trunk/java/org/apache/jasper/runtime/JspApplicationContextImpl.java
>
> Added: tomcat/trunk/java/org/apache/jasper/el/JasperELResolver.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/el/JasperELResolver.java?rev=1402855&view=auto
> ==============================================================================
> --- tomcat/trunk/java/org/apache/jasper/el/JasperELResolver.java (added)
> +++ tomcat/trunk/java/org/apache/jasper/el/JasperELResolver.java Sat Oct 27 19:44:52
2012
> @@ -0,0 +1,159 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +package org.apache.jasper.el;
> +
> +import java.util.List;
> +
> +import javax.el.ArrayELResolver;
> +import javax.el.BeanELResolver;
> +import javax.el.CompositeELResolver;
> +import javax.el.ELContext;
> +import javax.el.ELException;
> +import javax.el.ELResolver;
> +import javax.el.ListELResolver;
> +import javax.el.MapELResolver;
> +import javax.el.PropertyNotFoundException;
> +import javax.el.ResourceBundleELResolver;
> +import javax.servlet.jsp.el.ImplicitObjectELResolver;
> +import javax.servlet.jsp.el.ScopedAttributeELResolver;
> +
> +/**
> + * Jasper-specific CompositeELResolver that optimizes certain functions to avoid
> + * unnecessary resolver calls.
> + */
> +public class JasperELResolver extends CompositeELResolver {
> +
> +    private int size;
> +    private ELResolver[] resolvers;
> +    private int appResolversSize;
> +
> +    public JasperELResolver(List<ELResolver> appResolvers) {
> +        appResolversSize = appResolvers.size();

This could be a bit optimized to avoid re-sizing the array when add()
is called from this constructor. The necessary size of resolvers array
is known (1 + appResolversSize + 6) and the current count of elements
is tracked by the "size" field.

So,

> +        resolvers = new ELResolver[0];
> +        size = resolvers.length;

resolvers = new ELResolver[appResolversSize + (1 + 6)];
size = 0;

> +
> +        add(new ImplicitObjectELResolver());
> +        for (ELResolver appResolver : appResolvers) {
> +            add(appResolver);
> +        }
> +        add(new MapELResolver());
> +        add(new ResourceBundleELResolver());
> +        add(new ListELResolver());
> +        add(new ArrayELResolver());
> +        add(new BeanELResolver());
> +        add(new ScopedAttributeELResolver());
> +    }
> +
> +    @Override
> +    public synchronized void add(ELResolver elResolver) {
> +        super.add(elResolver);

if (resolvers.length < size) {
  resolvers[size] = elResolver;
} else {

> +        ELResolver[] nr = new ELResolver[size + 1];
> +        System.arraycopy(resolvers, 0, nr, 0, size);
> +        nr[size] = elResolver;
> +
> +        resolvers = nr;

}

> +        size ++;
> +    }
> +

Best regards,
Konstantin Kolinko

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


Mime
View raw message