struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4110) struts2+spring intergration,when user aop, maybe inject fail
Date Wed, 06 Aug 2014 20:20:18 GMT

    [ https://issues.apache.org/jira/browse/WW-4110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14088186#comment-14088186
] 

Hudson commented on WW-4110:
----------------------------

SUCCESS: Integrated in Struts-JDK6-develop #73 (See [https://builds.apache.org/job/Struts-JDK6-develop/73/])
WW-4110 Adds special flag to use different logic when creating AOP beans (lukaszlenart: rev
ae324c98119ecc44041f40fcb5828773c4f72e33)
* plugins/spring/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java
* plugins/spring/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java
* core/src/main/resources/org/apache/struts2/default.properties
* xwork-core/src/main/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java
* core/src/main/java/org/apache/struts2/StrutsConstants.java


> 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
>            Assignee: Lukasz Lenart
>             Fix For: 2.3.18
>
>         Attachments: test.rar
>
>
> 1.
> {code:java}
>     @Autowired
>     private Resource resource; //no setter
> {code}
> {code:xml}
> <action name="myAction" class="cn.javass.MyAction">
> {code}
> 2. use aop, for example
> {code:xml}
>     <aop:config proxy-target-class="true">
>         <aop:aspect ref="myAspect">
>             <aop:before method="before" pointcut="execution(* cn.javass.MyAction.*(..))"/>
>         </aop:aspect>
>     </aop:config>
> {code}
> 3. StrutsSpringObject
> {code:java}
> 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
> {code}
> spring`s  processing flow :
> (org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory):
> # InstantiationAwareBeanPostProcessor.applyBeanPostProcessorsBeforeInstantiation
> # InstantiationAwareBeanPostProcessor.applyBeanPostProcessorsAfterInitialization
> # doCreateBean
> ## createBeanInstance
> ## populateBean
> ### InstantiationAwareBeanPostProcessor.postProcessAfterInstantiation
> ### autowire, for example AUTOWIRE_BY_NAME,AUTOWIRE_BY_TYPE
> ### InstantiationAwareBeanPostProcessor.postProcessPropertyValues
> ### applyPropertyValues
> # initializeBean
> ## invokeAwareMethods
> ## BeanPostProcessor.postProcessBeforeInitialization
> ## invokeInitMethods
> ## BeanPostProcessor.postProcessAfterInitialization
> # solution
> {code:java}
> bean = autoWiringFactory.createBean(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR,
false);
> bean = autoWireBean(bean, autoWiringFactory);
> bean = autoWiringFactory.initializeBean(bean, bean.getClass().getName());
> {code}
> 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



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message