|
||||||||||
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 org.springframework.context.ApplicationContext |
appContext
|
protected int |
autowireStrategy
|
protected org.springframework.beans.factory.config.AutowireCapableBeanFactory |
autoWiringFactory
|
private Map |
classes
|
private static Logger |
LOG
|
private boolean |
useClassCache
|
Fields inherited from class com.opensymphony.xwork2.ObjectFactory |
---|
reflectionProvider |
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,
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)
Utility method to obtain the class matched to className. |
void |
initObjectFactory()
Deprecated. Since 2.1 as it isn't necessary |
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 |
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, setReflectionProvider |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger LOG
protected org.springframework.context.ApplicationContext appContext
protected org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory
protected int autowireStrategy
private Map classes
private boolean useClassCache
Constructor Detail |
---|
public SpringObjectFactory()
Method Detail |
---|
public void setApplicationContextPath(String ctx)
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, 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, 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)
useClassCache
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |