001package io.dinject;
002
003import java.lang.annotation.ElementType;
004import java.lang.annotation.Retention;
005import java.lang.annotation.RetentionPolicy;
006import java.lang.annotation.Target;
007
008/**
009 * Marks methods on a <code>@Factory</code> bean that create dependencies.
010 * <p>
011 *   See {@link Factory}.
012 * </p>
013 *
014 * <pre>{@code
015 *
016 * @Factory
017 * class Configuration {
018 *
019 *   private final StartConfig startConfig;
020 *
021 *   @Inject
022 *   Configuration(StartConfig startConfig) {
023 *     this.startConfig = startConfig;
024 *   }
025 *
026 *   @Bean
027 *   Foo buildFoo() {
028 *     ...
029 *     return new Foo(...);
030 *   }
031 *
032 *   @Bean
033 *   Bar buildBar(Foo foo, Bazz bazz) {
034 *     ...
035 *     return new Bar(...);
036 *   }
037 * }
038 * }</pre>
039 */
040@Target(ElementType.METHOD)
041@Retention(RetentionPolicy.RUNTIME)
042public @interface Bean {
043
044  /**
045   * Specify a method to be treated like a <code>@PostConstruct</code>
046   */
047  String initMethod() default "";
048
049  /**
050   * Specify a method to be treated like a <code>@PreDestroy</code>
051   */
052  String destroyMethod() default "";
053}