java - How to auto-detect and wire classes which extends from specific type? -
spring supports auto-detect classes using annotation @component , <component-scan>, however, @component not @inherited.
i have tried create custom inheritable annotation:
@component @inherited @retention(runtime) public @interface myinheritablecomponent {} unfortunately, @myinheritablecomponent doesn't work.
any idea?
edit
file my/package/injectable.java:
@myinheritablecomponent public class injectable {} file my/package/foo.java:
public class foo extends injectable {} and component-scan defined as:
<context:component-scan base-package="my.package" /> in above example, foo not auto-detected.
my intention is, hide @component annotation specific classes.
due absence of @inherited on @component <context:component-scan> default filters doesn't respect @inherited on custom annotations.
however, if add custom filter annotation, work expected:
<context:component-scan base-package="my.package"> <context:include-filter type = "annotation" expression = "myinheritablecomponent" /> </context:component-scan>
Comments
Post a Comment