Return to www.inductionframework.org

com.acciente.commons.reflect
Class Invoker

java.lang.Object
  extended by com.acciente.commons.reflect.Invoker

public class Invoker
extends java.lang.Object

This class contains java reflection helper methods to invoke constructors and methods. The methods in this class are used to do constructor and method dependency injection based on type matching.

Author:
Adinath Raveendra Raj

Constructor Summary
Invoker()
           
 
Method Summary
static java.lang.Object invoke(java.lang.reflect.Constructor oConstructor, java.lang.Object[] aoArgs, ParameterProvider oParameterProvider)
          This method calls the specified class constructor using the specified args as follows.
static java.lang.Object invoke(java.lang.reflect.Method oMethod, java.lang.Object oTarget, java.lang.Object[] aoArgs, ParameterProvider oParameterProvider)
          This method calls the specified method using the specified args as follows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Invoker

public Invoker()
Method Detail

invoke

public static java.lang.Object invoke(java.lang.reflect.Constructor oConstructor,
                                      java.lang.Object[] aoArgs,
                                      ParameterProvider oParameterProvider)
                               throws java.lang.reflect.InvocationTargetException,
                                      java.lang.IllegalAccessException,
                                      java.lang.InstantiationException,
                                      ParameterProviderException
This method calls the specified class constructor using the specified args as follows. Each arg in aoArgs is expected to be of a unique type, if there is more than one value with the same type the first value is used. This method provides a value to each parameter of the constructor from aoArgs based on the type of the expected parameter.

Parameters:
oConstructor - a constructor object to be invoked
aoArgs - an array containing a set of arguments each of a distinct type
oParameterProvider - an interface that allows a developer to provide the value of a parameter based on the parameter type
Returns:
the new object instance created by calling the constructor
Throws:
java.lang.reflect.InvocationTargetException - propagated from Constructor.newInstance()
java.lang.IllegalAccessException - propagated from Constructor.newInstance()
java.lang.InstantiationException - propagated from Constructor.newInstance()
ParameterProviderException - propagated from the supplied ParameterProvider instance

invoke

public static java.lang.Object invoke(java.lang.reflect.Method oMethod,
                                      java.lang.Object oTarget,
                                      java.lang.Object[] aoArgs,
                                      ParameterProvider oParameterProvider)
                               throws java.lang.reflect.InvocationTargetException,
                                      java.lang.IllegalAccessException,
                                      ParameterProviderException
This method calls the specified method using the specified args as follows. Each arg in aoArgs is expected to be of a unique type, if there is more than one value with the same type the first value is used. This method provides a value to each parameter of the method from aoArgs based on the type of the expected parameter.

Parameters:
oMethod - a method object to be invoked
oTarget - the target object on which the method should be invoked
aoArgs - an array containing a set of arguments each of a distinct type
oParameterProvider - an interface that allows a developer to provide the value of a parameter based on the parameter type
Returns:
the value returned by the called method
Throws:
java.lang.reflect.InvocationTargetException - propagated from Constructor.newInstance()
java.lang.IllegalAccessException - propagated from Constructor.newInstance()
ParameterProviderException - propagated from the supplied ParameterProvider instance

Return to www.inductionframework.org

Copyright © 2008-2011 Acciente, LLC. All Rights Reserved.