EnableDynamicClients.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package cn.nosum.support.annotation;
  2. import java.lang.annotation.Documented;
  3. import java.lang.annotation.ElementType;
  4. import java.lang.annotation.Retention;
  5. import java.lang.annotation.RetentionPolicy;
  6. import java.lang.annotation.Target;
  7. import cn.nosum.support.config.DynamicClientRegistrar;
  8. import org.springframework.context.annotation.Import;
  9. /**
  10. * Scans for interfaces that declare they are feign clients (via
  11. * {@link DynamicClient} <code>@FeignClient</code>).
  12. * Configures component scanning directives for use with
  13. * {@link org.springframework.context.annotation.Configuration}
  14. * <code>@Configuration</code> classes.
  15. *
  16. * @author Spencer Gibb
  17. * @author Dave Syer
  18. * @since 1.0
  19. */
  20. @Documented
  21. @Target(ElementType.TYPE)
  22. @Retention(RetentionPolicy.RUNTIME)
  23. @Import(DynamicClientRegistrar.class)
  24. public @interface EnableDynamicClients {
  25. /**
  26. * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation
  27. * declarations e.g.: {@code @ComponentScan("org.my.pkg")} instead of
  28. * {@code @ComponentScan(basePackages="org.my.pkg")}.
  29. * @return the array of 'basePackages'.
  30. */
  31. String[] value() default {};
  32. /**
  33. * Base packages to scan for annotated components.
  34. * <p>
  35. * {@link #value()} is an alias for (and mutually exclusive with) this attribute.
  36. * <p>
  37. * Use {@link #basePackageClasses()} for a type-safe alternative to String-based
  38. * package names.
  39. * @return the array of 'basePackages'.
  40. */
  41. String[] basePackages() default {};
  42. /**
  43. * Type-safe alternative to {@link #basePackages()} for specifying the packages to
  44. * scan for annotated components. The package of each class specified will be scanned.
  45. * <p>
  46. * Consider creating a special no-op marker class or interface in each package that
  47. * serves no purpose other than being referenced by this attribute.
  48. * @return the array of 'basePackageClasses'.
  49. */
  50. Class<?>[] basePackageClasses() default {};
  51. }