You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2007/05/21 17:20:04 UTC

svn commit: r540168 - /felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java

Author: rickhall
Date: Mon May 21 08:20:03 2007
New Revision: 540168

URL: http://svn.apache.org/viewvc?view=rev&rev=540168
Log:
Applied patch (FELIX-292) to modify the iPOJO Callback class to return the
returned object.

Modified:
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java?view=diff&rev=540168&r1=540167&r2=540168
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java Mon May 21 08:20:03 2007
@@ -203,27 +203,30 @@
     /**
      * Call the method.
      * 
+     * @return the result of the invocation, null for void method, the last result for multi-object instance
      * @throws NoSuchMethodException : Method is not found in the class
      * @throws InvocationTargetException : The method is not static
      * @throws IllegalAccessException : The method can not be invoked
      */
-    public void call() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+    public Object call() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
         if (m_methodObj == null) {
             searchMethod();
         }
 
         if (m_isStatic) {
-            m_methodObj.invoke(null, new Object[] {});
+            return m_methodObj.invoke(null, new Object[] {});
         } else {
             // Two cases :
             // - if instances already exists : call on each instances
             // - if no instance exists : create an instance
             if (m_manager.getPojoObjects().length == 0) {
-                m_methodObj.invoke(m_manager.getPojoObject(), new Object[] {});
+                return m_methodObj.invoke(m_manager.getPojoObject(), new Object[] {});
             } else {
+                Object r = null;
                 for (int i = 0; i < m_manager.getPojoObjects().length; i++) {
-                    m_methodObj.invoke(m_manager.getPojoObjects()[i], new Object[] {});
+                    r = m_methodObj.invoke(m_manager.getPojoObjects()[i], new Object[] {});
                 }
+                return r;
             }
         }
     }
@@ -231,44 +234,48 @@
     /**
      * Call the current callback method on the instance given in parameter.
      * 
-     * @param instance : instance on which call the callbakc
+     * @param instance : instance on which call the callback
+     * @return the result of the invocation, null for void method
      * @throws NoSuchMethodException : the method was not found
      * @throws IllegalAccessException : the method cannont be called
      * @throws InvocationTargetException : an error happens in the method
      */
-    public void call(Object instance) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+    public Object call(Object instance) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
         if (m_methodObj == null) {
             searchMethod();
         }
-        m_methodObj.invoke(instance, new Object[] {});
+        return m_methodObj.invoke(instance, new Object[] {});
     }
 
     /**
      * Call the callback on the method with the argument given in parameter.
      * 
      * @param arg : the parameters
+     * @return the result of the invocation, null for void method, the last result for multi-object instance
      * @throws NoSuchMethodException : the callback method is not found
      * @throws IllegalAccessException : the callbback method cannot be called
      * @throws InvocationTargetException : an error occurs inside the called
      * method
      */
-    public void call(Object[] arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+    public Object call(Object[] arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
         if (m_methodObj == null) {
             searchMethod();
         }
         
         if (m_isStatic) {
-            m_methodObj.invoke(null, arg);
+            return m_methodObj.invoke(null, arg);
         } else {
             // Two cases :
             // - if instances already exists : call on each instances
             // - if no instance exists : create an instance
             if (m_manager.getPojoObjects().length == 0) {
-                m_methodObj.invoke(m_manager.getPojoObject(), arg);
+                return m_methodObj.invoke(m_manager.getPojoObject(), arg);
             } else {
+                Object r = null;
                 for (int i = 0; i < m_manager.getPojoObjects().length; i++) {
-                    m_methodObj.invoke(m_manager.getPojoObjects()[i], arg);
+                    r = m_methodObj.invoke(m_manager.getPojoObjects()[i], arg);
                 }
+                return r;
             }
         }
     }
@@ -279,16 +286,17 @@
      * 
      * @param instance : instance on which call the callback
      * @param arg : the argument array
+     * @return the result of the invocation, null for void method
      * @throws NoSuchMethodException : the callback method is not found
      * @throws IllegalAccessException : the callbback method cannot be called
      * @throws InvocationTargetException : an error occurs inside the called
      * method
      */
-    public void call(Object instance, Object[] arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+    public Object call(Object instance, Object[] arg) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
         if (m_methodObj == null) {
             searchMethod();
         }
         
-        m_methodObj.invoke(instance, arg);
+        return m_methodObj.invoke(instance, arg);
     }
 }