001package io.avaje.inject;
002
003import java.lang.annotation.ElementType;
004import java.lang.annotation.Retention;
005import java.lang.annotation.RetentionPolicy;
006import java.lang.annotation.Target;
007
008/**
009 * Identify a bean as component with singleton scope that avaje-inject will use.
010 * <p>
011 * This is an alternative to using the standard <code>@Singleton</code> annotation.
012 * We generally use <code>@Component</code> when we:
013 * <ul>
014 *   <li>Want to use avaje-inject in a project that has some other library using <code>@Singleton</code></li>
015 *   <li>Want to support BOTH <code>javax.inject</code> and <code>jakarta.inject</code></li>
016 * </ul>
017 *
018 * <h3>Example</h3>
019 * <pre>{@code
020 *
021 * @Component
022 * class MyEmailSender implements EmailSender {
023 *
024 *   ...
025 * }
026 * }</pre>
027 *
028 * <h3>Ignoring <em>@Singleton</em></h3>
029 * <p>
030 * Set {@link InjectModule#ignoreSingleton()} <code>true</code> to get avaje-inject to ignore
031 * classes annotated with <code>@Singleton</code>. Typically, we want another DI library to use
032 * those classes and want avaje-inject to co-exist independently.
033 * <p>
034 *
035 * <pre>{@code
036 *
037 *   @InjectModule(name = "coffee", ignoreSingleton = true)
038 *   package coffee;
039 *
040 *   import io.avaje.inject.InjectModule;
041 *
042 * }</pre>
043 *
044 * @see InjectModule#ignoreSingleton()
045 */
046@Target(ElementType.TYPE)
047@Retention(RetentionPolicy.RUNTIME)
048public @interface Component {
049}