JBoss Community

Binding annotated methods and session bean methods

created by Marco Strauch in JBoss AOP Development - View the full discussion

Hello,

 

I have 2 little problems using JBoss AOP within JBoss 5.1.

 

  1. I have annotated methods and I want to create bindings using AOP (e.g. <bind pointcut="execution(* *->@mstrauch.test.aop.common.MyAnnotation(..))"> .... ). But the aspects are never called. When I bind the method directly without using the annotation it works (e.g. <bind pointcut="execution(* mstrauch.test.aop.common.CommonTest->*(..))"> ...).
  2. The second problem is, that I can't bind methods in session beans (e.g. <bind pointcut="execution(* mstrauch.test.aop.TestSessionBean->*(..))">...).

 

I have follow project structure:

 

aoptest.ear

     | -- lib

           | -- common.jar

     | -- META-INF

           | -- application.xml

           | -- jboss-app.xml

     | -- aspects.aop

     | -- ejb.jar

 

For testing I tried XML Bindings (MyAspect.class) and Annotation Bindings (MyAnnotationAspect.class). I also put my annoation (MyAnnotation.class, MyAnnotation2.class, MyAnnotation3.class) once in the common.jar, aspects.aop and ejb.jar. But nothing works.

 

I don't know what is wrong. Maybe somebody can help me.

 

I attached a complete example with all kinds of bindings. The sample works fine in JBoss 4.3 but not in JBoss 5.1. Below I copied the log output of both JBoss servers. It should be the same but it isn't.

 

To run the sample, just deploy the exploded archive "aoptest.ear" in JBoss and run the test Method via the JMX-Console (mst.test.aop:service=TestMBean)

 

Log-Output JBoss 5.1 (JBoss AOP 2.1.8.GA - Version JBoss Aspect Library: 1.3)

 

08:53:10,383 INFO  [TestClass] [testAnnot01] --> Called Test 01
08:53:10,383 INFO  [TestClass] [testAnnot02] --> Called Test 02
08:53:10,383 INFO  [TestClass] [testAnnot03] --> Called Test 03
08:53:10,440 INFO  [MyAspect] <init>
08:53:10,451 INFO  [MyAnnoatedAspect] <init>
08:53:10,454 INFO  [MyAspect] [injectTest11 --> test11]
08:53:10,454 INFO  [MyAnnoatedAspect] [injectTest11 --> test11]
08:53:10,462 INFO  [TestClass] [test11] --> Called Test 11
08:53:10,518 INFO  [MyAnnoatedAspect] <init>
08:53:10,518 INFO  [MyAspect] [injectCommonTest11 --> testCommon]
08:53:10,519 INFO  [MyAnnoatedAspect] [injectCommonTest11 --> testCommon]
08:53:10,527 INFO  [CommonTest] [testCommon]
08:53:10,569 INFO  [MyAnnoatedAspect] <init>
08:53:10,570 INFO  [MyAspect] [injectTestSessionBean --> ejbPostContruct]
08:53:10,570 INFO  [MyAnnoatedAspect] [injectTestSessionBean --> ejbPostContruct]
08:53:10,578 INFO  [TestSessionBean] [ejbPostContruct]
08:53:10,588 INFO  [TestSessionBean] [test01]

 

 

 

Log-Output JBoss 4.3 (JBoss AOP 1.5.6.GA - Version JBoss Aspect Library: 1.5)

 

08:38:29,432 INFO  [MyAspect] <init>
08:38:29,482 INFO  [MyAnnoatedAspect] <init>
08:38:29,483 INFO  [MyAspect] [injectTestAnnot01 --> testAnnot01]
08:38:29,483 INFO  [TestClass] [testAnnot01] --> Called Test 01
08:38:29,483 INFO  [MyAnnoatedAspect] <init>
08:38:29,484 INFO  [MyAspect] [injectTestAnnot02 --> testAnnot02]
08:38:29,484 INFO  [TestClass] [testAnnot02] --> Called Test 02
08:38:29,484 INFO  [MyAnnoatedAspect] <init>
08:38:29,484 INFO  [MyAspect] [injectTestAnnot03 --> testAnnot03]
08:38:29,484 INFO  [TestClass] [testAnnot03] --> Called Test 03
08:38:29,484 INFO  [MyAnnoatedAspect] <init>
08:38:29,485 INFO  [MyAnnoatedAspect] [injectTest11 --> test11]
08:38:29,486 INFO  [MyAspect] [injectTest11 --> test11]
08:38:29,486 INFO  [TestClass] [test11] --> Called Test 11
08:38:29,521 INFO  [MyAnnoatedAspect] <init>
08:38:29,522 INFO  [MyAnnoatedAspect] [injectCommonTest11 --> testCommon]
08:38:29,523 INFO  [MyAspect] [injectCommonTest11 --> testCommon]
08:38:29,524 INFO  [CommonTest] [testCommon]
08:38:29,587 INFO  [MyAnnoatedAspect] <init>
08:38:29,588 INFO  [MyAnnoatedAspect] [injectTestSessionBean --> ejbPostContruct]
08:38:29,589 INFO  [MyAspect] [injectTestSessionBean --> ejbPostContruct]
08:38:29,591 INFO  [TestSessionBean] [ejbPostContruct]
08:38:29,592 INFO  [MyAnnoatedAspect] [injectTestSessionBean --> test01]
08:38:29,592 INFO  [MyAspect] [injectTestSessionBean --> test01]
08:38:29,593 INFO  [TestSessionBean] [test01]

Reply to this message by going to Community

Start a new discussion in JBoss AOP Development at Community