Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

Annotations @ Runtime

for an annotation to be accessible at runtime it has to be annotated as follows
@Retention(RUNTIME)
How to access annotations
Method[] methods = cls.getMethods();
for(int i=0;i<methods.length';i++){
Annotation[] annos = methods[i].getAnnotations();
// the annos[] can be type casted to the annotation and then used.
}

No comments:

Post a Comment

Search 24 Bytes