190 CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES
CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES 191 Tip If you declare your own annotations, keep in mind the pattern shown here. Repeated annotations are not allowed, so they must be grouped together into a single annotation. The javax.annotation.processing Package The annotations found in the javax.annotation.processing package are used by the capabilities added with JSR 269 for annotation processing. There are three annotations there: SupportedAnnotationTypes, SupportedOptions, and SupportedSourceVersion. Each of these will be described later in the chapter, in the Annotation Processing section. The javax.management Package The two annotations found in the javax.management package are DescriptorKey and MXBean. If you are familiar with the Java Management Extensions, their usage will prove helpful. The DescriptorKey annotation is for describing annotation elements related to a field. For an attribute, operation, or construction, you can add descriptors such that when the resulting descriptor is created, you can configure its values. See the javadoc for the DescriptorKey annotation for more information about auto-conversion of annotation elements, such as rules for how a primitive becomes an object. The MXBean annotation is used to explicitly tag an interface as an MXBean interface or not. If the interface name ends in MXBean, it is an MXBean interface by default. If it doesn t, then the interface isn t an MXBean-related interface. The @MXBean annotation allows you to tag an interface as an MXBean if it doesn t end with MXBean, and allows you to reject the automatic association if you don t want it. For the positive case, the following three declarations in Listing 10-5 are defined to be MXBean interfaces, assuming proper imports. Listing 10-5. @MXBean Annotation Usage // Default naming public interface MyMXBean { } @MXBean public interface MyInterface1 { } @MXBean(true) public interface MyInterface2 { }
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services