|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.ObjectFactory
com.opensymphony.xwork2.spring.SpringObjectFactory
public class SpringObjectFactory
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.
Field Summary | |
---|---|
protected ApplicationContext |
appContext
|
protected int |
autowireStrategy
|
protected AutowireCapableBeanFactory |
autoWiringFactory
|
Constructor Summary | |
---|---|
SpringObjectFactory()
|
Method Summary | |
---|---|
Object |
autoWireBean(Object bean)
|
Object |
autoWireBean(Object bean,
AutowireCapableBeanFactory autoWiringFactory)
|
Object |
buildBean(Class clazz,
Map extraContext)
Build a generic Java object of the given type. |
Object |
buildBean(String beanName,
Map extraContext,
boolean injectInternal)
Looks up beans using Spring's application context before falling back to the method defined in the ObjectFactory . |
protected AutowireCapableBeanFactory |
findAutoWiringBeanFactory(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)
Utility method to obtain the class matched to className. |
void |
initObjectFactory()
This method sets the ObjectFactory used by XWork to this object. |
boolean |
isNoArgConstructorRequired()
Allows for ObjectFactory implementations that support Actions without no-arg constructors. |
void |
setApplicationContext(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 |
setUseClassCache(boolean useClassCache)
Enable / disable caching of classes loaded by Spring. |
Methods inherited from class com.opensymphony.xwork2.ObjectFactory |
---|
buildAction, buildBean, buildInterceptor, buildResult, buildValidator, getObjectFactory, injectInternalBeans, setClassLoader, setContainer, setObjectFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ApplicationContext appContext
protected AutowireCapableBeanFactory autoWiringFactory
protected int autowireStrategy
Constructor Detail |
---|
public SpringObjectFactory()
Method Detail |
---|
public void setApplicationContextPath(String ctx)
public void setApplicationContext(ApplicationContext appContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
appContext
- The Spring ApplicationContext that should be used to look beans up with.
BeansException
public void setAutowireStrategy(int autowireStrategy)
autowireStrategy
- public int getAutowireStrategy()
protected AutowireCapableBeanFactory findAutoWiringBeanFactory(ApplicationContext context)
context
- public Object buildBean(String beanName, Map extraContext, boolean injectInternal) throws Exception
ObjectFactory
.
buildBean
in class ObjectFactory
beanName
- The name of the bean to look up in the application contextextraContext
-
Exception
public Object buildBean(Class clazz, Map extraContext) throws Exception
ObjectFactory
buildBean
in class ObjectFactory
clazz
- extraContext
-
Exception
public Object autoWireBean(Object bean)
public Object autoWireBean(Object bean, AutowireCapableBeanFactory autoWiringFactory)
bean
- autoWiringFactory
- public Class getClassInstance(String className) throws ClassNotFoundException
ObjectFactory
getClassInstance
in class ObjectFactory
className
- The fully qualified name of the class to return
ClassNotFoundException
public void initObjectFactory()
public boolean isNoArgConstructorRequired()
isNoArgConstructorRequired
in class ObjectFactory
public void setUseClassCache(boolean useClassCache)
useClassCache
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |