package org.springframework.cloud.config.java; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; /** * Add this annotation to an @{@link Configuration} class to have the services bound * to the app scanned and bean for each one added to the application context: * * <pre class="code"> * @Configuration * @ServiceScan * public class CloudConfiguration { * // may (optionally) extend AbstractCloudConfiguration * } * </pre> * * This annotation is similar to @ComponentScan in Spring, which scans for classes * with the @Component classes and creates a bean for each. @ServiceScan, in the same * spirit, scans services bound to the app and creates a bean for each. * * Upon service scanning, if there is a unique bean for service type, you can inject it * using the following code (shows Redis, but the same scheme works for all services): * <pre> * @Autowired RedisConnectionFactory redisConnectionFactory; * </pre> * * If there are more than one services of a type, you can use the @Qualifier annotation * as in the following code: * <pre> * @Autowired @Qualifier("service-name1") RedisConnectionFactory redisConnectionFactory; * @Autowired @Qualifier("service-name2") RedisConnectionFactory redisConnectionFactory; * </pre> * * @author Ramnivas Laddad * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Documented @Import(ServiceScanConfiguration.class) public @interface ServiceScan { }