简体   繁体   English

从jar文件扫描注释

[英]Scan annotation from a jar file

Is it possible to scan annotations (Ex: javax.ejb.MessageDriven) from an external jar project. 是否可以从外部jar项目中扫描注释(例如:javax.ejb.MessageDriven)。

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 可以通过解析部署描述符(ejb-jar.xml)使用EJB 2.x,但对于EJB 3.x则不是

If possible, please give me an example. 如果可能的话,请给我一个例子。

Thank you very much for any reply. 非常感谢您的答复。

Thanks, rlegendi 谢谢,莱根迪

Look like Scannotation is a find solution for me. 看起来Scannotation是我的理想解决方案。 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()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM