Bonjour,
J’essaie de déclarer des aspects avec des annotations "AspectJ". J’ai utilisé un greffon "Before" pour faire la journalisation.
Voila mon fichier "Beans.xml" (Conteneur Ioc):
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
<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
<a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a>
<a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a>
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
	<aop:aspectj-autoproxy />
	<bean id="arithmeticCalculator"
		class="com.apress.springrecipes.aspectj.ArithmeticCalculatorImpl" />
	<bean class="com.apress.springrecipes.aspectj.CalculatorLoggingAspect" />
</beans>

Voici mon greffon "Before":
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
@Aspect
public class CalculatorLoggingAspect {
	private Log log = LogFactory.getLog(this.getClass());
 
	@Before("execution(* ArithmeticCalculator.add(..))")
	public void logBefore() {
		log.info("Début de la méthode add()");
                System.out.println("Acces à la méthode ! ");
	}
}

Ma classe de test :
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class Test {
 
	public Test() {
		m();
	}
 
	public void m() {
 
		ApplicationContext context = new ClassPathXmlApplicationContext(
				"beans.xml");
		ArithmeticCalculator arithmeticCalculator = (ArithmeticCalculator) context
				.getBean("arithmeticCalculator");
		arithmeticCalculator.add(1, 2);
		arithmeticCalculator.sub(4, 3);
		arithmeticCalculator.mul(2, 3);
 
	}
 
	public static void main(String[] args) {
		new Test();
	}
 
}
Mais ce que le programme m'affiche :
1.0 + 2.0 = 3.0
4.0 - 3.0 = 1.0
2.0 * 3.0 = 6.0
Sans les informations de journalisation ......pourquoi ?