From a9224ba3fe3bffaa90b2bcc8be5fa1a2e1df48d2 Mon Sep 17 00:00:00 2001 From: jmaupoux Date: Tue, 17 Jul 2012 21:28:41 +0200 Subject: [PATCH] #6 Adding property to mail.properties + AOP class Remain IHM adjustment --- .../src/main/resources/mail.properties | 2 + .../main/resources/conf-embedded.properties | 1 + ultimate-breakfast-domain/pom.xml | 37 +++++++++++++++++++ .../domain/aop/mail/MailEnableAspect.java | 24 ++++++++++++ .../main/resources/applicationContext-aop.xml | 14 +++++++ .../resources/applicationContext-domain.xml | 2 + 6 files changed, 80 insertions(+) create mode 100644 ultimate-breakfast-domain/src/main/java/fr/ultimate/breakfast/domain/aop/mail/MailEnableAspect.java create mode 100644 ultimate-breakfast-domain/src/main/resources/applicationContext-aop.xml diff --git a/ultimate-breakfast-classpath/src/main/resources/mail.properties b/ultimate-breakfast-classpath/src/main/resources/mail.properties index 1bce415..01cfb05 100644 --- a/ultimate-breakfast-classpath/src/main/resources/mail.properties +++ b/ultimate-breakfast-classpath/src/main/resources/mail.properties @@ -2,6 +2,8 @@ ### Mail configuration ### ########################## +#Should mail feature be enabled ? +mail.enabled=true # The mail server host mail.server.host=localhost # The mail server port diff --git a/ultimate-breakfast-common/src/main/resources/conf-embedded.properties b/ultimate-breakfast-common/src/main/resources/conf-embedded.properties index 6fc8973..9d3c479 100644 --- a/ultimate-breakfast-common/src/main/resources/conf-embedded.properties +++ b/ultimate-breakfast-common/src/main/resources/conf-embedded.properties @@ -17,6 +17,7 @@ application-log-level=ERROR log-home=./ # Mail configuration +mail.enabled=false mail.server.host=localhost mail.server.port=25 mail.from=noreply@ultimate-breakfast.fr diff --git a/ultimate-breakfast-domain/pom.xml b/ultimate-breakfast-domain/pom.xml index f986783..35eeafc 100644 --- a/ultimate-breakfast-domain/pom.xml +++ b/ultimate-breakfast-domain/pom.xml @@ -27,6 +27,43 @@ spring-security-core ${spring-security-version} + + + + org.springframework + org.springframework.asm + ${spring-version} + + + + org.springframework + org.springframework.aop + ${spring-version} + + + + org.springframework + org.springframework.aspects + ${spring-version} + + + + org.springframework + org.springframework.expression + ${spring-version} + + + + org.aspectj + aspectjrt + 1.6.11 + + + + org.aspectj + aspectjweaver + 1.6.11 + diff --git a/ultimate-breakfast-domain/src/main/java/fr/ultimate/breakfast/domain/aop/mail/MailEnableAspect.java b/ultimate-breakfast-domain/src/main/java/fr/ultimate/breakfast/domain/aop/mail/MailEnableAspect.java new file mode 100644 index 0000000..e065ed5 --- /dev/null +++ b/ultimate-breakfast-domain/src/main/java/fr/ultimate/breakfast/domain/aop/mail/MailEnableAspect.java @@ -0,0 +1,24 @@ +package fr.ultimate.breakfast.domain.aop.mail; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Aspect +@Component +public class MailEnableAspect +{ + @Value("${mail.enabled}") + private boolean mailEnabled; + + // @Around("execution(* *(..))") + @Around("execution(* fr.ultimate.breakfast.mail.service.UltimateBreakfastMailService.*(..))") + public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable + { + if (mailEnabled) { return joinPoint.proceed(); } + return null; + } + +} diff --git a/ultimate-breakfast-domain/src/main/resources/applicationContext-aop.xml b/ultimate-breakfast-domain/src/main/resources/applicationContext-aop.xml new file mode 100644 index 0000000..d5018cd --- /dev/null +++ b/ultimate-breakfast-domain/src/main/resources/applicationContext-aop.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/ultimate-breakfast-domain/src/main/resources/applicationContext-domain.xml b/ultimate-breakfast-domain/src/main/resources/applicationContext-domain.xml index ae33fec..3355503 100644 --- a/ultimate-breakfast-domain/src/main/resources/applicationContext-domain.xml +++ b/ultimate-breakfast-domain/src/main/resources/applicationContext-domain.xml @@ -23,4 +23,6 @@ + +