struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "zhangkaitao (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (WW-4110) struts2+spring intergration,when user aop, maybe inject fail
Date Sun, 16 Jun 2013 08:26:19 GMT

     [ https://issues.apache.org/jira/browse/WW-4110?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

zhangkaitao updated WW-4110:
----------------------------

    Attachment: test.rar

please delete src/main/java patch
com.opensymphony.xwork2.spring.SpringObjectFactory 

test, will see resource is null;

but use this patch will be not null
                
> struts2+spring intergration,when user aop, maybe inject fail
> ------------------------------------------------------------
>
>                 Key: WW-4110
>                 URL: https://issues.apache.org/jira/browse/WW-4110
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - Spring
>    Affects Versions: 2.3.1.1
>            Reporter: zhangkaitao
>         Attachments: test.rar
>
>
> 1、
>     @Autowired
>     private Resource resource; //no setter
> <action name="myAction" class="cn.javass.MyAction">
> 2、use aop, for example
>     <aop:config proxy-target-class="true">
>         <aop:aspect ref="myAspect">
>             <aop:before method="before" pointcut="execution(* cn.javass.MyAction.*(..))"/>
>         </aop:aspect>
>     </aop:config>
> 3、StrutsSpringObject
>  bean = autoWiringFactory.autowire(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR,
false);
>                 bean = autoWiringFactory.applyBeanPostProcessorsBeforeInitialization(bean,
bean.getClass().getName());
>                 // We don't need to call the init-method since one won't be registered.
>                 bean = autoWiringFactory.applyBeanPostProcessorsAfterInitialization(bean,
bean.getClass().getName());  //generate proxy
> return autoWireBean(bean, autoWiringFactory); //inject error  because proxy
> spring`s  processing flow :
> (org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory):
> 1、InstantiationAwareBeanPostProcessor.applyBeanPostProcessorsBeforeInstantiation
> 2、InstantiationAwareBeanPostProcessor.applyBeanPostProcessorsAfterInitialization
> 如果此时有bean返回 直接返回;
> 3、doCreateBean
> 3.1、createBeanInstance
> 3.2、populateBean
> 3.2.1、InstantiationAwareBeanPostProcessor.postProcessAfterInstantiation
> 3.2.2、autowire, for example AUTOWIRE_BY_NAME,AUTOWIRE_BY_TYPE
> 3.2.3、InstantiationAwareBeanPostProcessor.postProcessPropertyValues
> 3.2.4、applyPropertyValues
> 4、initializeBean
> 4.1、invokeAwareMethods
> 4.2、BeanPostProcessor.postProcessBeforeInitialization
> 4.3、invokeInitMethods
> 4.4、BeanPostProcessor.postProcessAfterInitialization
> 5、solution
> bean = autoWiringFactory.createBean(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR,
false);
> bean = autoWireBean(bean, autoWiringFactory);
> bean = autoWiringFactory.initializeBean(bean, bean.getClass().getName());

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message