Giter Site home page Giter Site logo

aptspring's Introduction

Status

Build Status Codacy Badge codebeat badge Maven Site Maven Central codecov

About AptSpring

This project checks that spring beans in your project adhere to certain properties when you add the @Verified annotation to your @Component or @Bean lite class.

Duplicate bean name and cycle free

Some of those properties include all beans being explicitly named, all names are unique, and all autowiring includes names via @Qualified annotations. Cycles are prevented as well as duplicate bean names.

Type Safety

Return types of @Bean methods are verified against @Autowired injection points.

Disallows "Interesting" practices

No autowiring in to @Bean lite instances. No non literal static member variables on @Bean lite instances. No autowiring an unknown list of instances by type... instead encourages the construction of named lists. No @ComponentScan, instead use @Import to allow the annotation processor to analyze your graph.

Safety

By defining the spring graph in a type safe and introspectable manner the relevant parts of a spring graph are encoded in the java type system. Your code will be more readable, more refactorable, and less error prone even if your app has to scale to thousands of beans.

Quick Start: Get the goodness.

In your pom file, include the version of spring you wish to use (3+ should be fine)

Include this dependency:

    <dependency>
        <groupId>com.salesforce.aptspring</groupId>
        <artifactId>AptSpringAPI</artifactId>
        <version>${apt.spring.version}</version>
    </dependency>

Include this takari-lifecycle configuration if you are using takari -- hint: you should be.

    <plugin>
        <groupId>io.takari.maven.plugins</groupId>
        <artifactId>takari-lifecycle-plugin</artifactId>
        <configuration>
            <processorpath>
                <dependency>
                    <groupId>com.salesforce.aptspring</groupId>
                    <artifactId>AptSpringProcessor</artifactId>
                    <version>${apt.spring.version}</version>
                    <scope>provided</scope>
                </dependency>
            </processorpath>
        </configuration>
    </plugin>

Include the @Verified annotation on your spring classes with @Bean methods.

Use the takari lifecycle and takari-m2e support for best performance and file handling. You can also configure the APT manually in eclipse if you are not using m2e, but eclipse's default APT handling will not support referencing a @Bean lite class in another eclipse project/maven module. You would be limited to having on one eclipse project.

The error messages will help clean up your code and keep it clean.

A full list of checks can be found on the javadoc of the @Verified annotation class.

In short, no cycles, fully defined decoupled spring graphs, with clear entry point for all system properties.

No guarantee you wont have runtime problems.

The guarantee is that those problems will be a lot simpler than the one you would otherwise get out of spring.

Enforcement

Please see @Verified Annotation for a full list of the constraints the AptSpringProcessor enforces, and what it may enforce in the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.