Browse Source

Constrain targets for @Filter declaration

For clarity, add @Target({}) to definition of @Filter, constraining it
to complex annotation composition only; i.e. it cannot be placed on
any element, only within annotations, e.g.

    @ComponentScan(includeFilters=@Filter(...))

is legal, while

    @Filter
    public class MyType { }

is not.

Also, widen @Retention from SOURCE to RUNTIME, even though it is not
technically necessary, as all parsing of @Filter annotations happens via
ASM, i.e. at the source level.  This change is made primarily for
consistency (@ComponentScan's Retention is RUNTIME) and in avoidance of
potential confusion or surprise on the part of those casually browsing
the code.
pull/7/head
Chris Beams 15 years ago
parent
commit
df7bda5637
  1. 3
      org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScan.java

3
org.springframework.context/src/main/java/org/springframework/context/annotation/ComponentScan.java

@ -128,7 +128,8 @@ public @interface ComponentScan { @@ -128,7 +128,8 @@ public @interface ComponentScan {
* Declares the type filter to be used as an {@linkplain ComponentScan#includeFilters()
* include filter} or {@linkplain ComponentScan#includeFilters() exclude filter}.
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.RUNTIME)
@Target({})
@interface Filter {
/**
* The type of filter to use.

Loading…
Cancel
Save