01: /*
02: * Created on 12 Sep 2007
03: */
04: package uk.org.ponder.rsf.swf.support;
05:
06: import org.springframework.beans.BeansException;
07: import org.springframework.beans.factory.config.BeanPostProcessor;
08: import org.springframework.context.ApplicationContext;
09: import org.springframework.context.ApplicationContextAware;
10:
11: import uk.org.ponder.springutil.validator.ValidatorCompostor;
12:
13: public class ValidatorFormActionPostProcessor implements
14: BeanPostProcessor, ApplicationContextAware {
15:
16: private ApplicationContext applicationContext;
17:
18: private ValidatorCompostor validatorComposter;
19:
20: public void setValidatorComposter(
21: ValidatorCompostor validatorComposter) {
22: this .validatorComposter = validatorComposter;
23: }
24:
25: public Object postProcessAfterInitialization(Object bean,
26: String beanName) throws BeansException {
27: // TODO Auto-generated method stub
28: return null;
29: }
30:
31: public Object postProcessBeforeInitialization(Object bean,
32: String beanName) throws BeansException {
33: if (bean instanceof ValidatorFormAction) {
34: // Use this method to break load-time cycles
35: if (validatorComposter == null) {
36: validatorComposter = (ValidatorCompostor) applicationContext
37: .getBean("validatorComposter");
38: }
39: ((ValidatorFormAction) bean)
40: .setValidatorComposter(validatorComposter);
41: }
42: return bean;
43: }
44:
45: public void setApplicationContext(
46: ApplicationContext applicationContext)
47: throws BeansException {
48: this.applicationContext = applicationContext;
49: }
50:
51: }
|