public class MethodInvocationBeanProvider extends SimpleBeanProvider
A specialized BeanProvider
that creates beans by invoking a
method.
This BeanProvider
implementation is initialized with a
MethodInvocation
object describing the method to be invoked. Optional
a Dependency
can be provided for the instance, on which the method is
to be invoked (if no such dependency is specified, the method to be invoked
must be static). This class is intended for the following use cases:
MethodInvocation
must refer to this factory method and must
provide the parameters for this invocation.Connection
object
that is obtained from a DataSource
. In this case the factory is
defined as a separate bean, and a dependency to this bean is specified to
this bean provider class. The MethodInvocation
defines the
method of this factory bean that has to be called for obtaining an instance.
As is true for other SimpleBeanProvider
s, this provider is
intended to be used together with a life-cycle-aware
BeanProvider
. It does not provide any life-cycle support on its
own.
Constructor and Description |
---|
MethodInvocationBeanProvider(Dependency targetBean,
MethodInvocation methodInv)
Creates a new instance of
MethodInvocationBeanProvider and
initializes it with the dependency to the target object (on which the
method is to be invoked) and the description of the method invocation. |
MethodInvocationBeanProvider(Dependency targetBean,
MethodInvocation methodInv,
ClassDescription beanClsDsc)
Creates a new instance of
MethodInvocationBeanProvider and
initializes it with the dependency to the target object (on which the
method is to be invoked), the description of the method invocation, and
the class of the managed bean. |
MethodInvocationBeanProvider(MethodInvocation methodInv)
Creates a new instance of
MethodInvocationBeanProvider and
initializes it with the description of the method to invoke. |
Modifier and Type | Method and Description |
---|---|
Object |
getBean(DependencyProvider dependencyProvider)
Returns the bean managed by this provider.
|
Class<?> |
getBeanClass(DependencyProvider dependencyProvider)
Returns the bean class of the bean managed by this provider.
|
ClassDescription |
getBeanClassDescription()
Returns the description of the class of the managed bean.
|
Set<Dependency> |
getDependencies()
Returns the dependencies of this bean provider.
|
MethodInvocation |
getInvocation()
Returns the
MethodInvocation for the method to be invoked. |
Dependency |
getTargetDependency()
Returns the dependency to the target bean.
|
String |
toString()
Returns a string representation for this object.
|
getLockID, isBeanAvailable, setLockID, shutdown
public MethodInvocationBeanProvider(Dependency targetBean, MethodInvocation methodInv)
MethodInvocationBeanProvider
and
initializes it with the dependency to the target object (on which the
method is to be invoked) and the description of the method invocation.targetBean
- the dependency to the target bean (can be null)methodInv
- the description of the method to invoke (must not be
null)IllegalArgumentException
- if the MethodInvocation
is undefinedpublic MethodInvocationBeanProvider(MethodInvocation methodInv)
MethodInvocationBeanProvider
and
initializes it with the description of the method to invoke. No
dependency for the target instance is provided, so a static method must
be specified.methodInv
- the description of the method to invoke (must not be
null)IllegalArgumentException
- if the MethodInvocation
is undefinedpublic MethodInvocationBeanProvider(Dependency targetBean, MethodInvocation methodInv, ClassDescription beanClsDsc)
MethodInvocationBeanProvider
and
initializes it with the dependency to the target object (on which the
method is to be invoked), the description of the method invocation, and
the class of the managed bean. Depending on the used dependency and/or
the method invocation, it is not always possible to determine the class
of the managed bean. With this constructor it can be explicitly set.targetBean
- the dependency to the target bean (can be null)methodInv
- the description of the method to invoke (must not be
null)beanClsDsc
- a description of the class of the managed bean (can be
null)IllegalArgumentException
- if the MethodInvocation
is undefinedpublic Dependency getTargetDependency()
public MethodInvocation getInvocation()
MethodInvocation
for the method to be invoked.public ClassDescription getBeanClassDescription()
MethodInvocation
object owned by this provider. Because
a class is optional for a method invocation, result can be null.
To avoid this, a valid ClassDescription
should always be set
either on the MethodInvocation
or when an instance of this
class is constructed.public Object getBean(DependencyProvider dependencyProvider)
dependencyProvider
- the dependency providerpublic Class<?> getBeanClass(DependencyProvider dependencyProvider)
getBeanClassDescription()
for
obtaining the description of the bean class. If this is successful, the
class is resolved; otherwise result is null.dependencyProvider
- the dependency providergetBeanClassDescription()
public Set<Dependency> getDependencies()
MethodInvocation
object. If a
dependency for the target instance is provided, it will also be contained
in the returned set.getDependencies
in interface BeanProvider
getDependencies
in class SimpleBeanProvider
Dependency
Copyright © 2016 The JGUIraffe Team. All rights reserved.