java annotations: library to override annotations with xml files

后端 未结 4 1653
耶瑟儿~
耶瑟儿~ 2021-02-07 16:26

Java has annotations and that is good. However, some developers feel that it is best to annotate code with metadata using xml files - others prefer annotations but would use met

相关标签:
4条回答
  • 2021-02-07 16:59

    It's not exactly what you want, but the backport175 project has an implementation of annotations for Java versions before Java 5.

    It has some of the functionality you search in that it will read both its own style implementations and "real" annotations if they are present. Maybe this can be used as a starting point to build a more general framework.

    0 讨论(0)
  • 2021-02-07 17:10

    Use JAXB http://java.sun.com/developer/technicalArticles/WebServices/jaxb/ You would write the xsd for your metadata file, generate JAXB classes that can help you parse the xml files.

    0 讨论(0)
  • 2021-02-07 17:10

    There is not a standard way, but here are some Java frameworks who does it:

    • JPA - check ejb-3_0-fr-spec-persistence.pdf
    • Spring Framework
    • TestNG - as written above, though I think it focuses to much on the annotation side rather than the actual configuration he tries to achieve
    • Seam Framework
    0 讨论(0)
  • 2021-02-07 17:18

    I wrote the Annox library which does exactly what you need. With Annox you can read arbitrary annotations from XML.

    0 讨论(0)
提交回复
热议问题