org.apache.felix.ipojo.util
Class Callback

java.lang.Object
  extended by org.apache.felix.ipojo.util.Callback
Direct Known Subclasses:
DependencyCallback

public class Callback
extends java.lang.Object

A callback allows calling a method on the component instances.

Author:
Felix Project Team

Field Summary
protected  java.lang.reflect.Method m_methodObj
          Method object.
 
Constructor Summary
Callback(MethodMetadata method, InstanceManager manager)
          Constructor.
Callback(java.lang.String method, java.lang.Class[] args, boolean isStatic, InstanceManager manager)
          Callback constructor.
Callback(java.lang.String method, java.lang.String[] args, boolean isStatic, InstanceManager manager)
          Callback constructor.
 
Method Summary
 java.lang.Object call()
          Call the method.
 java.lang.Object call(java.lang.Object instance)
          Call the current callback method on the instance given in parameter.
 java.lang.Object call(java.lang.Object[] arg)
          Call the callback on the method with the argument given in parameter.
 java.lang.Object call(java.lang.Object instance, java.lang.Object[] arg)
          Call the callback on the method with the argument given in parameter and with the arguments given in parameter too.
 java.lang.String getMethod()
           
protected  void searchMethod()
          Search the method object in the POJO by analyzing present method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_methodObj

protected java.lang.reflect.Method m_methodObj
Method object.

Constructor Detail

Callback

public Callback(java.lang.String method,
                java.lang.String[] args,
                boolean isStatic,
                InstanceManager manager)
Callback constructor.

Parameters:
method - : the name of the method to call
args - : argument type name
isStatic - : is the method a static method
manager - : the instance manager of the component containing the method

Callback

public Callback(java.lang.String method,
                java.lang.Class[] args,
                boolean isStatic,
                InstanceManager manager)
Callback constructor.

Parameters:
method - : the name of the method to call
args - : argument classes
isStatic - : is the method a static method
manager - : the instance manager of the component containing the method

Callback

public Callback(MethodMetadata method,
                InstanceManager manager)
Constructor.

Parameters:
method - : Method Metadata obtain form manipulation metadata.
manager - : instance manager.
Method Detail

searchMethod

protected void searchMethod()
                     throws java.lang.NoSuchMethodException
Search the method object in the POJO by analyzing present method. The name of the method and the argument type are checked.

Throws:
java.lang.NoSuchMethodException - : occurs when the method cannot be found either in the pojo class either in parent classes.

call

public java.lang.Object call()
                      throws java.lang.NoSuchMethodException,
                             java.lang.IllegalAccessException,
                             java.lang.reflect.InvocationTargetException
Call the method.

Returns:
the result of the invocation, null for void method, the last result for multi-object instance
Throws:
java.lang.NoSuchMethodException - : Method is not found in the class
java.lang.reflect.InvocationTargetException - : The method is not static
java.lang.IllegalAccessException - : The method can not be invoked

call

public java.lang.Object call(java.lang.Object instance)
                      throws java.lang.NoSuchMethodException,
                             java.lang.IllegalAccessException,
                             java.lang.reflect.InvocationTargetException
Call the current callback method on the instance given in parameter.

Parameters:
instance - : instance on which call the callback
Returns:
the result of the invocation, null for void method
Throws:
java.lang.NoSuchMethodException - : the method was not found
java.lang.IllegalAccessException - : the method cannot be called
java.lang.reflect.InvocationTargetException - : an error happens in the method

call

public java.lang.Object call(java.lang.Object[] arg)
                      throws java.lang.NoSuchMethodException,
                             java.lang.IllegalAccessException,
                             java.lang.reflect.InvocationTargetException
Call the callback on the method with the argument given in parameter.

Parameters:
arg - : the parameters
Returns:
the result of the invocation, null for void method, the last result for multi-object instance
Throws:
java.lang.NoSuchMethodException - : the callback method is not found
java.lang.IllegalAccessException - : the callback method cannot be called
java.lang.reflect.InvocationTargetException - : an error occurs inside the called method

call

public java.lang.Object call(java.lang.Object instance,
                             java.lang.Object[] arg)
                      throws java.lang.NoSuchMethodException,
                             java.lang.IllegalAccessException,
                             java.lang.reflect.InvocationTargetException
Call the callback on the method with the argument given in parameter and with the arguments given in parameter too.

Parameters:
instance - : instance on which call the callback
arg - : the argument array
Returns:
the result of the invocation, null for void method
Throws:
java.lang.NoSuchMethodException - : the callback method is not found
java.lang.IllegalAccessException - : the callback method cannot be called
java.lang.reflect.InvocationTargetException - : an error occurs inside the called method

getMethod

public java.lang.String getMethod()