Using AspectJ in Scala
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
README.textile
pom.xml

README.textile

Playing around with and trying to re-implement an old blog entry of Jonas Boner.

AspectJ Load Time Weaving

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>

Aspects with Stackable Traits (current look)

Around Interception

"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")

    }

Before Interception

    "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")
    }

After Interception

    "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")
    }