zoukankan      html  css  js  c++  java
  • Java基础之理解Annotation

    Java基础之理解Annotation

    学习了:https://www.cnblogs.com/mandroid/archive/2011/07/18/2109829.html

    学习了:https://www.jianshu.com/p/ca7f22b4b751

    @Retetion决定运行的事件;

    @Target说明注解针对的对象;

    jdk方面的说明:https://docs.oracle.com/javase/tutorial/java/annotations/predefined.html

    可以查看@HystrixCommand源码,

    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //
    
    package com.netflix.hystrix.contrib.javanica.annotation;
    
    import java.lang.annotation.Documented;
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Inherited;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    
    @Target({ElementType.METHOD})
    @Retention(RetentionPolicy.RUNTIME)
    @Inherited
    @Documented
    public @interface HystrixCommand {
        String groupKey() default "";
    
        String commandKey() default "";
    
        String threadPoolKey() default "";
    
        String fallbackMethod() default "";
    
        HystrixProperty[] commandProperties() default {};
    
        HystrixProperty[] threadPoolProperties() default {};
    
        Class<? extends Throwable>[] ignoreExceptions() default {};
    
        ObservableExecutionMode observableExecutionMode() default ObservableExecutionMode.EAGER;
    }

    Annotation可以包含默认值,字符串默认值是“”,对象默认值是{};

    而且Annotation中可以包含Annotation数组,HystrixProperty也是一个Annotation;

    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //
    
    package com.netflix.hystrix.contrib.javanica.annotation;
    
    import java.lang.annotation.Documented;
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    
    @Target({ElementType.METHOD})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    public @interface HystrixProperty {
        String name();
    
        String value();
    }
  • 相关阅读:
    getchar,putchar函数
    强制类型转换和整数常量的数据类型及转换
    c语言整型的隐式数据 类型转换
    c语言整型数据输出格式声明
    c语言整型变量的储存空间,以及所表示的整数范围
    c语言常量
    c语言求回文数
    Android4.0源码目录结构详解
    MTK Android源代码目录
    Comparator 和 Comparable
  • 原文地址:https://www.cnblogs.com/stono/p/8193504.html
Copyright © 2011-2022 走看看