dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01412
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 422: Replaced the Spring 1 AOP definitions with Spring 2 AOP syntax. The Spring 1 stuff did not work i...
------------------------------------------------------------
revno: 422
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-07-07 12:27:18 +0200
message:
Replaced the Spring 1 AOP definitions with Spring 2 AOP syntax. The Spring 1 stuff did not work in conjunction with Spring Transaction management when the same bean was being adviced.
modified:
dhis-2/dhis-i18n/dhis-i18n-db/pom.xml
dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/interceptor/I18nObjectInterceptor.java
dhis-2/dhis-i18n/dhis-i18n-db/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-organisationunit/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-system/pom.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionInterceptor.java
dhis-2/pom.xml
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/pom.xml'
--- dhis-2/dhis-i18n/dhis-i18n-db/pom.xml 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/pom.xml 2009-07-07 10:27:18 +0000
@@ -28,6 +28,14 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ </dependency>
</dependencies>
</project>
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/interceptor/I18nObjectInterceptor.java'
--- dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/interceptor/I18nObjectInterceptor.java 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/interceptor/I18nObjectInterceptor.java 2009-07-07 10:27:18 +0000
@@ -28,17 +28,15 @@
*/
import java.lang.reflect.Method;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
import org.hisp.dhis.i18n.I18nService;
+import org.aspectj.lang.ProceedingJoinPoint;
/**
* @author Torgeir Lorange Ostby
+ * @author Lars Helge Overland
* @version $Id: I18nObjectInterceptor.java 5992 2008-10-19 11:52:20Z larshelg $
*/
public class I18nObjectInterceptor
- implements MethodInterceptor
{
private static final String ADD = "add";
@@ -65,41 +63,32 @@
// MethodInterceptor implementation
// -------------------------------------------------------------------------
- public Object invoke( MethodInvocation methodInvocation )
+ public void intercept( ProceedingJoinPoint joinPoint )
throws Throwable
{
- String methodName = methodInvocation.getMethod().getName();
-
- Object object = null;
-
- if ( methodInvocation.getArguments().length == 1 )
- {
- object = methodInvocation.getArguments()[0];
- }
-
- if ( object != null )
- {
+ String methodName = joinPoint.getSignature().toShortString();
+
+ if ( joinPoint.getArgs() != null && joinPoint.getArgs().length > 0 )
+ {
+ Object object = joinPoint.getArgs()[0];
+
if ( methodName.startsWith( ADD ) )
{
- Object returnValue = methodInvocation.proceed();
+ joinPoint.proceed();
i18nService.addObject( object );
-
- return returnValue;
}
else if ( methodName.startsWith( UPDATE ) )
{
i18nService.verify( object );
- return methodInvocation.proceed();
+ joinPoint.proceed();
}
else if ( methodName.startsWith( DELETE ) )
{
- Object returnValue = methodInvocation.proceed();
+ joinPoint.proceed();
i18nService.removeObject( object );
-
- return returnValue;
}
else if ( methodName.startsWith( SAVE ) )
{
@@ -109,21 +98,21 @@
if ( id == 0 )
{
- Object returnValue = methodInvocation.proceed();
+ joinPoint.proceed();
i18nService.addObject( object );
-
- return returnValue;
}
else
{
i18nService.verify( object );
- return methodInvocation.proceed();
+ joinPoint.proceed();
}
}
}
-
- return methodInvocation.proceed();
+ else
+ {
+ joinPoint.proceed();
+ }
}
}
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-i18n/dhis-i18n-db/src/main/resources/META-INF/dhis/beans.xml 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/src/main/resources/META-INF/dhis/beans.xml 2009-07-07 10:27:18 +0000
@@ -212,7 +212,7 @@
<!-- I81n AOP definitions -->
<!--
- <bean id="I18nObjectInterceptor"
+ <bean id="i18nObjectInterceptor"
class="org.hisp.dhis.i18n.interceptor.I18nObjectInterceptor">
<property name="i18nService"
ref="org.hisp.dhis.i18n.I18nService"/>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2009-07-06 22:27:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2009-07-07 10:27:18 +0000
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- Store definitions -->
@@ -516,23 +518,22 @@
<!-- Deletion AOP definitions -->
- <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
- <property name="advice" ref="deletionInterceptor"/>
- <property name="patterns">
- <list>
- <value>.*\.DataDictionaryService\.delete.*</value>
- <value>.*\.DataElementService\.delete.*</value>
- <value>.*\.DataElementCategoryService\.delete.*</value>
- <value>.*\.DataElementCategoryComboService\.delete.*</value>
- <value>.*\.DataElementCategoryOptionService\.delete.*</value>
- <value>.*\.DataSetService\.delete.*</value>
- <value>.*\.IndicatorService\.delete.*</value>
- <value>.*\.ExpressionService\.delete.*</value>
- <value>.*\.MinMaxDataElementService\.delete.*</value>
- <value>.*\.ValidationRuleService\.delete.*</value>
- <value>.*\.PeriodService\.delete.*</value>
- </list>
- </property>
- </bean>
+ <aop:config>
+
+ <aop:aspect ref="deletionInterceptor">
+ <aop:before pointcut="execution( * org.hisp.dhis.datadictionary.DataDictionaryService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.dataelement.DataElementService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.dataelement.DataElementCategoryService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.dataelement.DataElementCategoryComboService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.dataelement.DataElementCategoryOptionService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.dataset.DataSetService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.indicator.IndicatorService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.expression.ExpressionService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.minmax.MinMaxDataElementService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.validation.ValidationRuleService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.period.PeriodService.delete*(..) )" method="intercept"/>
+ </aop:aspect>
+
+ </aop:config>
</beans>
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2009-06-19 13:23:57 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2009-07-07 10:27:18 +0000
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- DataMartExportStore -->
@@ -220,15 +222,14 @@
<!-- Deletion AOP definitions -->
- <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
- <property name="advice" ref="deletionInterceptor"/>
- <property name="patterns">
- <list>
- <value>.*\.DataMartExportService\.delete.*</value>
- </list>
- </property>
- </bean>
+ <aop:config>
+ <aop:aspect ref="deletionInterceptor">
+ <aop:before pointcut="execution( * org.hisp.dhis.datamart.DataMartExportService.delete*(..) )" method="intercept"/>
+ </aop:aspect>
+
+ </aop:config>
+
<!-- Startup -->
<bean id="org.hisp.dhis.datamart.startup.AggregationTableCreator"
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-06-10 22:25:07 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-07-07 10:27:18 +0000
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- Service definitions -->
@@ -51,17 +53,8 @@
ref="org.hisp.dhis.mapping.MappingService"/>
</bean>
- <!-- Deletion AOP definitions -->
+ <!-- DeletionManager -->
- <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
- <property name="advice" ref="deletionInterceptor"/>
- <property name="patterns">
- <list>
- <value>.*\.MappingService\.delete.*</value>
- </list>
- </property>
- </bean>
-
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="org.hisp.dhis.system.deletion.DeletionManager"/>
<property name="targetMethod" value="addDeletionHandlers"/>
@@ -71,10 +64,20 @@
<ref local="org.hisp.dhis.mapping.MapDeletionHandler"/>
<ref local="org.hisp.dhis.mapping.MapLegendSetDeletionHandler"/>
<ref local="org.hisp.dhis.mapping.MapOrganisationUnitRelationDeletionHandler"/>
- <ref local="org.hisp.dhis.mapping.MapViewDeletionHandler"/>
+ <ref local="org.hisp.dhis.mapping.MapViewDeletionHandler"/>
</list>
</list>
</property>
</bean>
+ <!-- Deletion AOP definitions -->
+
+ <aop:config>
+
+ <aop:aspect ref="deletionInterceptor">
+ <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.delete*(..) )" method="intercept"/>
+ </aop:aspect>
+
+ </aop:config>
+
</beans>
=== modified file 'dhis-2/dhis-services/dhis-service-organisationunit/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2009-06-10 22:25:07 +0000
+++ dhis-2/dhis-services/dhis-service-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2009-07-07 10:27:18 +0000
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="org.hisp.dhis.organisationunit.OrganisationUnitStore"
class="org.hisp.dhis.organisationunit.hibernate.HibernateOrganisationUnitStore">
@@ -86,14 +88,13 @@
<!-- Deletion AOP definitions -->
- <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
- <property name="advice" ref="deletionInterceptor"/>
- <property name="patterns">
- <list>
- <value>.*\.OrganisationUnitService\.delete.*</value>
- <value>.*\.OrganisationUnitGroupService\.delete.*</value>
- </list>
- </property>
- </bean>
+ <aop:config>
+
+ <aop:aspect ref="deletionInterceptor">
+ <aop:before pointcut="execution( * org.hisp.dhis.organisationunit.OrganisationUnitService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.organisationunit.OrganisationUnitGroupService.delete*(..) )" method="intercept"/>
+ </aop:aspect>
+
+ </aop:config>
</beans>
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-06-19 13:23:57 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-07-07 10:27:18 +0000
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- OLAP -->
@@ -309,16 +311,15 @@
<!-- Deletion AOP definitions -->
- <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
- <property name="advice" ref="deletionInterceptor"/>
- <property name="patterns">
- <list>
- <value>.*\.ReportTableService\.delete.*</value>
- <value>.*\.ReportStore\.delete.*</value>
- <value>.*\.ChartService\.delete.*</value>
- <value>.*\.DocumentService\.delete.*</value>
- </list>
- </property>
- </bean>
+ <aop:config>
+ <aop:aspect ref="deletionInterceptor">
+ <aop:before pointcut="execution( * org.hisp.dhis.reporttable.ReportTableService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.report.ReportService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.chart.ChartService.delete*(..) )" method="intercept"/>
+ <aop:before pointcut="execution( * org.hisp.dhis.document.DocumentService.delete*(..) )" method="intercept"/>
+ </aop:aspect>
+
+ </aop:config>
+
</beans>
=== modified file 'dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/META-INF/dhis/beans.xml 2009-06-10 22:25:07 +0000
+++ dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/META-INF/dhis/beans.xml 2009-07-07 10:27:18 +0000
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="org.hisp.dhis.user.UserStore"
class="org.hisp.dhis.user.hibernate.HibernateUserStore">
@@ -63,4 +65,14 @@
</property>
</bean>
+ <!-- Deletion AOP definitions -->
+
+ <aop:config>
+
+ <aop:aspect ref="deletionInterceptor">
+ <aop:before pointcut="execution( * org.hisp.dhis.user.UserStore.delete*(..) )" method="intercept"/>
+ </aop:aspect>
+
+ </aop:config>
+
</beans>
=== modified file 'dhis-2/dhis-support/dhis-support-system/pom.xml'
--- dhis-2/dhis-support/dhis-support-system/pom.xml 2009-06-14 19:43:19 +0000
+++ dhis-2/dhis-support/dhis-support-system/pom.xml 2009-07-07 10:27:18 +0000
@@ -33,6 +33,14 @@
<!-- Other -->
<dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</dependency>
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionInterceptor.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionInterceptor.java 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionInterceptor.java 2009-07-07 10:27:18 +0000
@@ -27,14 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
+import org.aspectj.lang.JoinPoint;
+
/**
* @author Lars Helge Overland
* @version $Id$
*/
public class DeletionInterceptor
- implements MethodInterceptor
{
// -------------------------------------------------------------------------
// Dependencies
@@ -51,16 +50,11 @@
// MethodInterceptor Implementation
// ----------------------------------------------------------------------
- public Object invoke( MethodInvocation methodInvocation )
- throws Throwable
+ public void intercept( JoinPoint joinPoint )
{
- if ( methodInvocation.getArguments().length == 1 )
+ if ( joinPoint.getArgs() != null && joinPoint.getArgs().length > 0 )
{
- Object object = methodInvocation.getArguments()[0];
-
- deletionManager.execute( object );
+ deletionManager.execute( joinPoint.getArgs()[0] );
}
-
- return methodInvocation.proceed();
}
}
=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml 2009-07-02 23:13:13 +0000
+++ dhis-2/pom.xml 2009-07-07 10:27:18 +0000
@@ -299,6 +299,16 @@
<version>2.5.6</version>
</dependency>
<dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.6</version>
@@ -391,11 +401,6 @@
<version>2.4</version>
</dependency>
<dependency>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
<groupId>com.opensymphony</groupId>
<artifactId>webwork</artifactId>
<version>2.2.6</version>
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.