public class Invocation extends Object
A base class for (method or constructor) invocations.
This class allows the definition of important data that is required for
invoking a method using reflection. Especially the parameter types and the
parameter values can be specified. The parameter values are provided as
Dependency
objects, so they can refer to other beans defined in a
BeanStore
.
The main use case for Invocation
objects is the creation and
initialization of beans performed by the dependency injection framework: At
first a bean has to be created by invoking one of its constructors. After
that some initialization methods may be called. In both cases the parameters
for the calls have to be specified (which can be either constant values or
references to other beans).
This base provides common functionality related to the management of the invocation parameters. There will be concrete sub classes implementing specific invocations of methods or constructors.
Modifier | Constructor and Description |
---|---|
protected |
Invocation(ClassDescription targetClass,
ClassDescription[] paramTypes,
Dependency... paramValues)
Creates a new instance of
Invocation and initializes it
with information about the call parameters. |
Modifier and Type | Method and Description |
---|---|
protected static void |
checkDependencyProvider(DependencyProvider depProvider)
Checks whether a valid
DependencyProvider has been specified. |
Class<?>[] |
getParameterClasses(DependencyProvider depProvider)
Returns an array with the concrete parameter classes.
|
List<Dependency> |
getParameterDependencies()
Returns the
Dependency objects defining the current
parameter values. |
ClassDescription[] |
getParameterTypes()
Returns an array with the types of the parameters of the invocation.
|
Object[] |
getResolvedParameters(DependencyProvider depProvider)
Returns an array with the resolved parameters.
|
ClassDescription |
getTargetClass()
Returns the target class of this invocation.
|
protected void |
invocationInfoToString(StringBuilder buf)
Creates a string with additional information about this invocation.
|
boolean |
isTypeInfoComplete()
Returns a flag whether the data types of all method parameters are known.
|
protected void |
parametersToString(StringBuilder buf)
Creates a string representation of the current parameter values.
|
String |
toString()
Returns a string representation of this object.
|
protected Invocation(ClassDescription targetClass, ClassDescription[] paramTypes, Dependency... paramValues)
Invocation
and initializes it
with information about the call parameters. To perform an invocation the
class has to know the current parameter values and (at least partly) the
data types of these values. From this information the signature of the
method to call is derived. The array with the parameter types can have
null elements if the corresponding parameter types are unknown;
it can even be null at all if no information about data types is
available. If it is not null, its length must be the same as the
length of the array with the parameter values.targetClass
- description of the class, on which the method is to be
invokedparamTypes
- an array with the parameter type descriptionsparamValues
- the current parameter values (defined as
Dependency
objects); this array must not contain null
elementsIllegalArgumentException
- if the length of the parameter types
array does not match the length of the parameter values array or if the
values array contains null elementspublic ClassDescription getTargetClass()
public ClassDescription[] getParameterTypes()
public List<Dependency> getParameterDependencies()
Dependency
objects defining the current
parameter values.Dependency
objects for the
parameter valuespublic boolean isTypeInfoComplete()
public Object[] getResolvedParameters(DependencyProvider depProvider)
DependencyProvider
. An array with the resulting beans is
returned. If no parameters are specified (i.e. for invocations of methods
that do not have arguments), the return value is null.depProvider
- the dependency provider (must not be null)InjectionException
- if a dependency cannot be
resolvedIllegalArgumentException
- if the passed in dependency provider is
nullpublic Class<?>[] getParameterClasses(DependencyProvider depProvider)
ClassDescription
objects into
Class
objects.depProvider
- the dependency provider for resolving the classesInjectionException
- if a class cannot be
resolvedpublic String toString()
invocationInfoToString()
, and
parametersToString()
are called. Finally a closing square
bracket is output.protected void invocationInfoToString(StringBuilder buf)
toString()
implementation.
It adds the target class to the buffer if it is defined.buf
- the target bufferprotected void parametersToString(StringBuilder buf)
toString()
method. It is called by the
toString()
method.buf
- the target bufferprotected static void checkDependencyProvider(DependencyProvider depProvider)
DependencyProvider
has been specified.depProvider
- the provider to be checkedIllegalArgumentException
- if the DependencyProvider
is
undefinedCopyright © 2016 The JGUIraffe Team. All rights reserved.