Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is possible to inject annotations at Runtime.</p> <p>A guy from our company tried this on classes, see that code:</p> <p><a href="https://github.com/OlivierCroisier/AnnotationInjector/blob/master/src/main/java/net/thecodersbreakfast/annotationinjector/AnnotationInjector.java" rel="nofollow">https://github.com/OlivierCroisier/AnnotationInjector/blob/master/src/main/java/net/thecodersbreakfast/annotationinjector/AnnotationInjector.java</a></p> <p>Note that it only injects annotations on a class. He sais it's harder to do the same with methods or constructor. I'm not sure to understand all he sais in his french slides (http://www.slideshare.net/Zenika/annotations-paris-jug at the end) but it seems that what you want could be possible, but your annotations will be only on the instances in which you modify them, not all the instances (but this is perhaps what you want?)</p> <p>However he didn't tell how to get the annotations map on a field or a method of a particular instance and i don't see how to get it. Note that many JDK methods returns copied values, so you cannot just modify the array of getAnnotations(), it won't have any effect... (but it seems necessary to initialize the annotations field on the class, cf his code)</p> <p>Good luck, perhaps try to contact him.</p> <p>Edit: you could simply make 2 different classes and choose the right one to use at runtime? this seems easier for me if you can't use MOXy. But i think you won't be able to override a method with/without xmltransient because they is no @Inherited on that JAXB annotation it seems (but i could be wrong, never tested annotation inheritence yet...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload