You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/12/16 23:07:07 UTC

svn commit: r1215316 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert: PropertyResolverToELResolver.java VariableResolverToELResolver.java

Author: lu4242
Date: Fri Dec 16 22:07:07 2011
New Revision: 1215316

URL: http://svn.apache.org/viewvc?rev=1215316&view=rev
Log:
MYFACES-3426 [perf] do not call default VariableResolver / PropertyResolver when no custom instance is set

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java?rev=1215316&r1=1215315&r2=1215316&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/PropertyResolverToELResolver.java Fri Dec 16 22:07:07 2011
@@ -32,6 +32,7 @@ import javax.faces.el.PropertyResolver;
 import java.beans.FeatureDescriptor;
 import java.util.Iterator;
 import java.util.List;
+import org.apache.myfaces.el.DefaultPropertyResolver;
 
 /**
  * Wrapper that converts a VariableResolver into an ELResolver. See JSF 1.2 spec section 5.6.1.6
@@ -46,6 +47,8 @@ public final class PropertyResolverToELR
     private PropertyResolver propertyResolver;
 
     private ExpressionFactory expressionFactory;
+    
+    private boolean isDefaultLegacyPropertyResolver;
 
     /**
      * Creates a new instance of PropertyResolverToELResolver
@@ -53,12 +56,17 @@ public final class PropertyResolverToELR
     public PropertyResolverToELResolver(final PropertyResolver propertyResolver)
     {
         this.propertyResolver = propertyResolver;
+        this.isDefaultLegacyPropertyResolver = (propertyResolver instanceof DefaultPropertyResolver);
     }
 
     @Override
     public void setValue(final ELContext context, final Object base, final Object property, final Object value)
         throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException
     {
+        if (isDefaultLegacyPropertyResolver)
+        {
+            return;
+        }
         if (base == null || property == null)
         {
             return;
@@ -101,6 +109,10 @@ public final class PropertyResolverToELR
     public boolean isReadOnly(final ELContext context, final Object base, final Object property)
             throws NullPointerException, PropertyNotFoundException, ELException
     {
+        if (isDefaultLegacyPropertyResolver)
+        {
+            return false;
+        }
         if (base == null || property == null)
         {
             return true;
@@ -145,6 +157,10 @@ public final class PropertyResolverToELR
     public Object getValue(final ELContext context, final Object base, final Object property)
             throws NullPointerException, PropertyNotFoundException, ELException
     {
+        if (isDefaultLegacyPropertyResolver)
+        {
+            return null;
+        }        
         if (base == null || property == null)
         {
             return null;
@@ -190,6 +206,10 @@ public final class PropertyResolverToELR
     public Class<?> getType(final ELContext context, final Object base, final Object property)
             throws NullPointerException, PropertyNotFoundException, ELException
     {
+        if (isDefaultLegacyPropertyResolver)
+        {
+            return null;
+        }
         if (base == null || property == null)
         {
             return null;
@@ -240,7 +260,10 @@ public final class PropertyResolverToELR
     @Override
     public Class<?> getCommonPropertyType(ELContext context, Object base)
     {
-
+        if (isDefaultLegacyPropertyResolver)
+        {
+            return null;
+        }
         if (base == null)
         {
             return null;

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java?rev=1215316&r1=1215315&r2=1215316&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/el/convert/VariableResolverToELResolver.java Fri Dec 16 22:07:07 2011
@@ -30,6 +30,7 @@ import java.beans.FeatureDescriptor;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
+import org.apache.myfaces.el.VariableResolverImpl;
 
 /**
  * Wrapper that converts a VariableResolver into an ELResolver. See JSF 1.2 spec section 5.6.1.5
@@ -71,6 +72,7 @@ public final class VariableResolverToELR
     }
     
     private VariableResolver variableResolver;
+    private boolean isDefaultLegacyVariableResolver;
 
     /**
      * Creates a new instance of VariableResolverToELResolver
@@ -78,6 +80,7 @@ public final class VariableResolverToELR
     public VariableResolverToELResolver(final VariableResolver variableResolver)
     {
         this.variableResolver = variableResolver;
+        this.isDefaultLegacyVariableResolver = (this.variableResolver instanceof VariableResolverImpl);
     }
     
     /**
@@ -92,7 +95,13 @@ public final class VariableResolverToELR
     public Object getValue(ELContext context, Object base, Object property) throws NullPointerException,
             PropertyNotFoundException, ELException
     {
-
+        if (isDefaultLegacyVariableResolver)
+        {
+            // Skip this one because it causes previous EL Resolvers already processed
+            // before this one to be called again. This behavior is only valid if it 
+            // is installed a custom VariableResolver.
+            return null;
+        }
         if (base != null)
         {
             return null;
@@ -165,6 +174,10 @@ public final class VariableResolverToELR
     @Override
     public Class<?> getCommonPropertyType(ELContext context, Object base)
     {
+        if (isDefaultLegacyVariableResolver)
+        {
+            return null;
+        }
         if (base != null)
         {
             return null;
@@ -177,7 +190,10 @@ public final class VariableResolverToELR
     public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException,
             PropertyNotFoundException, PropertyNotWritableException, ELException
     {
-
+        if (isDefaultLegacyVariableResolver)
+        {
+            return;
+        }
         if ((base == null) && (property == null))
         {
             throw new PropertyNotFoundException();
@@ -188,7 +204,10 @@ public final class VariableResolverToELR
     public boolean isReadOnly(ELContext context, Object base, Object property) throws NullPointerException,
             PropertyNotFoundException, ELException
     {
-
+        if (isDefaultLegacyVariableResolver)
+        {
+            return false;
+        }
         if ((base == null) && (property == null))
         {
             throw new PropertyNotFoundException();
@@ -201,7 +220,10 @@ public final class VariableResolverToELR
     public Class<?> getType(ELContext context, Object base, Object property) throws NullPointerException,
             PropertyNotFoundException, ELException
     {
-
+        if (isDefaultLegacyVariableResolver)
+        {
+            return null;
+        }
         if ((base == null) && (property == null))
         {
             throw new PropertyNotFoundException();
@@ -213,6 +235,10 @@ public final class VariableResolverToELR
     @Override
     public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base)
     {
+        if (isDefaultLegacyVariableResolver)
+        {
+            return null;
+        }
         return null;
     }