myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r809934 - in /myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog: Blog.java Cast.java JSFUtil.java Null.java
Date Tue, 01 Sep 2009 09:37:03 GMT
Author: werpu
Date: Tue Sep  1 09:37:02 2009
New Revision: 809934

URL: http://svn.apache.org/viewvc?rev=809934&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-3
moving over the example introspection code to add
the dynamic helpers for the java layer




Removed:
    myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Cast.java
    myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Null.java
Modified:
    myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java
    myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java

Modified: myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java?rev=809934&r1=809933&r2=809934&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java
(original)
+++ myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/Blog.java
Tue Sep  1 09:37:02 2009
@@ -5,6 +5,7 @@
 import org.apache.myfaces.scripting.loaders.java.ScriptingClass;
 
 import static org.apache.myfaces.javaloader.blog.JSFUtil.*;
+import static org.apache.myfaces.scripting.core.util.ClassUtils.*;
 
 /**
  * @author werpu2

Modified: myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java?rev=809934&r1=809933&r2=809934&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java
(original)
+++ myfaces/extensions/scripting/trunk/examples/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/blog/JSFUtil.java
Tue Sep  1 09:37:02 2009
@@ -8,6 +8,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
 
+import static org.apache.myfaces.scripting.core.util.ClassUtils.*;
 
 /**
  * @author werpu2
@@ -43,83 +44,6 @@
     }
 
 
-    /**
-     * executes a method
-     *
-     * @param obj        the target object
-     * @param methodName the method name
-     * @param varargs    a list of objects casts or nulls defining the parameter classes
and its values
-     *                   if something occurs on introspection level an unmanaged exception
is throw, just like
-     *                   it would happen in a scripting class
-     */
-    public static void executeMethod(Object obj, String methodName, Object... varargs) {
-
-        Class[] classes = new Class[varargs.length];
-        for (int cnt = 0; cnt < varargs.length; cnt++) {
-
-            if (varargs[cnt] instanceof Cast) {
-                classes[cnt] = ((Cast) varargs[cnt]).getClazz();
-                varargs[cnt] = ((Cast) varargs[cnt]).getValue();
-            } else {
-                classes[cnt] = varargs[cnt].getClass();
-            }
-        }
-
-        try {
-            Method m = obj.getClass().getMethod(methodName, classes);
-            m.invoke(obj, varargs);
-        } catch (NoSuchMethodException e) {
-            throw new RuntimeException(e);
-        } catch (InvocationTargetException e) {
-            throw new RuntimeException(e);
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * executes a function on a target object
-     *
-     * @param obj        the target object
-     * @param methodName the method name
-     * @param varargs    a list of objects casts or nulls defining the parameter classes
and its values
-     *                   if something occurs on introspection level an unmanaged exception
is throw, just like
-     *                   it would happen in a scripting class
-     * @return the result object for the function(method) call
-     * @throws RuntimeException an unmanaged runtime exception in case of an introspection
error
-     */
-    public static Object executeFunction(Object obj, String methodName, Object... varargs)
{
-        Class[] classes = new Class[varargs.length];
-        for (int cnt = 0; cnt < varargs.length; cnt++) {
-
-            if (varargs[cnt] instanceof Cast) {
-                classes[cnt] = ((Cast) varargs[cnt]).getClazz();
-                varargs[cnt] = ((Cast) varargs[cnt]).getValue();
-            } else {
-                classes[cnt] = varargs[cnt].getClass();
-            }
-        }
-
-        try {
-            Method m = obj.getClass().getMethod(methodName, classes);
-            return m.invoke(obj, varargs);
-        } catch (NoSuchMethodException e) {
-            throw new RuntimeException(e);
-        } catch (InvocationTargetException e) {
-            throw new RuntimeException(e);
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException(e);
-        }
-
-    }
-
-
-    public static Cast cast(Class clazz, Object value) {
-        return new Cast(clazz, value);
-    }
-
-    public static Null nullCast(Class clazz) {
-        return new Null(clazz);
-    }
+   
 
 }



Mime
View raw message