Annotation Type RequiresProperty


Expresses a requirement for a bean to be wired/registered into the BeanScope.


   @Factory
   public class MyAutoConfiguration {

     @Bean
     @RequiresProperty("use.service")
     public MyService myService() {
         ...
     }

   }

 

In the sample above the MyService bean will get wired only if use.service is set in Java system properties / Avaje Config.

PropertyRequiresPlugin is used to test the property conditions and is loaded via ServiceLoader.

Avaje Config provides an implementation and if it is included in the classpath then Avaje Config will be used to test the property conditions.

If no PropertyRequiresPlugin is found then the default implementation is used which uses System.getProperty(String) and System.getenv(String).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Used in combination with value() to express the required value of the property.
    Expresses that the bean or configuration will only be registered if the given properties are missing.
    Constraint a property to not equal the given value.
    Expresses that the given property should be set for the bean to load.
  • Element Details

    • value

      Expresses that the given property should be set for the bean to load.
      Returns:
      the property to check
      Default:
      ""
    • missing

      Expresses that the bean or configuration will only be registered if the given properties are missing.
      Returns:
      the properties to check
      Default:
      {}
    • equalTo

      Used in combination with value() to express the required value of the property.
      Returns:
      the value the property should be
      Default:
      ""
    • notEqualTo

      Constraint a property to not equal the given value.
      Returns:
      the value the property should not be
      Default:
      ""