Spring Annotation and Qualifier Based Scan
Is there a way in spring to apply qualifiers while performing an annotation based component scan?
I have a couple of classes annotated with my custom annotation, MyAnnotation. 
@MyAnnotation
public class ClassOne {
}

@MyAnnotation
public class ClassTwo {
}

@Configuration
@ComponentScan(basePackages = { "common" }, useDefaultFilters = false, includeFilters = { @ComponentScan.Filter(type = FilterType.ANNOTATION, value = MyAnnotation.class) })
public class ClassProvider {
}

What I want to do is, scan a subset of the classes with this annotation, selectively based on some condition say some input from the user.
Is it possible to say specify a qualifier along with the annotation and also specify it with the component scan filter, something like this -
@MyAnnotation (qualifier = "one")
public class ClassOne {
}

@MyAnnotation (qualifier = "two")
public class ClassTwo {
}

@Configuration
@ComponentScan(basePackages = { "common" }, useDefaultFilters = false, includeFilters = { @ComponentScan.Filter(type = FilterType.ANNOTATION, value = MyAnnotation.class, qualifier = "one") })
public class ClassProvider {
}

so that only ClassOne gets scanned?

You can implement a custom TypeFilter so that your @ComponentScan can look like:
@ComponentScan(includeFilters = { @ComponentScan.Filter(type = FilterType.CUSTOM, value = MyAnnotation.class) })

And the TypeFilter implementation:
public class TypeOneFilter implements TypeFilter {

    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        final AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();

        if (annotationMetadata.hasAnnotation(MyAnnotation.class.getName())) {
            final Map<String, Object> attributes = annotationMetadata.getAnnotationAttributes(MyAnnotation.class.getName());

            return "one".equals(attributes.get("qualifier"));
        }

        return false;
    }

}


Thanks for your answer, I will give it a try; I think it is what I was looking for. I would further like to set the qualifier value on the annotation dynamically, but I think it is more of a standard java annotations question than a spring specific one.

Cool, but are you sure that you don't want to use Spring profile support?

I haven't really used profiles before but that option looks even better. I probably won't need to implement a custom TypeFilter if I used that. Am I correct in saying that it doesn't need to be accompanied with other annotations, like Configuration or Component; and that the component scanner will not scan a class unless any specified profile is active?

@ZoranRegvart do we need write in @ComponentScan.Filter(value=TypeOneFilter.class or @ComponentScan.Filter(value=MyAnnotation.class in your example ?? Looks like mistake, if not where should i create or declare   TypeOneFilter to know the spring context
