MethodInvokingFactoryBean).
This invoker supports any kind of target method. A static method may be specified
by setting the targetMethod property to a String representing
the static method name, with targetClass specifying the Class
that the static method is defined on. Alternatively, a target instance method may be
specified, by setting the targetObject property as the target
object, and the targetMethod property as the name of the
method to call on that target object. Arguments for the method invocation may be
specified by setting the arguments property.
This class depends on afterPropertiesSet() being called once
all properties have been set, as per the InitializingBean contract.
An example (in an XML based bean factory definition) of a bean definition which uses this class to call a static initialization method:
<bean id="myObject" class="org.springframework.beans.factory.config.MethodInvokingBean"> <property name="staticMethod" value="com.whatever.MyClass.init"/> </bean>
An example of calling an instance method to start some server bean:
<bean id="myStarter" class="org.springframework.beans.factory.config.MethodInvokingBean"> <property name="targetObject" ref="myServer"/> <property name="targetMethod" value="start"/> </bean>
MethodInvokingFactoryBean, org.springframework.util.MethodInvoker
| Modifier and Type | Field and Description |
|---|---|
| private ClassLoader | |
| private ConfigurableBeanFactory |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. |
| protected TypeConverter | getDefaultTypeConverter()
Overrides org. |
| protected Object | invokeWithTargetException()
Perform the invocation and convert InvocationTargetException into the underlying target exception. |
| protected Class | resolveClassName(String
the class name to resolve className)Overrides org. |
| public void | setBeanClassLoader(ClassLoader
the owning class loader classLoader)Implements org. class loader to
a bean instance.
|
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. |
| beanClassLoader | back to summary |
|---|---|
| private ClassLoader beanClassLoader
| |
| beanFactory | back to summary |
|---|---|
| private ConfigurableBeanFactory beanFactory
| |
| MethodInvokingBean | back to summary |
|---|---|
| public MethodInvokingBean() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() throws Exception Implements org. Doc from org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. | |
| getDefaultTypeConverter | back to summary |
|---|---|
| protected TypeConverter getDefaultTypeConverter() Overrides org. Obtain the TypeConverter from the BeanFactory that this bean runs in, if possible.
| |
| invokeWithTargetException | back to summary |
|---|---|
| protected Object invokeWithTargetException() throws Exception Perform the invocation and convert InvocationTargetException into the underlying target exception.
| |
| resolveClassName | back to summary |
|---|---|
| protected Class Overrides org. Doc from org. Resolve the given class name into a Class. The default implementations uses
| |
| setBeanClassLoader | back to summary |
|---|---|
| public void setBeanClassLoader(ClassLoader classLoader) Implements org. Doc from org. Callback that supplies the bean Invoked after the population of normal bean properties but
before an initialization callback such as
| |
| setBeanFactory | back to summary |
|---|---|
| public void setBeanFactory(BeanFactory beanFactory) Implements org. Doc from org. Callback that supplies the owning factory to a bean instance. Invoked after the population of normal bean properties
but before an initialization callback such as
| |