siouxsie.mvc.spring
Class SpringObjectFactory

java.lang.Object
  extended by com.opensymphony.xwork2.ObjectFactory
      extended by siouxsie.mvc.spring.SpringObjectFactory
All Implemented Interfaces:
java.io.Serializable

public class SpringObjectFactory
extends com.opensymphony.xwork2.ObjectFactory

static Spring object factory. The application context must be assigned statically before the factory is used. Static init is nasty but allows easy sharing of application contexts. If the MVC app is standalone, prefer the XW spring object factory and set the XML files path via the XW container. Code mainly taken from XW 2.1.

Version:
$Id: SpringObjectFactory.java 119 2008-02-24 18:16:32Z acogo $
Author:
Arnaud Cogoluegnes
See Also:
Serialized Form

Field Summary
protected static org.springframework.context.ApplicationContext APP_CONTEXT
           
protected  int autowireStrategy
           
protected static org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory
           
 
Fields inherited from class com.opensymphony.xwork2.ObjectFactory
reflectionProvider
 
Constructor Summary
SpringObjectFactory()
           
 
Method Summary
 java.lang.Object autoWireBean(java.lang.Object bean)
           
 java.lang.Object autoWireBean(java.lang.Object bean, org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory)
           
 java.lang.Object buildBean(java.lang.Class clazz, java.util.Map extraContext)
           
 java.lang.Object buildBean(java.lang.String beanName, java.util.Map extraContext, boolean injectInternal)
          Looks up beans using Spring's application context before falling back to the method defined in the ObjectFactory.
protected static 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()
           
 java.lang.Class getClassInstance(java.lang.String className)
           
 boolean isNoArgConstructorRequired()
          Allows for ObjectFactory implementations that support Actions without no-arg constructors.
static 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)
          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

APP_CONTEXT

protected static org.springframework.context.ApplicationContext APP_CONTEXT

autoWiringFactory

protected static org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory

autowireStrategy

protected int autowireStrategy
Constructor Detail

SpringObjectFactory

public SpringObjectFactory()
Method Detail

setApplicationContext

public static void setApplicationContext(org.springframework.context.ApplicationContext appContext)
                                  throws org.springframework.beans.BeansException
Set the Spring ApplicationContext that should be used to look beans up with.

Parameters:
appContext - The Spring ApplicationContext that should be used to look beans up with.
Throws:
org.springframework.beans.BeansException

setAutowireStrategy

public void setAutowireStrategy(int autowireStrategy)
Sets the autowiring strategy

Parameters:
autowireStrategy -

getAutowireStrategy

public int getAutowireStrategy()

findAutoWiringBeanFactory

protected static 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.

Parameters:
context -

buildBean

public java.lang.Object buildBean(java.lang.String beanName,
                                  java.util.Map extraContext,
                                  boolean injectInternal)
                           throws java.lang.Exception
Looks up beans using Spring's application context before falling back to the method defined in the ObjectFactory.

Overrides:
buildBean in class com.opensymphony.xwork2.ObjectFactory
Parameters:
beanName - The name of the bean to look up in the application context
extraContext -
Returns:
A bean from Spring or the result of calling the overridden method.
Throws:
java.lang.Exception

buildBean

public java.lang.Object buildBean(java.lang.Class clazz,
                                  java.util.Map extraContext)
                           throws java.lang.Exception
Overrides:
buildBean in class com.opensymphony.xwork2.ObjectFactory
Parameters:
clazz -
extraContext -
Throws:
java.lang.Exception

autoWireBean

public java.lang.Object autoWireBean(java.lang.Object bean)

autoWireBean

public java.lang.Object autoWireBean(java.lang.Object bean,
                                     org.springframework.beans.factory.config.AutowireCapableBeanFactory autoWiringFactory)
Parameters:
bean -
autoWiringFactory -

getClassInstance

public java.lang.Class getClassInstance(java.lang.String className)
                                 throws java.lang.ClassNotFoundException
Overrides:
getClassInstance in class com.opensymphony.xwork2.ObjectFactory
Throws:
java.lang.ClassNotFoundException

isNoArgConstructorRequired

public boolean isNoArgConstructorRequired()
Allows for ObjectFactory implementations that support Actions without no-arg constructors.

Overrides:
isNoArgConstructorRequired in class com.opensymphony.xwork2.ObjectFactory
Returns:
false

setUseClassCache

public void setUseClassCache(boolean useClassCache)
Enable / disable caching of classes loaded by Spring.

Parameters:
useClassCache -


Copyright © 2006-2008 null. All Rights Reserved.