public class SpringObjectFactory extends ObjectFactory implements org.springframework.context.ApplicationContextAware
Simple implementation of the ObjectFactory that makes use of Spring's application context if one has been configured, before falling back on the default mechanism of instantiating a new class using the class name.
In order to use this class in your application, you will need to instantiate a copy of this class and set it as XWork's ObjectFactory before the xwork.xml file is parsed. In a servlet environment, this could be done using a ServletContextListener.
| Modifier and Type | Field and Description | 
|---|---|
| protected org.springframework.context.ApplicationContext | appContext | 
| protected int | autowireStrategy | 
| protected org.springframework.beans.factory.config.AutowireCapableBeanFactory | autoWiringFactory | 
| Constructor and Description | 
|---|
| SpringObjectFactory() | 
| Modifier and Type | Method and Description | 
|---|---|
| Object | autoWireBean(Object bean) | 
| Object | autoWireBean(Object bean,
            org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory) | 
| Object | buildBean(Class clazz,
         Map<String,Object> extraContext) | 
| Object | buildBean(String beanName,
         Map<String,Object> extraContext,
         boolean injectInternal)Looks up beans using Spring's application context before falling back to the method defined in the  ObjectFactory. | 
| protected org.springframework.beans.factory.config.AutowireCapableBeanFactory | findAutoWiringBeanFactory(org.springframework.context.ApplicationContext context)If the given context is assignable to AutowireCapbleBeanFactory or contains a parent or a factory that is, then
 set the autoWiringFactory appropriately. | 
| int | getAutowireStrategy() | 
| Class | getClassInstance(String className) | 
| boolean | isNoArgConstructorRequired()Allows for ObjectFactory implementations that support
 Actions without no-arg constructors. | 
| void | setAlwaysRespectAutowireStrategy(boolean alwaysRespectAutowireStrategy)Determines if the autowire strategy is always followed when creating beans | 
| void | setApplicationContext(org.springframework.context.ApplicationContext appContext)Set the Spring ApplicationContext that should be used to look beans up with. | 
| void | setApplicationContextPath(String ctx) | 
| void | setAutowireStrategy(int autowireStrategy)Sets the autowiring strategy | 
| void | setEnableAopSupport(String enableAopSupport) | 
| void | setUseClassCache(boolean useClassCache)Enable / disable caching of classes loaded by Spring. | 
buildAction, buildBean, buildConverter, buildInterceptor, buildResult, buildUnknownHandler, buildValidator, injectInternalBeans, setActionFactory, setClassLoader, setContainer, setConverterFactory, setInterceptorFactory, setResultFactory, setUnknownHandlerFactory, setValidatorFactoryprotected org.springframework.context.ApplicationContext appContext
protected org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory
protected int autowireStrategy
public void setApplicationContextPath(String ctx)
public void setEnableAopSupport(String enableAopSupport)
public void setApplicationContext(org.springframework.context.ApplicationContext appContext)
                           throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareappContext - The Spring ApplicationContext that should be used to look beans up with.org.springframework.beans.BeansExceptionpublic void setAutowireStrategy(int autowireStrategy)
autowireStrategy - the autowire strategypublic int getAutowireStrategy()
protected org.springframework.beans.factory.config.AutowireCapableBeanFactory findAutoWiringBeanFactory(org.springframework.context.ApplicationContext context)
context - the application contextpublic Object buildBean(String beanName, Map<String,Object> extraContext, boolean injectInternal) throws Exception
ObjectFactory.buildBean in class ObjectFactorybeanName - The name of the bean to look up in the application contextextraContext - additional context parametersException - in case of any errorspublic Object buildBean(Class clazz, Map<String,Object> extraContext) throws Exception
buildBean in class ObjectFactoryclazz - class of beanextraContext - additional context parametersException - in case of any errorspublic Object autoWireBean(Object bean, org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory)
bean - the bean to be autowiredautoWiringFactory - the autowiring factorypublic Class getClassInstance(String className) throws ClassNotFoundException
getClassInstance in class ObjectFactoryClassNotFoundExceptionpublic boolean isNoArgConstructorRequired()
isNoArgConstructorRequired in class ObjectFactorypublic void setUseClassCache(boolean useClassCache)
useClassCache - enable / disable class cachepublic void setAlwaysRespectAutowireStrategy(boolean alwaysRespectAutowireStrategy)
alwaysRespectAutowireStrategy - True if the strategy is always usedCopyright © 2000–2025 Apache Software Foundation. All rights reserved.