You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2015/06/24 20:57:15 UTC

svn commit: r1687344 - in /myfaces/tobago/branches/tobago-3.0.x: tobago-core/src/main/java/org/apache/myfaces/tobago/el/ tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/ tobago-extension/tobago-security/src/main/java/org/apache/myfaces/tob...

Author: lofwyr
Date: Wed Jun 24 18:57:15 2015
New Revision: 1687344

URL: http://svn.apache.org/r1687344
Log:
clean up - remove MethodBinding where possible

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/el/ConstantMethodExpression.java
Removed:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/el/ConstantMethodBinding.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-extension/tobago-security/src/main/java/org/apache/myfaces/tobago/security/CheckAuthorisationMethodBinding.java
Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java

Added: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/el/ConstantMethodExpression.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/el/ConstantMethodExpression.java?rev=1687344&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/el/ConstantMethodExpression.java (added)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/el/ConstantMethodExpression.java Wed Jun 24 18:57:15 2015
@@ -0,0 +1,86 @@
+package org.apache.myfaces.tobago.el;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodInfo;
+import javax.el.MethodNotFoundException;
+import javax.el.PropertyNotFoundException;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+
+public class ConstantMethodExpression extends MethodExpression implements StateHolder {
+
+  private String outcome;
+
+  private boolean transientFlag;
+
+  public ConstantMethodExpression() {
+  }
+
+  public ConstantMethodExpression(String outcome) {
+    this.outcome = outcome;
+  }
+
+  @Override
+  public MethodInfo getMethodInfo(ELContext context)
+      throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException {
+    return null;
+  }
+
+  @Override
+  public Object invoke(ELContext context, Object[] params)
+      throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException {
+    return outcome;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    ConstantMethodExpression that = (ConstantMethodExpression) o;
+
+    return !(outcome != null ? !outcome.equals(that.outcome) : that.outcome != null);
+
+  }
+
+  @Override
+  public int hashCode() {
+    return outcome.hashCode();
+  }
+
+  @Override
+  public String getExpressionString() {
+    return outcome;
+  }
+
+  @Override
+  public boolean isLiteralText() {
+    return true;
+  }
+
+  @Override
+  public Object saveState(FacesContext context) {
+    return outcome;
+  }
+
+  @Override
+  public void restoreState(FacesContext context, Object state) {
+    this.outcome = (String) state;
+  }
+
+  @Override
+  public void setTransient(final boolean transientFlag) {
+    this.transientFlag = transientFlag;
+  }
+
+  @Override
+  public boolean isTransient() {
+    return transientFlag;
+  }
+}

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java?rev=1687344&r1=1687343&r2=1687344&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java Wed Jun 24 18:57:15 2015
@@ -24,7 +24,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.SupportsMarkup;
 import org.apache.myfaces.tobago.component.SupportsRenderedPartially;
 import org.apache.myfaces.tobago.context.Markup;
-import org.apache.myfaces.tobago.el.ConstantMethodBinding;
+import org.apache.myfaces.tobago.el.ConstantMethodExpression;
 import org.apache.myfaces.tobago.internal.util.Deprecation;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -183,7 +183,7 @@ public final class AttributeHandler exte
         } else if ("actionFromValue".equals(mode.getValue())) {
           if (!value.isLiteral()) {
             final String result = value.getValue(faceletContext);
-            parent.getAttributes().put(name.getValue(), new ConstantMethodBinding(result));
+            parent.getAttributes().put(name.getValue(), new ConstantMethodExpression(result));
           }
         } else if ("valueIfSet".equals(mode.getValue())) {
           String expressionString = value.getValue();