com.acciente.commons.reflect
Class Invoker
java.lang.Object
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
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 |
Invoker
public Invoker()
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 invokedaoArgs
- an array containing a set of arguments each of a distinct typeoParameterProvider
- 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 invokedoTarget
- the target object on which the method should be invokedaoArgs
- an array containing a set of arguments each of a distinct typeoParameterProvider
- 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
Copyright © 2008-2011 Acciente, LLC. All Rights Reserved.