com.ibm.streams.operator.model

Annotation Type CustomMetric



  • @Target(value=METHOD)
    @Retention(value=RUNTIME)
    @Documented
    public @interface CustomMetric
    Declare a relationship between an Operator's Java bean property and custom metric. This allows Operator implementations to simplify their initialize method by having the SPL runtime automatically set field values using setter methods.

    Any Java bean setter methods of an Operator implementation class or its super classes annotated @CustomMetric are invoked by the SPL runtime passing the custom metric's Metric reference. The custom metric's name defaults to the Java bean property's name, but may be set explicitly using name().

    Setter methods are invoked before Operator.initialize is invoked. Invocation ordering of setter methods is not defined.

    Java bean properties of the operator's class and its super-classes are identified using java.beans.BeanInfo.getPropertyDescriptors() with the BeanInfo instance obtained using java.beans.Inspector. The setter method is identified by the getWriteMethod of a class's BeanInfo.

    If the SPL runtime throws an exception during automatic setting of metrics prior to initialization the processing element will terminate.
    An IllegalStateException is thrown if the Java Bean property's type is not Metric.
    An IllegalStateException is thrown if the corresponding custom metric definition in the Java primitive's operator model has a different kind.
    No action is taken for non-setter methods annotated @CustomMetric.

    The method this annotation is applied to must be:

    • public
    • an instance method (not static)
    • return type of void
    • have a single parameter of type Metric.
    These restrictions are enforced at Java compilation time using annotation processing from InfoSphere® Streams Version 3.2 onwards.

    Since:
    InfoSphere® Streams Version 3.1
    See Also:
    OperatorMetrics, Metric
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element and Description
      Metric.Kind kind
      Kind of the custom metric.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element and Description
      java.lang.String description
      Description of the custom metric
      boolean mxbean
      Register the custom metric as a MetricMXBean in the platform MBean server.
      java.lang.String name
      Name of the custom metric
    • Element Detail

      • kind

        public abstract Metric.Kind kind
        Kind of the custom metric.
      • name

        public abstract java.lang.String name
        Name of the custom metric
        Returns:
        The name of the custom metric or the empty string to indicate the custom metric name matches the Java bean property name.
        Default:
        ""
      • description

        public abstract java.lang.String description
        Description of the custom metric
        Returns:
        The description of the custom metric.
        Default:
        ""