001package io.avaje.inject;
002
003import java.lang.annotation.Retention;
004import java.lang.annotation.Target;
005
006import static java.lang.annotation.ElementType.*;
007import static java.lang.annotation.RetentionPolicy.RUNTIME;
008
009/**
010 * Expresses a requirement for a bean to be wired/registered into the {@link BeanScope}.
011 *
012 * <pre>{@code
013 * @Factory
014 * public class MyAutoConfiguration {
015 *
016 *   @Bean
017 *   @Profile("test")
018 *   public MyService myService() {
019 *       ...
020 *   }
021 *
022 * }
023 *
024 * }</pre>
025 *
026 * <p>In the sample above, the MyService bean will get wired only if <code>avaje.profiles</code> is
027 * set to "test" in the {@link io.avaje.inject.spi.PropertyRequiresPlugin}.
028 *
029 * <p>Avaje Config provides an implementation and if it is included in the classpath then Avaje
030 * Config will be used to test the property conditions.
031 *
032 * <p>If no PropertyRequiresPlugin is found then the default implementation is used which uses
033 * {@link System#getProperty(String)} and {@link System#getenv(String)}.
034 */
035@Retention(RUNTIME)
036@Target({TYPE, METHOD, ANNOTATION_TYPE})
037public @interface Profile {
038
039  /**
040   * Expresses that any of the given profiles must be set for the bean to load.
041   *
042   * @return the property to check
043   */
044  String[] value() default {};
045
046  /**
047   * Expresses that all of the given profiles must be set for the bean to load.
048   *
049   * @return the property to check
050   */
051  String[] all() default {};
052
053  /**
054   * Expresses that none of the given profiles must be set for the bean to load.
055   *
056   * @return the properties to check
057   */
058  String[] none() default {};
059}