[seam-commits] Seam SVN: r10658 - modules/trunk/el/src/main/java/org/jboss/seam/el.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Apr 27 12:37:25 EDT 2009


Author: dan.j.allen
Date: 2009-04-27 12:37:24 -0400 (Mon, 27 Apr 2009)
New Revision: 10658

Removed:
   modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java
Modified:
   modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java
   modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java
Log:
don't need optional method expression any longer (default in JSF 2)


Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java	2009-04-27 16:37:06 UTC (rev 10657)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/EL.java	2009-04-27 16:37:24 UTC (rev 10658)
@@ -1,143 +1,147 @@
-package org.jboss.seam.el;
-
-import java.util.Locale;
-
-import javax.el.ArrayELResolver;
-import javax.el.BeanELResolver;
-import javax.el.CompositeELResolver;
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.ExpressionFactory;
-import javax.el.FunctionMapper;
-import javax.el.ListELResolver;
-import javax.el.MapELResolver;
-import javax.el.ResourceBundleELResolver;
-import javax.el.VariableMapper;
-
-import org.jboss.el.ExpressionFactoryImpl;
-import org.jboss.el.lang.FunctionMapperImpl;
-import org.jboss.el.lang.VariableMapperImpl;
-
-/**
- * An instance of JBoss EL.
- * 
- * @author Gavin King
- *
- */
-public class EL
-{
-   public static final ELResolver EL_RESOLVER = createELResolver();
-   //ELContext instances should not be shared between threads
-   //public static final ELContext EL_CONTEXT = createELContext( EL_RESOLVER, new FunctionMapperImpl() );
-   
-   public static final ExpressionFactory EXPRESSION_FACTORY = new ExpressionFactoryImpl();
-   
-   private static ELResolver createELResolver()
-   {
-      CompositeELResolver resolver = new CompositeELResolver();
-      resolver.add( new SeamELResolver() );
-      resolver.add( new MapELResolver() );
-      resolver.add( new ListELResolver() );
-      resolver.add( new ArrayELResolver() );
-      resolver.add( new ResourceBundleELResolver() );
-      resolver.add( new BeanELResolver() );
-      return resolver;
-   }
-
-   public static ELContext createELContext() {
-       return createELContext( EL_RESOLVER, new FunctionMapperImpl() );
-   }
-   
-   public static ELContext createELContext(final ELResolver resolver, final FunctionMapper functionMapper)
-   {
-      return new ELContext()
-      {
-         final VariableMapperImpl variableMapper = new VariableMapperImpl();
-
-         @Override
-         public ELResolver getELResolver()
-         {
-            return resolver;
-         }
-
-         @Override
-         public FunctionMapper getFunctionMapper()
-         {
-            return functionMapper;
-         }
-
-         @Override
-         public VariableMapper getVariableMapper()
-         {
-            return variableMapper;
-         }
-         
-      };
-   }
-   
-   public static ELContext createELContext(final ELContext context, final ELResolver resolver)
-   {
-      return new ELContext()
-      {
-
-         @Override
-         public Locale getLocale()
-         {
-            return context.getLocale();
-         }
-         
-         @Override
-         public void setPropertyResolved(boolean value)
-         {
-            super.setPropertyResolved(value);
-            context.setPropertyResolved(value);
-         }
-         
-         /*@Override
-         public boolean isPropertyResolved()
-         {
-            return super.isPropertyResolved();
-         }*/
-         
-         @Override
-         public void putContext(Class clazz, Object object)
-         {
-            super.putContext(clazz, object);
-            context.putContext(clazz, object);
-         }
-         
-         @Override
-         public Object getContext(Class clazz)
-         {
-            return context.getContext(clazz);
-         }
-         
-         @Override
-         public void setLocale(Locale locale)
-         {
-            super.setLocale(locale);
-            context.setLocale(locale);
-         }
-         
-         @Override
-         public ELResolver getELResolver()
-         {
-            return resolver;
-         }
-
-         @Override
-         public FunctionMapper getFunctionMapper()
-         {
-            return context.getFunctionMapper();
-         }
-
-         @Override
-         public VariableMapper getVariableMapper()
-         {
-            return context.getVariableMapper();
-         }
-         
-      };
-   }
-   
-}
+/* 
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.
+ *
+ * $Id$
+ */
+package org.jboss.seam.el;
+
+import java.util.Locale;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.el.ResourceBundleELResolver;
+import javax.el.VariableMapper;
+
+import org.jboss.el.ExpressionFactoryImpl;
+import org.jboss.el.lang.FunctionMapperImpl;
+import org.jboss.el.lang.VariableMapperImpl;
+
+/**
+ * An instance of JBoss EL.
+ * 
+ * @author Gavin King
+ */
+public class EL
+{
+   public static final ELResolver EL_RESOLVER = createELResolver();
+   public static final ExpressionFactory EXPRESSION_FACTORY = new ExpressionFactoryImpl();
+
+   private static ELResolver createELResolver()
+   {
+      CompositeELResolver resolver = new CompositeELResolver();
+      resolver.add(new MapELResolver());
+      resolver.add(new ListELResolver());
+      resolver.add(new ArrayELResolver());
+      resolver.add(new ResourceBundleELResolver());
+      resolver.add(new BeanELResolver());
+      return resolver;
+   }
+
+   public static ELContext createELContext()
+   {
+      return createELContext(EL_RESOLVER, new FunctionMapperImpl());
+   }
+
+   public static ELContext createELContext(final ELResolver resolver, final FunctionMapper functionMapper)
+   {
+      return new ELContext()
+      {
+         final VariableMapperImpl variableMapper = new VariableMapperImpl();
+
+         @Override
+         public ELResolver getELResolver()
+         {
+            return resolver;
+         }
+
+         @Override
+         public FunctionMapper getFunctionMapper()
+         {
+            return functionMapper;
+         }
+
+         @Override
+         public VariableMapper getVariableMapper()
+         {
+            return variableMapper;
+         }
+      };
+   }
+
+   public static ELContext createELContext(final ELContext context, final ELResolver resolver)
+   {
+      return new ELContext()
+      {
+         @Override
+         public Locale getLocale()
+         {
+            return context.getLocale();
+         }
+
+         @Override
+         public void setPropertyResolved(boolean value)
+         {
+            super.setPropertyResolved(value);
+            context.setPropertyResolved(value);
+         }
+
+         @Override
+         public void putContext(Class clazz, Object object)
+         {
+            super.putContext(clazz, object);
+            context.putContext(clazz, object);
+         }
+
+         @Override
+         public Object getContext(Class clazz)
+         {
+            return context.getContext(clazz);
+         }
+
+         @Override
+         public void setLocale(Locale locale)
+         {
+            super.setLocale(locale);
+            context.setLocale(locale);
+         }
+
+         @Override
+         public ELResolver getELResolver()
+         {
+            return resolver;
+         }
+
+         @Override
+         public FunctionMapper getFunctionMapper()
+         {
+            return context.getFunctionMapper();
+         }
+
+         @Override
+         public VariableMapper getVariableMapper()
+         {
+            return context.getVariableMapper();
+         }
+      };
+   }
+}

Deleted: modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java	2009-04-27 16:37:06 UTC (rev 10657)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/OptionalParameterMethodExpression.java	2009-04-27 16:37:24 UTC (rev 10658)
@@ -1,80 +0,0 @@
-/**
- * 
- */
-package org.jboss.seam.el;
-
-import javax.el.ELContext;
-import javax.el.MethodExpression;
-import javax.el.MethodInfo;
-import javax.el.MethodNotFoundException;
-
-/**
- * 
- * @author Gavin King
- *
- */
-class OptionalParameterMethodExpression extends MethodExpression
-{
-    
-    private MethodExpression withParam;
-    private MethodExpression withNoParam;
-    
-   public OptionalParameterMethodExpression(MethodExpression withParam, MethodExpression withNoParam)
-   {
-      this.withParam = withParam;
-      this.withNoParam = withNoParam;
-   }
-
-   @Override
-   public MethodInfo getMethodInfo(ELContext ctx)
-   {
-      return withParam.getMethodInfo(ctx);
-   }
-
-   @Override
-   public Object invoke(ELContext ctx, Object[] args)
-   {
-      try
-      {
-         return withParam.invoke(ctx, args);
-      }
-      catch (MethodNotFoundException mnfe)
-      {
-         try
-         {
-            return withNoParam.invoke(ctx, new Object[0]);
-         }
-         catch (MethodNotFoundException mnfe2)
-         {
-            throw mnfe;
-         }
-      }
-   }
-
-   @Override
-   public String getExpressionString()
-   {
-      return withParam.getExpressionString();
-   }
-
-   @Override
-   public boolean isLiteralText()
-   {
-      return withParam.isLiteralText();
-   }
-
-   @Override
-   public boolean equals(Object object)
-   {
-      if ( !(object instanceof OptionalParameterMethodExpression) ) return false;
-      OptionalParameterMethodExpression other = (OptionalParameterMethodExpression) object;
-      return withParam.equals(other.withParam);
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return withParam.hashCode();
-   }
-    
- }
\ No newline at end of file

Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java	2009-04-27 16:37:06 UTC (rev 10657)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/SeamExpressionFactory.java	2009-04-27 16:37:24 UTC (rev 10658)
@@ -1,101 +1,65 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.el;
-
-import javax.el.ELContext;
-import javax.el.ExpressionFactory;
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-
-import org.jboss.el.lang.EvaluationContext;
-import org.jboss.seam.util.JSF;
-
-/**
- * Allows JSF action listener methods to not declare the
- * totally useless ActionEvent parameter if they don't
- * want to. 
- *
- * @author Gavin King
- */
-public class SeamExpressionFactory extends ExpressionFactory 
-{
-   public static final ExpressionFactory INSTANCE = new SeamExpressionFactory(EL.EXPRESSION_FACTORY);
-   
-    private static final Class[] NO_CLASSES = {};
-    
-    private final ExpressionFactory expressionFactory;
-    
-    SeamExpressionFactory(ExpressionFactory expressionFactory) 
-    {
-       this.expressionFactory = expressionFactory;
-    }
-    
-    /**
-     * Wrap the base ELContext, adding Seam's FunctionMapper.
-     * 
-     * Thus, any expressions with s:hasRole, s:hasPermission 
-     * must be evaluated either via Facelets/JSP (since they
-     * are declared in the tld/taglib.xml or via the 
-     * Expressions component.
-     * 
-     * @param context the JSF ELContext
-     */
-    private static EvaluationContext decorateELContext(ELContext context)
-    {
-       return new EvaluationContext( context, new SeamFunctionMapper( context.getFunctionMapper() ), context.getVariableMapper() );
-    }
-    
-    @Override
-    public Object coerceToType(Object obj, Class targetType) 
-    {
-        return expressionFactory.coerceToType(obj, targetType);
-    }
-
-    @Override
-    public MethodExpression createMethodExpression(ELContext elContext, String expression, Class returnType, Class[] paramTypes) 
-    {
-        if ( paramTypes.length==1 && JSF.FACES_EVENT.isAssignableFrom( paramTypes[0] ) )
-        {
-         return new OptionalParameterMethodExpression(
-                 expressionFactory.createMethodExpression( decorateELContext(elContext), expression, returnType, paramTypes ),
-                 expressionFactory.createMethodExpression( decorateELContext(elContext), expression, returnType, NO_CLASSES )
-              );
-        }
-        else
-        {
-           return expressionFactory.createMethodExpression( decorateELContext(elContext), expression, returnType, paramTypes );
-        }
-    }
-    
-    @Override
-    public ValueExpression createValueExpression(Object instance, Class expectedType) 
-    {
-        return expressionFactory.createValueExpression(instance, expectedType);
-    }
-
-    @Override
-    public ValueExpression createValueExpression(ELContext elContext, String expression, Class expectedType) 
-    {   
-        return expressionFactory.createValueExpression( decorateELContext(elContext), expression, expectedType );
-    }
-    
-}
\ No newline at end of file
+/* 
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.
+ *
+ * $Id$
+ */
+package org.jboss.seam.el;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+/**
+ * Provides integration with the JBoss EL.
+ *
+ * @author Gavin King
+ */
+public class SeamExpressionFactory extends ExpressionFactory
+{
+   public static final ExpressionFactory INSTANCE = new SeamExpressionFactory(EL.EXPRESSION_FACTORY);
+
+   private final ExpressionFactory expressionFactory;
+
+   SeamExpressionFactory(ExpressionFactory expressionFactory)
+   {
+      this.expressionFactory = expressionFactory;
+   }
+
+   @Override
+   public Object coerceToType(Object obj, Class targetType)
+   {
+      return expressionFactory.coerceToType(obj, targetType);
+   }
+
+   @Override
+   public MethodExpression createMethodExpression(ELContext elContext, String expression, Class returnType, Class[] paramTypes)
+   {
+      return expressionFactory.createMethodExpression(elContext, expression, returnType, paramTypes);
+   }
+
+   @Override
+   public ValueExpression createValueExpression(Object instance, Class expectedType)
+   {
+      return expressionFactory.createValueExpression(instance, expectedType);
+   }
+
+   @Override
+   public ValueExpression createValueExpression(ELContext elContext, String expression, Class expectedType)
+   {
+      return expressionFactory.createValueExpression(elContext, expression, expectedType);
+   }
+}




More information about the seam-commits mailing list