Strix

Strix

Strix is a lightweight and simple transaction library using aspects to do the magic.

Simple Usage

In short terms you have to:

  1. Include strix as dependency

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

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.10</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>strix</artifactId>
                </aspectLibrary>
            </aspectLibraries>
        </configuration>
    </plugin>
    
  3. Start strix before you call any transactional methods

    import io.mcarle.strix.Strix;
    import org.glassfish.jersey.servlet.ServletContainer;
    
    public class ExampleServlet extends ServletContainer {
       
        @Override
        public void destroy() {
            super.destroy();
            Strix.shutdown();
        }
       
        @Override
        public void init() throws ServletException {
            Strix.startup();
            super.init();
        }
    }
    
  4. Annotate your classes or methods, which should be transactional with strix’s @Transactional-Annotation like

    import io.mcarle.strix.annotation.Transactional;
    import static io.mcarle.strix.Strix.em;
    
    @Transactional
    public class ExampleManager {
       public <T> T find(Class<T> entityClass, Long id) {
            return em().find(entityClass, id);
       }
    }
    

More information and example

https://github.com/mcarleio/strix

Marcel Carlé
Marcel Carlé
Software Developer

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