本文整理了Java中javax.enterprise.inject.spi.Annotated.getAnnotation()
方法的一些代码示例,展示了Annotated.getAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotated.getAnnotation()
方法的具体详情如下:
包路径:javax.enterprise.inject.spi.Annotated
类名称:Annotated
方法名:getAnnotation
[英]Get program element annotation of a certain annotation type. The behavior of this method is intended to be the same behavior as AnnotatedElement#getAnnotation(Class), where repeatable annotations are not supported.
[中]获取特定注释类型的程序元素注释。此方法的行为与AnnotateDelete#getAnnotation(类)的行为相同,不支持可重复的注释。
代码示例来源:origin: oracle/helidon
/**
* Returns the {@link Gauge} matching the criteria from the injection point.
*
* @param <T> type of the {@code Gauge}
* @param registry metric registry
* @param ip injection point being resolved
* @return requested gauge
*/
@Produces
@VendorDefined
@SuppressWarnings("unchecked")
private <T> Gauge<T> produceGauge(MetricRegistry registry, InjectionPoint ip) {
Metric metric = ip.getAnnotated().getAnnotation(Metric.class);
return (Gauge<T>) registry.getGauges().entrySet().stream()
.filter(entry -> entry.getKey().equals(metric.name()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Could not produce Gauge for injection point " + ip.toString()))
.getValue();
}
代码示例来源:origin: wildfly/wildfly
protected String getResourceName(InjectionPoint injectionPoint) {
Resource resource = getResourceAnnotated(injectionPoint).getAnnotation(Resource.class);
String mappedName = resource.mappedName();
String lookup = resource.lookup();
if (!lookup.isEmpty()) {
return lookup;
}
if (!mappedName.isEmpty()) {
return mappedName;
}
String proposedName = ResourceInjectionUtilities.getResourceName(injectionPoint);
return getEJBResourceName(injectionPoint, proposedName);
}
代码示例来源:origin: oracle/helidon
@Produces
@VendorDefined
private Timer produceTimer(MetricRegistry registry, InjectionPoint ip) {
Metric metric = ip.getAnnotated().getAnnotation(Metric.class);
return registry.timer(newMetadata(ip, metric, MetricType.TIMER));
}
代码示例来源:origin: oracle/helidon
@Produces
@VendorDefined
private Histogram produceHistogram(MetricRegistry registry, InjectionPoint ip) {
Metric metric = ip.getAnnotated().getAnnotation(Metric.class);
return registry.histogram(newMetadata(ip, metric, MetricType.HISTOGRAM));
}
代码示例来源:origin: oracle/helidon
@Produces
@VendorDefined
private Meter produceMeter(MetricRegistry registry, InjectionPoint ip) {
Metric metric = ip.getAnnotated().getAnnotation(Metric.class);
return registry.meter(newMetadata(ip, metric, MetricType.METERED));
}
代码示例来源:origin: oracle/helidon
@Produces
@VendorDefined
private Counter produceCounter(MetricRegistry registry, InjectionPoint ip) {
Metric metric = ip.getAnnotated().getAnnotation(Metric.class);
return registry.counter(newMetadata(ip, metric, MetricType.COUNTER));
}
代码示例来源:origin: wildfly/wildfly
public static String getResourceName(InjectionPoint injectionPoint) {
Resource resource = getResourceAnnotated(injectionPoint).getAnnotation(Resource.class);
String mappedName = resource.mappedName();
if (!mappedName.equals("")) {
代码示例来源:origin: oracle/helidon
ConfigProperty configProperty = pip.getInjectionPoint().getAnnotated().getAnnotation(ConfigProperty.class);
if (configProperty != null) {
InjectionPoint ip = pip.getInjectionPoint();
代码示例来源:origin: oracle/helidon
Claim claim = pip.getInjectionPoint().getAnnotated().getAnnotation(Claim.class);
if (claim != null) {
if ((claim.standard() != Claims.UNKNOWN) && !claim.value().isEmpty()) {
代码示例来源:origin: camunda/camunda-bpm-platform
protected String getVariableLocalTypedName(InjectionPoint ip) {
String variableName = ip.getAnnotated().getAnnotation(ProcessVariableLocalTyped.class).value();
if (variableName.length() == 0) {
variableName = ip.getMember().getName();
}
return variableName;
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected String getVariableTypedName(InjectionPoint ip) {
String variableName = ip.getAnnotated().getAnnotation(ProcessVariableTyped.class).value();
if (variableName.length() == 0) {
variableName = ip.getMember().getName();
}
return variableName;
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected String getVariableName(InjectionPoint ip) {
String variableName = ip.getAnnotated().getAnnotation(ProcessVariable.class).value();
if (variableName.length() == 0) {
variableName = ip.getMember().getName();
}
return variableName;
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected String getVariableLocalName(InjectionPoint ip) {
String variableName = ip.getAnnotated().getAnnotation(ProcessVariableLocal.class).value();
if (variableName.length() == 0) {
variableName = ip.getMember().getName();
}
return variableName;
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Produces @ProcessEngineName("")
public ProcessEngine processEngine(InjectionPoint ip) {
ProcessEngineName annotation = ip.getAnnotated().getAnnotation(ProcessEngineName.class);
String processEngineName = annotation.value();
if(processEngineName == null || processEngineName.length() == 0) {
throw new ProcessEngineException("Cannot determine which process engine to inject: @ProcessEngineName must specify the name of a process engine.");
}
try {
ProcessEngineService processEngineService = BpmPlatform.getProcessEngineService();
return processEngineService.getProcessEngine(processEngineName);
}catch (Exception e) {
throw new ProcessEngineException("Cannot find process engine named '"+processEngineName+"' specified using @ProcessEngineName: "+e.getMessage(), e);
}
}
代码示例来源:origin: stackoverflow.com
publi class MyAnnotationIntrospector extends JacksonAnnotationIntrospector {
@Override
protected boolean _isIgnorable(Annotated a) {
boolean isIgnorable = super._isIgnorable(a);
if (!isIgnorable) {
SomeAnnotation ann = a.getAnnotation(SomeAnnotation.class);
isIgnorable = ann != null;
}
return isIgnorable;
}
}
代码示例来源:origin: weld/core
public Class<?>[] extractInterceptorClasses(Annotated annotated) {
Annotation annotation = annotated.getAnnotation(INTERCEPTORS_ANNOTATION_CLASS);
if (annotation != null) {
try {
return (Class<?>[]) interceptorsValueMethod.invoke(annotation);
} catch (Exception e) {
throw UtilLogger.LOG.annotationValuesInaccessible(e);
}
}
return null;
}
代码示例来源:origin: org.jboss.weld.se/weld-se
public Class<?>[] extractInterceptorClasses(Annotated annotated) {
Annotation annotation = annotated.getAnnotation(INTERCEPTORS_ANNOTATION_CLASS);
if (annotation != null) {
try {
return (Class<?>[]) interceptorsValueMethod.invoke(annotation);
} catch (Exception e) {
throw UtilLogger.LOG.annotationValuesInaccessible(e);
}
}
return null;
}
代码示例来源:origin: weld/core
public Class<?>[] extractInterceptorClasses(Annotated annotated) {
Annotation annotation = annotated.getAnnotation(INTERCEPTORS_ANNOTATION_CLASS);
if (annotation != null) {
try {
return (Class<?>[]) interceptorsValueMethod.invoke(annotation);
} catch (Exception e) {
throw UtilLogger.LOG.annotationValuesInaccessible(e);
}
}
return null;
}
代码示例来源:origin: weld/core
protected Resource getResourceAnnotation(InjectionPoint injectionPoint) {
Annotated annotated = injectionPoint.getAnnotated();
if (annotated instanceof AnnotatedParameter<?>) {
annotated = ((AnnotatedParameter<?>) annotated).getDeclaringCallable();
}
return annotated.getAnnotation(Resource.class);
}
代码示例来源:origin: apiman/apiman
@Produces @ApimanLogger
public static IApimanLogger provideLogger(ManagerApiMicroServiceConfig config, InjectionPoint injectionPoint) {
try {
ApimanLogger logger = injectionPoint.getAnnotated().getAnnotation(ApimanLogger.class);
Class<?> klazz = logger.value();
return getDelegate(config).newInstance().createLogger(klazz);
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(String.format(
Messages.i18n.format("LoggerFactory.InstantiationFailed")), e); //$NON-NLS-1$
}
}
内容来源于网络,如有侵权,请联系作者删除!