You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ms...@apache.org on 2009/11/30 20:51:31 UTC

svn commit: r885567 [2/2] - in /myfaces/trinidad/branches/1.2.12.1-sanity-jsf2: ./ trinidad-api/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/ trinidad-api/src/test/java/...

Modified: myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java?rev=885567&r1=885566&r2=885567&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java (original)
+++ myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java Mon Nov 30 19:51:30 2009
@@ -1,187 +0,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.
- */
-package org.apache.myfaces.trinidadinternal.facelets;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import javax.el.MethodExpression;
-import javax.faces.el.MethodBinding;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.el.LegacyMethodBinding;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-
-/**
- * 
- * =-=AEW REWRITE USING BEANINFO
- */
-final class TrinidadListenersTagRule extends MetaRule
-{
-  public static final MetaRule Instance = new TrinidadListenersTagRule();
-
-  private static class ListenerMBPropertyMetadata extends Metadata
-  {
-    public ListenerMBPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
-    {
-      _method = method;
-      _attribute = attribute;
-      _paramList = paramList;
-    }
-    
-    @Override
-    @SuppressWarnings("deprecation")
-    public void applyMetadata(FaceletContext ctx, Object instance)
-    {
-      MethodExpression expr =
-        _attribute.getMethodExpression(ctx, null, _paramList);
-      
-      try
-      {
-        _method.invoke(instance,
-                       new Object[]{new LegacyMethodBinding(expr)});
-      }
-      catch (InvocationTargetException e)
-      {
-        throw new TagAttributeException(_attribute, e.getCause());
-      }
-      catch (Exception e)
-      {
-        throw new TagAttributeException(_attribute, e);
-      }
-    }
-
-    private final Method       _method;
-    private final TagAttribute _attribute;
-    private       Class[]      _paramList;
-  }
-
-  private static class ListenerMEPropertyMetadata extends Metadata
-  {
-    public ListenerMEPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
-    {
-      _method = method;
-      _attribute = attribute;
-      _paramList = paramList;
-    }
-    
-    @Override
-    @SuppressWarnings("deprecation")
-    public void applyMetadata(FaceletContext ctx, Object instance)
-    {
-      MethodExpression expr =
-        _attribute.getMethodExpression(ctx, null, _paramList);
-      
-      try
-      {
-        _method.invoke(instance,
-                       new Object[]{expr});
-      }
-      catch (InvocationTargetException e)
-      {
-        throw new TagAttributeException(_attribute, e.getCause());
-      }
-      catch (Exception e)
-      {
-        throw new TagAttributeException(_attribute, e);
-      }
-    }
-
-    private final Method       _method;
-    private final TagAttribute _attribute;
-    private       Class[]      _paramList;
-  }
-   
-
-  @Override
-  public Metadata applyRule(
-     String name,
-     TagAttribute attribute,
-     MetadataTarget meta)
-  {
-    Class metaType = meta.getPropertyType(name);
-    boolean isMethodBinding = (metaType == MethodBinding.class);
-    boolean isMethodExpression = (metaType == MethodExpression.class);
-
-    if ((isMethodBinding || isMethodExpression) &&
-        name.endsWith("Listener"))
-    {
-      // OK, we're trying to call setFooListener()
-      Method m = meta.getWriteMethod(name);
-      if (m != null)
-      {
-        // First, look for the getFooListeners() property
-        PropertyDescriptor listeners = meta.getProperty(name + "s");
-        if (listeners == null)
-          return null;
-
-        // It should return an array of FooListener objects
-        Class<?> arrayType = listeners.getPropertyType();
-        if (!arrayType.isArray())
-          return null;
-        
-        // Ignore non-Trinidad types
-        Class<?> listenerClass = arrayType.getComponentType();
-        if (!listenerClass.getName().startsWith("org.apache.myfaces.trinidad."))
-          return null;
-
-        // Turn that into an Event to get the signature
-        Class<?> eventClass = _getEventClass(listenerClass);
-        if (eventClass == null)
-          return null;
-
-        // And go
-        if (isMethodBinding)
-          return new ListenerMBPropertyMetadata(m, attribute,
-                                                new Class[]{eventClass});
-        else
-          return new ListenerMEPropertyMetadata(m, attribute,
-                                                new Class[]{eventClass});
-      }
-    }
-    return null;
-  }
-
-  static private Class<?> _getEventClass(Class<?> listenerClass)
-  {
-    String listenerName = listenerClass.getName();
-    if (!listenerName.endsWith("Listener"))
-      return null;
-    
-    String eventName = (listenerName.substring(0,
-                          listenerName.length() - "Listener".length()) +
-                        "Event");
-
-    ClassLoader loader = Thread.currentThread().getContextClassLoader();
-    
-    try
-    {
-      return Class.forName(eventName, true, loader);
-    }
-    catch (ClassNotFoundException cnfe)
-    {
-      return null;
-    }
-  }
-}

Modified: myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadValidatorHandler.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadValidatorHandler.java?rev=885567&r1=885566&r2=885567&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadValidatorHandler.java (original)
+++ myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadValidatorHandler.java Mon Nov 30 19:51:30 2009
@@ -1,42 +0,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.
- */
-package org.apache.myfaces.trinidadinternal.facelets;
-
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.jsf.ValidateHandler;
-import com.sun.facelets.tag.jsf.ValidatorConfig;
-
-public class TrinidadValidatorHandler
-  extends ValidateHandler
-{
-  public TrinidadValidatorHandler(ValidatorConfig config)
-  {
-    super(config);
-  }
-  
-  @Override
-  protected MetaRuleset createMetaRuleset(Class type)
-  {
-    MetaRuleset m = super.createMetaRuleset(type);
-    m.addRule(StringArrayPropertyTagRule.Instance);
-    m.addRule(ValueExpressionTagRule.Instance);
-    m.addRule(DatePropertyTagRule.Instance);
-    return m;
-  }
-}

Modified: myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ValueExpressionTagRule.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ValueExpressionTagRule.java?rev=885567&r1=885566&r2=885567&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ValueExpressionTagRule.java (original)
+++ myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/ValueExpressionTagRule.java Mon Nov 30 19:51:30 2009
@@ -1,99 +0,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.
- */
-package org.apache.myfaces.trinidadinternal.facelets;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import javax.el.ValueExpression;
-
-
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-
-class ValueExpressionTagRule extends MetaRule
-{
-  
-  static ValueExpressionTagRule Instance = new ValueExpressionTagRule();
-  
-  public Metadata applyRule(String name, TagAttribute attribute,
-                            MetadataTarget meta)
-  {
-    // This rule should be used only for objects implementing setValueExpression().
-    
-    if (!attribute.isLiteral()) 
-    {
-      Class type = meta.getPropertyType(name);
-      if (type == null) {
-          type = Object.class;
-      }
-      return new ValueExpressionMetadata(name, type, attribute);
-    }
-    
-    return null;
-  }
-  
-  private final static class ValueExpressionMetadata extends Metadata
-  {
-    private final String _name;
-    private final TagAttribute _attr;
-    private final Class _type;
-    
-    public ValueExpressionMetadata(String name, Class type, TagAttribute attr) 
-    {
-      _name = name;
-      _attr = attr;
-      _type = type;
-    }
-    
-    public void applyMetadata(FaceletContext ctx, Object instance) 
-    {
-      Class klass = instance.getClass();
-      try
-      {
-        Method setter = klass.getMethod("setValueExpression", _SETTER_ARGS);
-        setter.invoke(instance, new Object[]{_name, _attr.getValueExpression(ctx, _type)});
-      }
-      // No user-readable messages are needed since we should never install this rule
-      // for objects not supportingg setvalueExpression() 
-      catch (NoSuchMethodException ncm)
-      {
-        _LOG.severe(ncm);
-      }
-      catch(IllegalAccessException iae)
-      {
-        _LOG.severe(iae);
-      }
-      catch(InvocationTargetException ite)
-      {
-        _LOG.severe(ite);
-      }
-    }
-    
-    private static final Class _SETTER_ARGS[] = {String.class, ValueExpression.class};
-  }
-  
-  private static final TrinidadLogger _LOG = 
-        TrinidadLogger.createTrinidadLogger(ValueExpressionTagRule.class);
-}

Modified: myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/PartialTriggersTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/PartialTriggersTest.java?rev=885567&r1=885566&r2=885567&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/PartialTriggersTest.java (original)
+++ myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/context/PartialTriggersTest.java Mon Nov 30 19:51:30 2009
@@ -26,7 +26,6 @@
 import javax.faces.component.UIViewRoot;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.apache.myfaces.trinidad.component.UIXCommand;
@@ -34,8 +33,9 @@
 import org.apache.myfaces.trinidad.component.UIXPanel;
 import org.apache.myfaces.trinidad.component.UIXTable;
 import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidadbuild.test.FacesTestCase;
 
-public class PartialTriggersTest extends TestCase
+public class PartialTriggersTest extends FacesTestCase
 {
   public static final Test suite()
   {

Modified: myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MApplication.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MApplication.java?rev=885567&r1=885566&r2=885567&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MApplication.java (original)
+++ myfaces/trinidad/branches/1.2.12.1-sanity-jsf2/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MApplication.java Mon Nov 30 19:51:30 2009
@@ -46,6 +46,7 @@
 import javax.faces.el.ValueBinding;
 import javax.faces.el.VariableResolver;
 import javax.faces.event.ActionListener;
+import javax.faces.event.SystemEvent;
 import javax.faces.validator.Validator;
 
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
@@ -61,6 +62,23 @@
   private MApplication()
   {
   }
+  
+  @Override
+  public void publishEvent(FacesContext context,
+                           Class<? extends SystemEvent> systemEventClass,
+                           Class<?> sourceBaseType,
+                           Object source)
+  {
+    // do nothing
+  }
+  
+  @Override
+  public void publishEvent(FacesContext context,
+                           Class<? extends SystemEvent> systemEventClass,
+                           Object source)
+  {
+    //do nothing
+  }
 
   @Override
   public ActionListener getActionListener()
@@ -306,7 +324,7 @@
   }
 
   @Override
-  public Iterator<Class> getConverterTypes()
+  public Iterator<Class<?>> getConverterTypes()
   {
     throw new UnsupportedOperationException("Should not be called during rendering");
   }