01: package javax.xml.bind.annotation;
02:
03: import javax.xml.bind.JAXBContext;
04: import java.lang.annotation.ElementType;
05: import java.lang.annotation.Retention;
06: import static java.lang.annotation.RetentionPolicy.RUNTIME;
07: import java.lang.annotation.Target;
08:
09: /**
10: * Instructs JAXB to also bind other classes when binding this class.
11: *
12: * <p>
13: * Java makes it impractical/impossible to list all sub-classes of
14: * a given class. This often gets in a way of JAXB users, as it JAXB
15: * cannot automatically list up the classes that need to be known
16: * to {@link JAXBContext}.
17: *
18: * <p>
19: * For example, with the following class definitions:
20: *
21: * <pre>
22: * class Animal {}
23: * class Dog extends Animal {}
24: * class Cat extends Animal {}
25: * </pre>
26: *
27: * <p>
28: * The user would be required to create {@link JAXBContext} as
29: * <tt>JAXBContext.newInstance(Dog.class,Cat.class)</tt>
30: * (<tt>Animal</tt> will be automatically picked up since <tt>Dog</tt>
31: * and <tt>Cat</tt> refers to it.)
32: *
33: * <p>
34: * {@link XmlSeeAlso} annotation would allow you to write:
35: * <pre>
36: * @XmlSeeAlso({Dog.class,Cat.class})
37: * class Animal {}
38: * class Dog extends Animal {}
39: * class Cat extends Animal {}
40: * </pre>
41: *
42: * <p>
43: * This would allow you to do <tt>JAXBContext.newInstance(Animal.class)</tt>.
44: * By the help of this annotation, JAXB implementations will be able to
45: * correctly bind <tt>Dog</tt> and <tt>Cat</tt>.
46: *
47: * @author Kohsuke Kawaguchi
48: * @since JAXB2.1
49: * @version $Revision: 1.1 $
50: */
51: @Target({ElementType.TYPE})
52: @Retention(RUNTIME)
53: public @interface XmlSeeAlso {
54: Class[] value();
55: }
|