Annotation Interface EachBean


@Documented @Retention(RUNTIME) @Target({METHOD,TYPE}) @Singleton public @interface EachBean

This annotation allows driving the production of Bean definitions from presence of other bean definitions. Typically used in conjunction with EachProperty

For example:

 @EachProperty("foo.bar")
  public class ExampleConfiguration {
  }

In the above example a new ExampleConfiguration bean will be created for each item under the foo.bar key in application configuration

One can then drive the configuration of other beans with the same annotation:

 @EachBean(ExampleConfiguration)
 @Singleton
  public class ExampleBean {
     ExampleBean(ExampleConfiguration config) {
         ...
     }
  }

EachBean requires that the parent bean has a Named qualifier, since the qualifier is inherited by each bean created by EachBean.

Since:
1.0
Author:
Graeme Rocher
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    The generics remapping configuration.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Enable for a new bean definition to inherit the generics from the driven bean definitions.
  • Element Details

    • value

      Class<?> value
      Returns:
      The bean type that this bean is driven by
    • remapGenerics

      EachBean.RemapGeneric[] remapGenerics
      Enable for a new bean definition to inherit the generics from the driven bean definitions.
      Returns:
      The remap configuration
      Since:
      4.6
      Default:
      {}