You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2007/03/05 22:47:59 UTC

svn commit: r514902 - in /incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main: conf/META-INF/ java/org/apache/myfaces/trinidadinternal/el/

Author: awiner
Date: Mon Mar  5 14:47:58 2007
New Revision: 514902

URL: http://svn.apache.org/viewvc?view=rev&rev=514902
Log:
Switch from VariableResolver to ELResolver - a minor performance improvement and a bit better DT support for anyone that takes advantage of ELResolver

Added:
    incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java
Removed:
    incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadVariableResolver.java
Modified:
    incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml

Modified: incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml?view=diff&rev=514902&r1=514901&r2=514902
==============================================================================
--- incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml (original)
+++ incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml Mon Mar  5 14:47:58 2007
@@ -1,119 +1,119 @@
-<?xml version="1.0" ?>
-<!--
-    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.
-	   
--->
-<faces-config xmlns="http://java.sun.com/xml/ns/javaee" >
-
-  <application>
-    <view-handler>org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl</view-handler>
-    <state-manager>org.apache.myfaces.trinidadinternal.application.StateManagerImpl</state-manager>
-    <navigation-handler>org.apache.myfaces.trinidadinternal.application.NavigationHandlerImpl</navigation-handler>
-    <variable-resolver>org.apache.myfaces.trinidadinternal.el.TrinidadVariableResolver</variable-resolver>
-  </application>
-
-  <factory>
-    <render-kit-factory>org.apache.myfaces.trinidadinternal.renderkit.CoreRenderKitFactory</render-kit-factory>
-    <faces-context-factory>
-      org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl
-    </faces-context-factory>
-  </factory>
-
-  <lifecycle>
-    <phase-listener>org.apache.myfaces.trinidadinternal.context.TrinidadPhaseListener</phase-listener>
-  </lifecycle>
-
-  <converter>
-    <converter-for-class>java.lang.Short</converter-for-class>
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.ShortConverter</converter-class>
-  </converter>
-  
-  <converter>
-    <converter-for-class>java.lang.Byte</converter-for-class>
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.ByteConverter</converter-class>
-  </converter>  
-
-  <converter>
-    <converter-for-class>java.lang.Integer</converter-for-class>
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.IntegerConverter</converter-class>
-  </converter>
-  
-  <converter>
-    <converter-for-class>java.lang.Long</converter-for-class>
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.LongConverter</converter-class>
-  </converter>
-  
-  <converter>
-    <converter-for-class>java.lang.Float</converter-for-class>
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.FloatConverter</converter-class>
-  </converter>  
-  
-  <converter>
-    <converter-for-class>java.lang.Double</converter-for-class>
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.DoubleConverter</converter-class>
-  </converter>        
-
-  <converter>
-    <description>Color Converter</description>
-    <converter-for-class>java.awt.Color</converter-for-class>
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.ColorConverter</converter-class>
-  </converter>
-
-  <converter>
-    <display-name>Date Time Converter</display-name>
-    <converter-for-class>java.util.Date</converter-for-class>   
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.DateTimeConverter</converter-class>
-  </converter>
-  
-  <converter>
-    <display-name>Date Time Converter</display-name>
-    <converter-for-class>java.util.Calendar</converter-for-class>   
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.DateTimeConverter</converter-class>
-  </converter>
-  
-  <converter>
-    <display-name>Number Converter</display-name>
-    <converter-for-class>java.lang.Number</converter-for-class>   
-    <converter-class>org.apache.myfaces.trinidadinternal.convert.NumberConverter</converter-class>
-  </converter>
-  
-  <referenced-bean>
-    <description>implicit object provided by Trinidad</description>
-    <display-name>Request Context</display-name>
-    <referenced-bean-name>requestContext</referenced-bean-name>
-    <referenced-bean-class>org.apache.myfaces.trinidad.context.RequestContext</referenced-bean-class>
-  </referenced-bean>
-
-  <referenced-bean>
-    <description>Trinidad Page Flow Scope Map</description>
-    <display-name>Page Flow Scope</display-name>
-    <referenced-bean-name>pageFlowScope</referenced-bean-name>
-    <referenced-bean-class>java.util.Map</referenced-bean-class>
-  </referenced-bean>
-
-  <render-kit>
-    <render-kit-id>org.apache.myfaces.trinidad.core.desktop</render-kit-id>
-    <render-kit-class>org.apache.myfaces.trinidadinternal.renderkit.core.desktop.DesktopRenderKit</render-kit-class>
-  </render-kit>
-
-  <render-kit>
-    <render-kit-id>org.apache.myfaces.trinidad.core.pda</render-kit-id>
-    <render-kit-class>org.apache.myfaces.trinidadinternal.renderkit.core.pda.PdaRenderKit</render-kit-class>
-  </render-kit>
-
+<?xml version="1.0" ?>
+<!--
+    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.
+	   
+-->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee" >
+
+  <application>
+    <view-handler>org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl</view-handler>
+    <state-manager>org.apache.myfaces.trinidadinternal.application.StateManagerImpl</state-manager>
+    <navigation-handler>org.apache.myfaces.trinidadinternal.application.NavigationHandlerImpl</navigation-handler>
+    <el-resolver>org.apache.myfaces.trinidadinternal.el.TrinidadELResolver</el-resolver>
+  </application>
+
+  <factory>
+    <render-kit-factory>org.apache.myfaces.trinidadinternal.renderkit.CoreRenderKitFactory</render-kit-factory>
+    <faces-context-factory>
+      org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl
+    </faces-context-factory>
+  </factory>
+
+  <lifecycle>
+    <phase-listener>org.apache.myfaces.trinidadinternal.context.TrinidadPhaseListener</phase-listener>
+  </lifecycle>
+
+  <converter>
+    <converter-for-class>java.lang.Short</converter-for-class>
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.ShortConverter</converter-class>
+  </converter>
+  
+  <converter>
+    <converter-for-class>java.lang.Byte</converter-for-class>
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.ByteConverter</converter-class>
+  </converter>  
+
+  <converter>
+    <converter-for-class>java.lang.Integer</converter-for-class>
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.IntegerConverter</converter-class>
+  </converter>
+  
+  <converter>
+    <converter-for-class>java.lang.Long</converter-for-class>
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.LongConverter</converter-class>
+  </converter>
+  
+  <converter>
+    <converter-for-class>java.lang.Float</converter-for-class>
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.FloatConverter</converter-class>
+  </converter>  
+  
+  <converter>
+    <converter-for-class>java.lang.Double</converter-for-class>
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.DoubleConverter</converter-class>
+  </converter>        
+
+  <converter>
+    <description>Color Converter</description>
+    <converter-for-class>java.awt.Color</converter-for-class>
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.ColorConverter</converter-class>
+  </converter>
+
+  <converter>
+    <display-name>Date Time Converter</display-name>
+    <converter-for-class>java.util.Date</converter-for-class>   
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.DateTimeConverter</converter-class>
+  </converter>
+  
+  <converter>
+    <display-name>Date Time Converter</display-name>
+    <converter-for-class>java.util.Calendar</converter-for-class>   
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.DateTimeConverter</converter-class>
+  </converter>
+  
+  <converter>
+    <display-name>Number Converter</display-name>
+    <converter-for-class>java.lang.Number</converter-for-class>   
+    <converter-class>org.apache.myfaces.trinidadinternal.convert.NumberConverter</converter-class>
+  </converter>
+  
+  <referenced-bean>
+    <description>implicit object provided by Trinidad</description>
+    <display-name>Request Context</display-name>
+    <referenced-bean-name>requestContext</referenced-bean-name>
+    <referenced-bean-class>org.apache.myfaces.trinidad.context.RequestContext</referenced-bean-class>
+  </referenced-bean>
+
+  <referenced-bean>
+    <description>Trinidad Page Flow Scope Map</description>
+    <display-name>Page Flow Scope</display-name>
+    <referenced-bean-name>pageFlowScope</referenced-bean-name>
+    <referenced-bean-class>java.util.Map</referenced-bean-class>
+  </referenced-bean>
+
+  <render-kit>
+    <render-kit-id>org.apache.myfaces.trinidad.core.desktop</render-kit-id>
+    <render-kit-class>org.apache.myfaces.trinidadinternal.renderkit.core.desktop.DesktopRenderKit</render-kit-class>
+  </render-kit>
+
+  <render-kit>
+    <render-kit-id>org.apache.myfaces.trinidad.core.pda</render-kit-id>
+    <render-kit-class>org.apache.myfaces.trinidadinternal.renderkit.core.pda.PdaRenderKit</render-kit-class>
+  </render-kit>
+
 </faces-config>

Added: incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java?view=auto&rev=514902
==============================================================================
--- incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java (added)
+++ incubator/adffaces/branches/faces-1_2-070201/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/el/TrinidadELResolver.java Mon Mar  5 14:47:58 2007
@@ -0,0 +1,172 @@
+/*
+ *  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.myfaces.trinidadinternal.el;
+
+import java.beans.FeatureDescriptor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+import org.apache.myfaces.trinidad.context.RequestContext;
+
+/**
+ * ELResolver implementation for Trinidad.  Serves up:
+ * <ul>
+ *   <li>requestContext: the RequestContext instance</li>
+ *   <li>pageFlowScope: the page flow scope Map</li>
+ *   <li>processScope: a backwards compatibility alias for page flow scope</li>
+ * </ul>
+ */
+public class TrinidadELResolver
+  extends ELResolver
+{
+  /**
+   * EL variable name for page-flow scope
+   */
+  static public final String PAGE_FLOW_SCOPE_VARIABLE_NAME = "pageFlowScope";
+
+  public TrinidadELResolver()
+  {
+  }
+
+  public Object getValue(ELContext elContext, Object base, 
+                         Object property)
+  {
+    if (base == null)
+    {
+      if (RequestContext.VARIABLE_NAME.equals(property))
+      {
+        elContext.setPropertyResolved(true);
+        return RequestContext.getCurrentInstance();
+      }
+      // Support both "pageFlowScope" and "processScope"
+      // as EL variables to give developers a time to migrate
+      else if (PAGE_FLOW_SCOPE_VARIABLE_NAME.equals(property) ||
+             "processScope".equals(property))
+      {
+        elContext.setPropertyResolved(true);
+        return RequestContext.getCurrentInstance().getPageFlowScope();
+      }
+    }
+    
+    return null;
+  }
+
+  public Class<?> getType(ELContext elContext, Object base, 
+                          Object property)
+  {
+    if (base == null)
+    {
+      if (RequestContext.VARIABLE_NAME.equals(property))
+      {
+        elContext.setPropertyResolved(true);
+        return RequestContext.class;
+      }
+      // Support both "pageFlowScope" and "processScope"
+      // as EL variables to give developers a time to migrate
+      else if (PAGE_FLOW_SCOPE_VARIABLE_NAME.equals(property) ||
+             "processScope".equals(property))
+      {
+        elContext.setPropertyResolved(true);
+        return Map.class;
+      }
+    }
+    
+    return null;
+  }
+
+  public void setValue(ELContext elContext, Object base, Object property, 
+                       Object value)
+  {
+  }
+
+  public boolean isReadOnly(ELContext elContext, Object base, 
+                            Object property)
+  {
+    return false;
+  }
+
+  public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext elContext, 
+                                                           Object base)
+  {
+    if (base == null)
+    {
+      if (_featureDescriptorList == null)
+        _featureDescriptorList = _createFeatureDescriptorList();
+      return _featureDescriptorList.iterator();
+    }
+    
+    return null;
+  }
+
+  public Class<?> getCommonPropertyType(ELContext elContext, Object base)
+  {
+    if (base == null)
+      return String.class;
+    
+    return null;
+  }
+
+  /**
+   * Creates the list of FeatureDescriptors.
+   */
+  private List<FeatureDescriptor> _createFeatureDescriptorList()
+  {
+    ArrayList<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
+    // FeatureDescriptor for "requestContext"
+    FeatureDescriptor requestContext = new FeatureDescriptor();
+    requestContext.setName(RequestContext.VARIABLE_NAME);
+    // TODO translate this
+    requestContext.setShortDescription("Trinidad RequestContext");
+    requestContext.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, false);
+    requestContext.setValue(ELResolver.TYPE, RequestContext.class);
+    list.add(requestContext);
+    
+    // FeatureDescriptor for "pageFlowScope"
+    FeatureDescriptor pageFlowScope = new FeatureDescriptor();
+    pageFlowScope.setName(PAGE_FLOW_SCOPE_VARIABLE_NAME);
+    // TODO translate this
+    pageFlowScope.setShortDescription("Trinidad Page Flow Scope");
+    pageFlowScope.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, false);
+    pageFlowScope.setValue(ELResolver.TYPE, Map.class);
+    list.add(pageFlowScope);
+    
+    // FeatureDescriptor for "processScope"
+    FeatureDescriptor processScope = new FeatureDescriptor();
+    processScope.setName(PAGE_FLOW_SCOPE_VARIABLE_NAME);
+    // TODO translate this
+    pageFlowScope.setShortDescription(
+      "Backwards compatibility alias for Trinidad Page Flow Scope");
+    processScope.setExpert(true);
+    processScope.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, false);
+    processScope.setValue(ELResolver.TYPE, Map.class);
+    list.add(pageFlowScope);
+
+    return Collections.unmodifiableList(list);
+  }
+
+  private List<FeatureDescriptor> _featureDescriptorList;
+}