public class ObjectFactory extends Object implements Serializable
This default implementation uses the buildBean
method to create all classes (interceptors, actions, results, etc).
Constructor and Description |
---|
ObjectFactory() |
Modifier and Type | Method and Description |
---|---|
Object |
buildAction(String actionName,
String namespace,
ActionConfig config,
Map<String,Object> extraContext)
Build an instance of the action class to handle a particular request (eg.
|
Object |
buildBean(Class clazz,
Map<String,Object> extraContext)
Build a generic Java object of the given type.
|
Object |
buildBean(String className,
Map<String,Object> extraContext)
Build a generic Java object of the given type.
|
Object |
buildBean(String className,
Map<String,Object> extraContext,
boolean injectInternal)
Build a generic Java object of the given type.
|
TypeConverter |
buildConverter(Class<? extends TypeConverter> converterClass,
Map<String,Object> extraContext)
Build converter of given type
|
Interceptor |
buildInterceptor(InterceptorConfig interceptorConfig,
Map<String,String> interceptorRefParams)
Builds an Interceptor from the InterceptorConfig and the Map of
parameters from the interceptor reference.
|
Result |
buildResult(ResultConfig resultConfig,
Map<String,Object> extraContext)
Build a Result using the type in the ResultConfig and set the parameters in the ResultConfig.
|
UnknownHandler |
buildUnknownHandler(String unknownHandlerName,
Map<String,Object> extraContext)
Builds unknown handler
|
Validator |
buildValidator(String className,
Map<String,Object> params,
Map<String,Object> extraContext)
Build a Validator of the given type and set the parameters on it
|
Class |
getClassInstance(String className)
Utility method to obtain the class matched to className.
|
protected Object |
injectInternalBeans(Object obj) |
boolean |
isNoArgConstructorRequired()
Allows for ObjectFactory implementations that support
Actions without no-arg constructors.
|
void |
setActionFactory(ActionFactory actionFactory) |
void |
setClassLoader(ClassLoader cl) |
void |
setContainer(Container container) |
void |
setConverterFactory(ConverterFactory converterFactory) |
void |
setInterceptorFactory(InterceptorFactory interceptorFactory) |
void |
setResultFactory(ResultFactory resultFactory) |
void |
setUnknownHandlerFactory(UnknownHandlerFactory unknownHandlerFactory) |
void |
setValidatorFactory(ValidatorFactory validatorFactory) |
public void setContainer(Container container)
public void setClassLoader(ClassLoader cl)
public void setActionFactory(ActionFactory actionFactory)
public void setResultFactory(ResultFactory resultFactory)
public void setInterceptorFactory(InterceptorFactory interceptorFactory)
public void setValidatorFactory(ValidatorFactory validatorFactory)
public void setConverterFactory(ConverterFactory converterFactory)
public void setUnknownHandlerFactory(UnknownHandlerFactory unknownHandlerFactory)
public boolean isNoArgConstructorRequired()
public Class getClassInstance(String className) throws ClassNotFoundException
className
- The fully qualified name of the class to returnClassNotFoundException
- if class not found in classpathpublic Object buildAction(String actionName, String namespace, ActionConfig config, Map<String,Object> extraContext) throws Exception
actionName
- the name the action configuration is set up with in the configurationnamespace
- the namespace the action is configured inconfig
- the action configuration found in the config for the actionName / namespaceextraContext
- a Map of extra context which uses the same keys as the ActionContext
Exception
- in case of any errorpublic Object buildBean(Class clazz, Map<String,Object> extraContext) throws Exception
clazz
- the type of Object to buildextraContext
- a Map of extra context which uses the same keys as the ActionContext
Exception
- in case of any errorprotected Object injectInternalBeans(Object obj)
obj
- object to inject internalpublic Object buildBean(String className, Map<String,Object> extraContext) throws Exception
className
- the type of Object to buildextraContext
- a Map of extra context which uses the same keys as the ActionContext
Exception
- in case of any errorpublic Object buildBean(String className, Map<String,Object> extraContext, boolean injectInternal) throws Exception
className
- the type of Object to buildextraContext
- a Map of extra context which uses the same keys as the ActionContext
injectInternal
- true if inject internal beansException
- in case of any errorpublic Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map<String,String> interceptorRefParams) throws ConfigurationException
interceptorConfig
- the InterceptorConfig from the configurationinterceptorRefParams
- a Map of params provided in the Interceptor reference in the
Action mapping or InterceptorStack definitionConfigurationException
public Result buildResult(ResultConfig resultConfig, Map<String,Object> extraContext) throws Exception
resultConfig
- the ResultConfig found for the action with the result code returnedextraContext
- a Map of extra context which uses the same keys as the ActionContext
Exception
- in case of any errorpublic Validator buildValidator(String className, Map<String,Object> params, Map<String,Object> extraContext) throws Exception
className
- the type of Validator to buildparams
- property name -> value Map to set onto the Validator instanceextraContext
- a Map of extra context which uses the same keys as the ActionContext
Exception
- in case of any errorpublic TypeConverter buildConverter(Class<? extends TypeConverter> converterClass, Map<String,Object> extraContext) throws Exception
converterClass
- to instantiateextraContext
- a Map of extra context which uses the same keys as the ActionContext
Exception
- in case of any errorpublic UnknownHandler buildUnknownHandler(String unknownHandlerName, Map<String,Object> extraContext) throws Exception
unknownHandlerName
- the unknown handler nameextraContext
- extra contextException
- in case of any errorCopyright © 2000–2024 Apache Software Foundation. All rights reserved.