dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02529
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 846: Added a StatementInterceptor and AOP definitions for charts and validation which follow the Sprin...
------------------------------------------------------------
revno: 846
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-10-10 17:35:01 +0200
message:
Added a StatementInterceptor and AOP definitions for charts and validation which follow the Spring 2 AOP style.
added:
dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-jdbc/pom.xml
dhis-2/dhis-services/dhis-service-jdbc/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-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionInterceptor.java
dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java
dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml
--
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.
=== 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-10-02 17:35:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2009-10-10 15:35:01 +0000
@@ -529,7 +529,7 @@
</property>
</bean>
- <!-- Deletion AOP definitions -->
+ <!-- AOP definitions -->
<aop:config>
@@ -547,6 +547,10 @@
<aop:before pointcut="execution( * org.hisp.dhis.period.PeriodService.delete*(..) )" method="intercept"/>
</aop:aspect>
+ <aop:aspect ref="statementInterceptor">
+ <aop:around pointcut="execution( * org.hisp.dhis.validation.ValidationRuleService.validate(..) )" method="intercept"/>
+ </aop:aspect>
+
</aop:config>
</beans>
=== modified file 'dhis-2/dhis-services/dhis-service-jdbc/pom.xml'
--- dhis-2/dhis-services/dhis-service-jdbc/pom.xml 2009-09-06 15:51:11 +0000
+++ dhis-2/dhis-services/dhis-service-jdbc/pom.xml 2009-10-10 15:35:01 +0000
@@ -26,6 +26,14 @@
<artifactId>quick</artifactId>
</dependency>
<dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-support-hibernate</artifactId>
</dependency>
=== added file 'dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java'
--- dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementInterceptor.java 2009-10-10 15:35:01 +0000
@@ -0,0 +1,77 @@
+package org.hisp.dhis.jdbc;
+
+/*
+ * Copyright (c) 2004-2007, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.amplecode.quick.StatementManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.system.deletion.DeletionManager;
+import org.aspectj.lang.ProceedingJoinPoint;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class StatementInterceptor
+{
+ private static final Log log = LogFactory.getLog( StatementInterceptor.class );
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private StatementManager statementManager;
+
+ public void setStatementManager( StatementManager statementManager )
+ {
+ this.statementManager = statementManager;
+ }
+
+ public Object intercept( ProceedingJoinPoint joinPoint )
+ throws Throwable
+ {
+ Object object = null;
+
+ statementManager.initialise();
+
+ log.info( "Initialising statement manager" );
+
+ try
+ {
+ object = joinPoint.proceed();
+ }
+ finally
+ {
+ statementManager.destroy();
+
+ log.info( "Destroying statement manager" );
+ }
+
+ return object;
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-jdbc/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-jdbc/src/main/resources/META-INF/dhis/beans.xml 2009-06-14 19:43:19 +0000
+++ dhis-2/dhis-services/dhis-service-jdbc/src/main/resources/META-INF/dhis/beans.xml 2009-10-10 15:35:01 +0000
@@ -18,7 +18,7 @@
<!-- Interceptor -->
- <bean id="statementInterceptor" class="org.amplecode.quick.statement.StatementInterceptor">
+ <bean id="statementInterceptor" class="org.hisp.dhis.jdbc.StatementInterceptor">
<property name="statementManager" ref="statementManager"/>
</bean>
=== 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-08-29 06:56:46 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-10-10 15:35:01 +0000
@@ -229,17 +229,6 @@
<bean id="org.hisp.dhis.tallysheet.TallySheetPdfService"
class="org.hisp.dhis.tallysheet.DefaultTallySheetPdfService"/>
- <!-- AOP statement definitions --> <!-- TODO change to AOP 2.0 -->
-
- <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
- <property name="advice" ref="statementInterceptor"/>
- <property name="patterns">
- <list>
- <value>.*\.ChartService\.getJFreeChart.*</value>
- </list>
- </property>
- </bean>
-
<!-- Startup routine definitions -->
<bean id="org.hisp.dhis.startup.OpenHealthDataSourceWriter"
@@ -311,7 +300,7 @@
</property>
</bean>
- <!-- Deletion AOP definitions -->
+ <!-- AOP definitions -->
<aop:config>
@@ -322,6 +311,10 @@
<aop:before pointcut="execution( * org.hisp.dhis.document.DocumentService.delete*(..) )" method="intercept"/>
</aop:aspect>
+ <aop:aspect ref="statementInterceptor">
+ <aop:around pointcut="execution( * org.hisp.dhis.chart.ChartService.getJFreeChart(..) )" method="intercept"/>
+ </aop:aspect>
+
</aop:config>
-
+
</beans>
=== 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-07-07 10:27:18 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionInterceptor.java 2009-10-10 15:35:01 +0000
@@ -46,10 +46,6 @@
this.deletionManager = deletionManager;
}
- // ----------------------------------------------------------------------
- // MethodInterceptor Implementation
- // ----------------------------------------------------------------------
-
public void intercept( JoinPoint joinPoint )
{
if ( joinPoint.getArgs() != null && joinPoint.getArgs().length > 0 )
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java 2009-09-25 21:45:01 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java 2009-10-10 15:35:01 +0000
@@ -93,13 +93,6 @@
this.organisationUnitService = organisationUnitService;
}
- private StatementManager statementManager;
-
- public void setStatementManager( StatementManager statementManager )
- {
- this.statementManager = statementManager;
- }
-
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -169,8 +162,6 @@
sources = organisationUnits;
}
- statementManager.initialise();
-
if ( validationRuleGroupId == -1 )
{
log.info( "Validating all rules" );
@@ -188,8 +179,6 @@
format.parseDate( startDate ), format.parseDate( endDate ), sources, group ) );
}
- statementManager.destroy();
-
Collections.sort( validationResults, new ValidationResultComparator() );
SessionUtils.setSessionVar( KEY_VALIDATIONRESULT, validationResults );
=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2009-10-10 14:26:24 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml 2009-10-10 15:35:01 +0000
@@ -201,9 +201,6 @@
<property name="organisationUnitService">
<ref bean="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
</property>
- <property name="statementManager">
- <ref bean="statementManager"/>
- </property>
</bean>
<bean id="org.hisp.dhis.validationrule.action.GetValidationResultDetailsAction"