1

Is it possible to scan annotations (Ex: javax.ejb.MessageDriven) from an external jar project.

I need to extract information from a given ear file . It is possible to do with EJB 2.x by parsing the deployment descriptors (ejb-jar.xml) but not quite for EJB 3.x

If possible, please give me an example.

Thank you very much for any reply.

Tran Ngu Dang
  • 2,540
  • 6
  • 29
  • 38
  • You mean all @interface definitions _or_ all annotated classes/functions/interfaces/etc.? – rlegendi Oct 04 '13 at 10:33
  • Yes. All annotated classes/functions/interfaces/etc ... if possible – Tran Ngu Dang Oct 04 '13 at 10:57
  • Oh ok. Then there are tons of APIs for that, take a look on this thread for example: http://stackoverflow.com/questions/259140/scanning-java-annotations-at-runtime – rlegendi Oct 04 '13 at 16:49

1 Answers1

0

Thanks, rlegendi

Look like Scannotation is a find solution for me. Here is the example:

URL[] urls = { new URL("jar:file:" + pathToJar+"!/") };
AnnotationDB db = new AnnotationDB(); 
db.scanArchives(urls);
System.out.println(db.getAnnotationIndex().get(javax.ejb.MessageDriven.class.getName()));
Tran Ngu Dang
  • 2,540
  • 6
  • 29
  • 38