-
-
Save rmannibucau/7ff2bea1e4ca1f3204a16e84afee5f87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@HandlesTypes(Foo.class) | |
public class FooStarter implements ServletContainerInitializer { | |
@Override | |
public void onStartup(final Set<Class<?>> set, final ServletContext servletContext) { | |
System.out.println(set.stream().map(Class::getName).collect(joining("\n", "\nClasses:\n\n", "\n\n"))); | |
if (set.stream() | |
.filter(it -> it.isAnnotationPresent(Foo.class)) | |
.count() != set.size()) { | |
throw new IllegalArgumentException("Invalid scanning"); | |
} | |
} | |
} | |
/* | |
with foo: | |
*/ | |
@Target({TYPE, FIELD}) | |
@Retention(RUNTIME) | |
public @interface Foo { | |
} | |
/** and beans */ | |
@Foo | |
public class OnClass { | |
} | |
public class OnField { | |
@Foo | |
private String name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment