1 16 17 package org.springframework.web.struts; 18 19 import org.apache.struts.action.Action; 20 import org.apache.struts.action.ActionServlet; 21 22 import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; 23 24 39 public class ActionServletAwareProcessor implements DestructionAwareBeanPostProcessor { 40 41 private final ActionServlet actionServlet; 42 43 44 47 public ActionServletAwareProcessor(ActionServlet actionServlet) { 48 this.actionServlet = actionServlet; 49 } 50 51 52 public Object postProcessBeforeInitialization(Object bean, String beanName) { 53 if (bean instanceof Action) { 54 ((Action) bean).setServlet(this.actionServlet); 55 } 56 return bean; 57 } 58 59 public Object postProcessAfterInitialization(Object bean, String beanName) { 60 return bean; 61 } 62 63 public void postProcessBeforeDestruction(Object bean, String beanName) { 64 if (bean instanceof Action) { 65 ((Action) bean).setServlet(null); 66 } 67 } 68 69 } 70 | Popular Tags |