In my early code of SQLWarp, I created the annotation ConnectionInfo to be annotated on an interface, and I need it for an interface, not a class.
@Retention(RUNTIME)
@Inherited
public @interface ConnectionInfo {
public String driver();
public String url();
public String userID() default "";
public String password() default "";
}
The JDK doc says that @Inherited won't work with an Interface, so this is my work around to get annotation from the class that implements the interface which is annotated by @ConnectionInfo.
ConnectionInfo c = (ConnectionInfo)obj
.getClass()
.getInterfaces()[0]
.getAnnotation(ConnectionInfo.class);
No comments:
Post a Comment