Example usage for org.apache.hadoop.util ReflectionUtils getDeclaredFieldsIncludingInherited

List of usage examples for org.apache.hadoop.util ReflectionUtils getDeclaredFieldsIncludingInherited

Introduction

In this page you can find the example usage for org.apache.hadoop.util ReflectionUtils getDeclaredFieldsIncludingInherited.

Prototype

public static List<Field> getDeclaredFieldsIncludingInherited(Class<?> clazz) 

Source Link

Document

Gets all the declared fields of a class including fields declared in superclasses.

Usage

From source file:com.datatorrent.stram.engine.Node.java

License:Apache License

public Node(OPERATOR operator, OperatorContext context) {
    this.operator = operator;
    this.context = context;

    outputs = new HashMap<String, Sink<Object>>();

    descriptor = new PortMappingDescriptor();
    Operators.describe(operator, descriptor);

    endWindowDequeueTimes = new HashMap<SweepableReservoir, Long>();
    tmb = ManagementFactory.getThreadMXBean();
    commandResponse = new LinkedBlockingQueue<StatsListener.OperatorResponse>();

    metricFields = Lists.newArrayList();
    for (Field field : ReflectionUtils.getDeclaredFieldsIncludingInherited(operator.getClass())) {
        if (field.isAnnotationPresent(AutoMetric.class)) {
            metricFields.add(field);//from  www. java 2 s  .c o m
            field.setAccessible(true);
        }
    }

    metricMethods = Maps.newHashMap();
    try {
        for (PropertyDescriptor pd : Introspector.getBeanInfo(operator.getClass()).getPropertyDescriptors()) {
            Method readMethod = pd.getReadMethod();
            if (readMethod != null) {
                AutoMetric rfa = readMethod.getAnnotation(AutoMetric.class);
                if (rfa != null) {
                    metricMethods.put(pd.getName(), readMethod);
                }
            }
        }
    } catch (IntrospectionException e) {
        throw new RuntimeException("introspecting {}", e);
    }
}