Playing around with and trying to re-implement an old blog entry of Jonas Boner.
Some resources:
to enable load time weaving with maven surefire plugin use the following:
<plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> <testFailureIgnore>true</testFailureIgnore> <forkMode>once</forkMode> <argLine> -javaagent:${user.home}/.m2/repository/org/aspectj/aspectjweaver/${aj.version}/aspectjweaver-${aj.version}.jar </argLine> <systemProperties> <property> <name>aj.weaving.verbose</name> <value>true</value> </property> </systemProperties> </configuration> </plugin>
"enable Around interception" in { val aspect = new Aspect("execution(* *.bar(..))") with LoggingInterceptor with TransactionInterceptor val foo = aspect.create[Foo](new FooImpl) foo.foo("foo") foo.bar("bar") }
"enable Before interception" in { val aspect = new Aspect("execution(* *.bar(..))") with InterceptBefore val foo = aspect.create[Foo](new FooImpl) foo.foo("foo") foo.bar("bar") }
"enable After interception" in { val aspect = new Aspect("execution(* *.bar(..))") with InterceptAfter val foo = aspect.create[Foo](new FooImpl) foo.foo("foo") foo.bar("bar") }