Sciurus

Sciurus Sciurus is a collection of useful aspects to

  • monitor execution runtimes of methods
  • lock method executions
  • cache method results
  • retry method executions on exceptions

General Usage

You need to include Sciurus as dependeny and declare it as an aspect library in the aspectj-maven-plugin.

  1. Include Sciurus as dependency

    <dependency>
        <groupId>io.mcarle</groupId>
        <artifactId>sciurus</artifactId>
        <version>1.1.0</version>
    </dependency>
    
  2. Include aspectj-maven-plugin and define Sciurus as aspectLibrary

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.11</version>
        <executions>
            <execution>
                <goals>
                    <goal>compile</goal>
                    <goal>test-compile</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <complianceLevel>${maven.compiler.source}</complianceLevel>
            <source>${maven.compiler.source}</source>
            <target>${maven.compiler.target}</target>
            <aspectLibraries>
                <aspectLibrary>
                    <groupId>io.mcarle</groupId>
                    <artifactId>sciurus</artifactId>
                </aspectLibrary>
            </aspectLibraries>
        </configuration>
    </plugin>
    

Use Case Examples

There are a number of possible use cases for each aspect.

@Monitor

  • Notify a monitoring application
  • Find bottlenecks
  • Test the speed of a new software version before deploying it in production
  • Store execution times (e.g. in a database) and
    • see how they evolve over time
    • see runaway values
    • monitor them through a MBean

@Cache

  • Caching (surprise!)
  • Facade for various caches which can be exchanged with merely little code changes

@Lock

  • Prevent multiple storing (e.g. in databases)
  • Prevent multiple execution of long running or high cpu consuming methods (e.g. in combination with @Cache)

@Retry

  • Retry storing entities into the database due to locking exceptions
  • Retry a failed connection to a web service
  • Retry a method which may lead to some random or temporary incidents

More information and example

https://github.com/mcarleio/sciurus

Marcel Carlé
Marcel Carlé
Software Developer

My developing interests include cloud computing, DDD, event sourcing, and serverless architectures.