1. import javax.inject.Singleton
    2. import java.lang.annotation.Documented
    3. import java.lang.annotation.Retention
    4. import static java.lang.annotation.RetentionPolicy.RUNTIME
    5. @Requires(classes = Car.class ) (1)
    6. @Singleton (2)
    7. @Retention(RUNTIME)
    8. @interface Driver {
    9. }

    In the example above the @Singleton annotation is applied to the @Driver annotation which results in every class that is annotated with @Driver being regarded as singleton.

    Declaring Another Scope

    1. class Foo {}

    Using @DefaultScope

    1. @Requires(classes = Car.class )
    2. @DefaultScope(Singleton.class) (1)
    3. @Documented
    4. @Retention(RUNTIME)
    5. @interface Driver {
    6. }
    1 is used to declare which scope to be used if none is present