里面放着两个注解类:InterfaceAudience和InterfaceStability。
InterfaceAudience 类包含三个注解类型,用来被说明被他们注解的类型的潜在的使用范围(audience)。
@InterfaceAudience.Public: 对所有工程和应用可用 @InterfaceAudience.LimitedPrivate: 仅限于某些特定工程,如Comomn,HDFS等 @InterfaceAudience.Private: 仅限于HadoopInterfaceStability 类包含三个注解,用于说明被他们注解的类型的稳定性。 @InterfaceStability.Stable: 主版本是稳定的,不同主版本间可能不兼容 @InterfaceStability.Evolving: 不断变化,不同次版本间可能不兼容 @InterfaceStability.Unstable: 没有任何可靠性和健壮性保证
1 /** 2 *注释省略... 3 **/ 4 package org.apache.hadoop.classification; 5 6 import java.lang.annotation.Documented; 7 //只引入了JDK的注释包中的Documented接口,即没有其他hadoop类级联 8 /** 9 * Annotation to inform users of a package, class or method's intended audience.10 */11 //这里面也是注解类,用来向用户表明一个包、类或者方法的潜在的使用范围12 @InterfaceAudience.Public13 @InterfaceStability.Evolving14 //自注解(自己起的名字)。第一个注解就用到了这个类中的第一个内部注解。第二个是同包下的第二个类(不解释)。15 public class InterfaceAudience {16 /**17 * Intended for use by any project or application.18 */19 @Documented public @interface Public {};20 //@Doccumented 是元注解(就是注解注解的注解),作用是指示某一类型的注释将通过 javadoc 和类似的默认工具进行文档化。21 //这个注解是标识适用任何工程或者应用22 /**23 * Intended only for the project(s) specified in the annotation.24 * For example, "Common", "HDFS", "MapReduce", "ZooKeeper", "HBase".25 */26 @Documented public @interface LimitedPrivate {27 String[] value();28 };29 //标识适用于某些特殊的工程。比如HDFS、Mapreduce等30 //它的值是个字符串数组,表示可以是多个工程31 32 /**33 * Intended for use only within Hadoop itself.34 */35 @Documented public @interface Private {};36 //只适用于hadoop自己37 private InterfaceAudience() {} // Audience can't exist on its own38 //构造方法,私有的。已有注释39 }
关于元注解和自定义注解
1 package org.apache.hadoop.classification; 2 3 import java.lang.annotation.Documented; 4 5 /** 6 * Annotation to inform users of how much to rely on a particular package, 7 * class or method not changing over time. 8 */ 9 //说明被他们注解的类型的稳定性10 @InterfaceAudience.Public11 @InterfaceStability.Evolving12 public class InterfaceStability {13 /**14 * Can evolve while retaining compatibility for minor release boundaries.; 15 * can break compatibility only at major release (ie. at m.0).16 */17 @Documented18 public @interface Stable {};19 //主版本是稳定的,不同主版本间可能不兼容20 /**21 * Evolving, but can break compatibility at minor release (i.e. m.x)22 */23 @Documented24 public @interface Evolving {};25 //不断变化,不同次版本间可能不兼容26 /**27 * No guarantee is provided as to reliability or stability across any28 * level of release granularity.29 */30 @Documented31 public @interface Unstable {};32 //没有任何可靠性和健壮性保证33 }