Skip to content

Commit

Permalink
#6 Adding property to mail.properties + AOP class
Browse files Browse the repository at this point in the history
Remain IHM adjustment
  • Loading branch information
jmaupoux authored and jmaupoux committed Jul 17, 2012
1 parent 8c11826 commit a9224ba
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions ultimate-breakfast-domain/pom.xml
Expand Up @@ -27,6 +27,43 @@
<artifactId>spring-security-core</artifactId>
<version>${spring-security-version}</version>
</dependency>

<!-- AOP -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.asm</artifactId>
<version>${spring-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.aop</artifactId>
<version>${spring-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.aspects</artifactId>
<version>${spring-version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.expression</artifactId>
<version>${spring-version}</version>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.11</version>
</dependency>

<!-- Dependances pour Unitils -->
<dependency>
Expand Down
@@ -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;
}

}
@@ -0,0 +1,14 @@
<?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:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">

<aop:aspectj-autoproxy/>

</beans>
Expand Up @@ -23,4 +23,6 @@

<!-- End Security beans -->

<import resource="classpath*:applicationContext-aop.xml"/>

</beans>

0 comments on commit a9224ba

Please sign in to comment.