|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork.ObjectFactory
com.opensymphony.xwork.spring.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 org.springframework.context.ApplicationContext |
appContext
|
protected int |
autowireStrategy
|
protected org.springframework.beans.factory.config.AutowireCapableBeanFactory |
autoWiringFactory
|
Constructor Summary | |
SpringObjectFactory()
|
Method Summary | |
Object |
autoWireBean(Object bean)
|
Object |
autoWireBean(Object bean,
org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory)
|
Object |
buildBean(Class clazz,
Map extraContext)
Build a generic Java object of the given type. |
Object |
buildBean(String beanName,
Map extraContext)
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)
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(org.springframework.context.ApplicationContext appContext)
Set the Spring ApplicationContext that should be used to look beans up with. |
void |
setAutowireStrategy(int autowireStrategy)
Sets the autowiring strategy |
void |
setUseClassCache(boolean useClassCache)
|
Methods inherited from class com.opensymphony.xwork.ObjectFactory |
buildAction, buildInterceptor, buildResult, buildValidator, getContinuationPackage, getObjectFactory, setContinuationPackage, setObjectFactory |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected org.springframework.context.ApplicationContext appContext
protected org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory
protected int autowireStrategy
Constructor Detail |
public SpringObjectFactory()
Method Detail |
public void setApplicationContext(org.springframework.context.ApplicationContext appContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
appContext
- The Spring ApplicationContext that should be used to look beans up with.
org.springframework.beans.BeansException
public void setAutowireStrategy(int autowireStrategy)
autowireStrategy
- public int getAutowireStrategy()
protected org.springframework.beans.factory.config.AutowireCapableBeanFactory findAutoWiringBeanFactory(org.springframework.context.ApplicationContext context)
context
- public Object buildBean(String beanName, Map extraContext) 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, org.springframework.beans.factory.config.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)
|
XWork Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |