Skip to content

FaKod/AOP-for-Scala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Using AspectJ in Scala

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published