Skip to content

Instantly share code, notes, and snippets.

@ricdex
Last active September 19, 2015 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricdex/8c7cda76292c184394cf to your computer and use it in GitHub Desktop.
Save ricdex/8c7cda76292c184394cf to your computer and use it in GitHub Desktop.
encontrar clases por anotaciones
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Execute {
String target() default "";
}
//----------------
Reflections reflections = new Reflections("path.donde.estan.las.clases.con.esa.anotacion");
Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(Execute.class);
//--------------------
for (Class<?> taskClass : annotated) {
Execute task = taskClass.getAnnotation(Execute.class);
String target = task.target();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment