Save This Page
Home » xwork-2.1.1-src » com.opensymphony.xwork2.spring » [javadoc | source]
com.opensymphony.xwork2.spring
public class: SpringObjectFactory [javadoc | source]
java.lang.Object
   com.opensymphony.xwork2.ObjectFactory
      com.opensymphony.xwork2.spring.SpringObjectFactory

All Implemented Interfaces:
    org.springframework.context.ApplicationContextAware, Serializable

Direct Known Subclasses:
    SpringProxyableObjectFactory

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  AutowireCapableBeanFactory autoWiringFactory     
protected  int autowireStrategy     
Fields inherited from com.opensymphony.xwork2.ObjectFactory:
reflectionProvider
Method from com.opensymphony.xwork2.spring.SpringObjectFactory Summary:
autoWireBean,   autoWireBean,   buildBean,   buildBean,   findAutoWiringBeanFactory,   getAutowireStrategy,   getClassInstance,   initObjectFactory,   isNoArgConstructorRequired,   setApplicationContext,   setApplicationContextPath,   setAutowireStrategy,   setUseClassCache
Methods from com.opensymphony.xwork2.ObjectFactory:
buildAction,   buildBean,   buildBean,   buildBean,   buildInterceptor,   buildResult,   buildValidator,   getClassInstance,   getObjectFactory,   injectInternalBeans,   isNoArgConstructorRequired,   setClassLoader,   setContainer,   setReflectionProvider
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.opensymphony.xwork2.spring.SpringObjectFactory Detail:
 public Object autoWireBean(Object bean) 
 public Object autoWireBean(Object bean,
    AutowireCapableBeanFactory autoWiringFactory) 
 public Object buildBean(Class clazz,
    Map extraContext) throws Exception 
 public Object buildBean(String beanName,
    Map extraContext,
    boolean injectInternal) throws Exception 
    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.
 public int getAutowireStrategy() 
 public Class getClassInstance(String className) throws ClassNotFoundException 
 public  void initObjectFactory() 
Deprecated! Since - 2.1 as it isn't necessary

    This method sets the ObjectFactory used by XWork to this object. It's best used as the "init-method" of a Spring bean definition in order to hook Spring and XWork together properly (as an alternative to the org.apache.struts2.spring.lifecycle.SpringObjectFactoryListener)
 public boolean isNoArgConstructorRequired() 
    Allows for ObjectFactory implementations that support Actions without no-arg constructors.
 public  void setApplicationContext(ApplicationContext appContext) throws BeansException 
    Set the Spring ApplicationContext that should be used to look beans up with.
 public  void setApplicationContextPath(String ctx) 
 public  void setAutowireStrategy(int autowireStrategy) 
    Sets the autowiring strategy
 public  void setUseClassCache(boolean useClassCache) 
    Enable / disable caching of classes loaded by Spring.