T - Type of the MP metrics annotationpublic final class AnnotationReader<T extends Annotation> extends Object
Annotations from different annotated abstractions
providing a common interface to allow generic handling and a common logic independent of the source of the
Annotation.
Supported are:
AnnotatedElementAnnotatedInjectionPointAnnotated and InjectionPoint have to be used as a source when
available as they allow to add or remove Annotation effectively acting as a runtime override of the compiled
information provided by AnnotatedElement.
This utility also encodes most of the logic as defined by the MP Metrics specification. This includes the logic of
which annotation applied and how the metrics effective name if computed from annotation values and the annotated
element. For this reason the methods are documented in great detail.| Modifier and Type | Field and Description |
|---|---|
static AnnotationReader<org.eclipse.microprofile.metrics.annotation.ConcurrentGauge> |
CONCURRENT_GAUGE |
static AnnotationReader<org.eclipse.microprofile.metrics.annotation.Counted> |
COUNTED |
static AnnotationReader<org.eclipse.microprofile.metrics.annotation.Gauge> |
GAUGE |
static AnnotationReader<org.eclipse.microprofile.metrics.annotation.Metered> |
METERED |
static AnnotationReader<org.eclipse.microprofile.metrics.annotation.Metric> |
METRIC |
static AnnotationReader<org.eclipse.microprofile.metrics.annotation.SimplyTimed> |
SIMPLY_TIMED |
static AnnotationReader<org.eclipse.microprofile.metrics.annotation.Timed> |
TIMED |
| Modifier and Type | Method and Description |
|---|---|
boolean |
absolute(T annotation)
Returns the metric absolute flag as defined by the provided
Annotation |
<E extends Member & AnnotatedElement> |
annotation(Class<?> bean,
E element)
Returns the effective annotation for the provided bean and element.
|
T |
annotation(javax.enterprise.inject.spi.InjectionPoint point)
Reads the effective
Annotation for the provided InjectionPoint. |
Class<T> |
annotationType() |
AnnotationReader<T> |
asType(org.eclipse.microprofile.metrics.MetricType type)
If this
AnnotationReader reads Metric Annotation it can be associated with different
MetricType so that the provided type is used when creating Metadata using the
AnnotationReader. |
String |
description(T annotation)
Returns the metric description as defined by the provided
Annotation |
String |
displayName(T annotation)
Returns the metric display name as defined by the provided
Annotation |
boolean |
equals(Object obj) |
static <T extends Annotation> |
forAnnotation(Class<T> annotationType)
Get
AnnotationReader for a provided Annotation. |
<M extends org.eclipse.microprofile.metrics.Metric> |
getOrRegister(javax.enterprise.inject.spi.InjectionPoint point,
Class<M> metric,
org.eclipse.microprofile.metrics.MetricRegistry registry)
Resolves the
Metric referred to by the provided InjectionPoint. |
int |
hashCode() |
<E extends Member & AnnotatedElement> |
isPresent(Class<?> bean,
E element)
Checks if this
AnnotationReader's annotationType() is present either at the provided
AnnotatedElement or the provided bean Class. |
boolean |
isReference(T annotation)
Checks if an
Annotation does not provide any information beyond the required name and tags. |
org.eclipse.microprofile.metrics.Metadata |
metadata(javax.enterprise.inject.spi.AnnotatedMember<?> member)
Returns the metric
Metadata as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. |
<E extends Member & AnnotatedElement> |
metadata(Class<?> bean,
E element)
|
org.eclipse.microprofile.metrics.Metadata |
metadata(javax.enterprise.inject.spi.InjectionPoint point)
Returns the metric
Metadata as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. |
org.eclipse.microprofile.metrics.Metadata |
metadata(T annotation)
Returns the full
Metadata as defined by the provided Annotation |
org.eclipse.microprofile.metrics.MetricID |
metricID(javax.enterprise.inject.spi.AnnotatedMember<?> member)
Returns the metric
MetricID as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. |
<E extends Member & AnnotatedElement> |
metricID(Class<?> bean,
E element)
|
org.eclipse.microprofile.metrics.MetricID |
metricID(javax.enterprise.inject.spi.InjectionPoint point)
Returns the metric
MetricID as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. |
org.eclipse.microprofile.metrics.MetricID |
metricID(T annotation)
Returns the
MetricID as defined by the provided Annotation's name and tags attributes. |
String |
name(javax.enterprise.inject.spi.AnnotatedMember<?> member)
Returns the metric name as defined by the MP specification for the annotation situation at hand for the provided
AnnotatedMember. |
<E extends Member & AnnotatedElement> |
name(Class<?> bean,
E element)
Reads the effective name for the provided bean
Class and AnnotatedElement. |
String |
name(javax.enterprise.inject.spi.InjectionPoint point)
Returns the metric name as defined by the MP specification for the annotation situation at hand for the provided
InjectionPoint. |
String |
name(T annotation)
Returns the metric name as defined by the provided
Annotation |
static Iterable<AnnotationReader<?>> |
readers() |
boolean |
reusable(T annotation)
Returns the metric reusable flag as defined by the provided
Annotation |
org.eclipse.microprofile.metrics.Tag[] |
tags(T annotation)
Returns the metric tags as defined by the provided
Annotation |
static org.eclipse.microprofile.metrics.Tag[] |
tagsFromString(String[] tags) |
String |
toString() |
org.eclipse.microprofile.metrics.MetricType |
type() |
String |
unit(T annotation)
Returns the metric unit as defined by the provided
Annotation |
public static final AnnotationReader<org.eclipse.microprofile.metrics.annotation.ConcurrentGauge> CONCURRENT_GAUGE
public static final AnnotationReader<org.eclipse.microprofile.metrics.annotation.Counted> COUNTED
public static final AnnotationReader<org.eclipse.microprofile.metrics.annotation.Gauge> GAUGE
public static final AnnotationReader<org.eclipse.microprofile.metrics.annotation.Metered> METERED
public static final AnnotationReader<org.eclipse.microprofile.metrics.annotation.Metric> METRIC
public static final AnnotationReader<org.eclipse.microprofile.metrics.annotation.Timed> TIMED
public static final AnnotationReader<org.eclipse.microprofile.metrics.annotation.SimplyTimed> SIMPLY_TIMED
public static <T extends Annotation> AnnotationReader<T> forAnnotation(Class<T> annotationType)
AnnotationReader for a provided Annotation.annotationType - AnnotationReader for the provided Annotation typeIllegalAccessException - In case no such reader existspublic static Iterable<AnnotationReader<?>> readers()
AnnotationReaderspublic AnnotationReader<T> asType(org.eclipse.microprofile.metrics.MetricType type)
AnnotationReader reads Metric Annotation it can be associated with different
MetricType so that the provided type is used when creating Metadata using the
AnnotationReader.type - any MetricTypeAnnotationReader using the provided MetricTypeIllegalStateException - In case this method is called on AnnotationReader that is not reading
Metric Annotation.public org.eclipse.microprofile.metrics.MetricType type()
MetricType used by this AnnotationReader when generating a Metadata object
any of the variants of the metadata(Annotation) methods. Usually each Annotation is
associated with a particular MetricType but for Metric Annotation the type can be
changed using #asType(Class) methods.public <E extends Member & AnnotatedElement> T annotation(Class<?> bean, E element)
bean - type of the bean that declared the provided elementelement - a AnnotatedElement possibly annotated with this AnnotationReader's
annotationType()Annotation, or null. The element's annotations take precedence over the
bean's annotations.public T annotation(javax.enterprise.inject.spi.InjectionPoint point)
Annotation for the provided InjectionPoint.point - source InjectionPoint for an annotated element having this AnnotationReader's
annotationType(), not nullInjectionPoint, never nullIllegalArgumentException - In case the provided InjectionPoint isn't effectively annotated with
this AnnotationReader's Annotation.public <E extends Member & AnnotatedElement> boolean isPresent(Class<?> bean, E element)
AnnotationReader's annotationType() is present either at the provided
AnnotatedElement or the provided bean Class.bean - type of the bean that declared the provided elementelement - a AnnotatedElement possibly annotated with this AnnotationReader's
annotationType()AnnotationReader's
annotationType(), else false.public String name(T annotation)
Annotationannotation - source annotation to read, not nullpublic String name(javax.enterprise.inject.spi.InjectionPoint point)
InjectionPoint. This does take into account that annotations might have been added or removed at runtime.point - source InjectionPoint for an annotated element having this AnnotationReader's
annotationType(), not nullIllegalArgumentException - In case the provided InjectionPoint isn't effectively annotated with
this AnnotationReader's Annotation.public String name(javax.enterprise.inject.spi.AnnotatedMember<?> member)
AnnotatedMember. This does take into account that annotations might have been added or removed at runtime.member - source AnnotatedMember for an annotated element having this AnnotationReader's
annotationType(), not nullIllegalArgumentException - In case the provided AnnotatedMember isn't effectively annotated with
this AnnotationReader's Annotation.public <E extends Member & AnnotatedElement> String name(Class<?> bean, E element)
Class and AnnotatedElement. Either bean or element
must have this AnnotationReader's Annotation.bean - type of the bean that declared the provided element possibly annotated with this
AnnotationReader's annotationType()element - a AnnotatedElement possibly annotated with this AnnotationReader's
annotationType()IllegalArgumentException - In case neither the AnnotatedElement or the Class isn't
annotated with this AnnotationReader's Annotation.public org.eclipse.microprofile.metrics.Tag[] tags(T annotation)
Annotationannotation - source annotation to read, not nullpublic org.eclipse.microprofile.metrics.MetricID metricID(T annotation)
MetricID as defined by the provided Annotation's name and tags attributes.annotation - source annotation to read, not nullMetricID value of the provided source annotationpublic org.eclipse.microprofile.metrics.MetricID metricID(javax.enterprise.inject.spi.InjectionPoint point)
MetricID as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. This does take into account that annotations might have been added or
removed at runtime.point - source InjectionPoint for an annotated element having this AnnotationReader's
annotationType(), not nullMetricID with full metric name as required by the MP specificationIllegalArgumentException - In case the provided InjectionPoint isn't effectively annotated with
this AnnotationReader's Annotation.public org.eclipse.microprofile.metrics.MetricID metricID(javax.enterprise.inject.spi.AnnotatedMember<?> member)
MetricID as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. This does take into account that annotations might have been added or
removed at runtime.point - source AnnotatedMember for an annotated element having this AnnotationReader's
annotationType(), not nullMetricID with full metric name as required by the MP specificationIllegalArgumentException - In case the provided AnnotatedMember isn't effectively annotated with
this AnnotationReader's Annotation.public <E extends Member & AnnotatedElement> org.eclipse.microprofile.metrics.MetricID metricID(Class<?> bean, E element)
MetricID for the provided bean Class and AnnotatedElement. Either
bean or element must have this AnnotationReader's Annotation.bean - type of the bean that declared the provided element possibly annotated with this
AnnotationReader's annotationType()element - a AnnotatedElement possibly annotated with this AnnotationReader's
annotationType()MetricID with full metric name as required by the MP specificationIllegalArgumentException - In case neither the AnnotatedElement or the Class isn't
annotated with this AnnotationReader's Annotation.public String displayName(T annotation)
Annotationannotation - source annotation to read, not nullpublic String description(T annotation)
Annotationannotation - source annotation to read, not nullpublic String unit(T annotation)
Annotationannotation - source annotation to read, not nullpublic boolean reusable(T annotation)
Annotationannotation - source annotation to read, not nullpublic boolean absolute(T annotation)
Annotationannotation - source annotation to read, not nullpublic org.eclipse.microprofile.metrics.Metadata metadata(T annotation)
Metadata as defined by the provided Annotationannotation - source annotation to read, not nullMetadata of the provided source annotationpublic org.eclipse.microprofile.metrics.Metadata metadata(javax.enterprise.inject.spi.InjectionPoint point)
Metadata as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. This does take into account that annotations might have been added or
removed at runtime.point - source InjectionPoint for an annotated element having this AnnotationReader's
annotationType(), not nullMetadata with full metric name as required by the MP specificationIllegalArgumentException - In case the provided InjectionPoint isn't effectively annotated with
this AnnotationReader's Annotation.public org.eclipse.microprofile.metrics.Metadata metadata(javax.enterprise.inject.spi.AnnotatedMember<?> member)
Metadata as defined by the MP specification for the annotation situation at hand for
the provided InjectionPoint. This does take into account that annotations might have been added or
removed at runtime.point - source AnnotatedMember for an annotated element having this AnnotationReader's
annotationType(), not nullMetadata with full metric name as required by the MP specificationIllegalArgumentException - In case the provided AnnotatedMember isn't effectively annotated with
this AnnotationReader's Annotation.public <E extends Member & AnnotatedElement> org.eclipse.microprofile.metrics.Metadata metadata(Class<?> bean, E element)
Metadata for the provided bean Class and AnnotatedElement. Either
bean or element must have this AnnotationReader's Annotation.bean - type of the bean that declared the provided element possibly annotated with this
AnnotationReader's annotationType()element - a AnnotatedElement possibly annotated with this AnnotationReader's
annotationType()Metadata with full metric name as required by the MP specificationIllegalArgumentException - In case neither the AnnotatedElement or the Class isn't
annotated with this AnnotationReader's Annotation.public boolean isReference(T annotation)
Annotation does not provide any information beyond the required name and tags.annotation - source annotation to read, not nullMetadata when registering, else
false.public <M extends org.eclipse.microprofile.metrics.Metric> M getOrRegister(javax.enterprise.inject.spi.InjectionPoint point,
Class<M> metric,
org.eclipse.microprofile.metrics.MetricRegistry registry)
Metric referred to by the provided InjectionPoint.
If it does not exist, the metric is created. Lookup and creation are one atomic operation. Depending on the
provided information in the effective Annotation for the provided InjectionPoint the metric is
resolved or registered using Metadata, name and Tags or just its name.
A Gauge can only be resolved, not created.point - source InjectionPoint for an annotated element having this AnnotationReader's
annotationType(), not nullmetric - type of the Metric to find or create, not nullregistry - MetricRegistry to use, not nullnull if a Gauge
did not existpublic static org.eclipse.microprofile.metrics.Tag[] tagsFromString(String[] tags)
Copyright © 2020. All rights reserved.