javax.enterprise.inject.spi.AnnotatedMethod.isAnnotationPresent()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(46)

本文整理了Java中javax.enterprise.inject.spi.AnnotatedMethod.isAnnotationPresent()方法的一些代码示例,展示了AnnotatedMethod.isAnnotationPresent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotatedMethod.isAnnotationPresent()方法的具体详情如下:
包路径:javax.enterprise.inject.spi.AnnotatedMethod
类名称:AnnotatedMethod
方法名:isAnnotationPresent

AnnotatedMethod.isAnnotationPresent介绍

暂无

代码示例

代码示例来源:origin: oracle/helidon

private void recordAnnotatedGaugeSite(@Observes @WithAnnotations(Gauge.class) ProcessAnnotatedType<?> pat) {
  LOGGER.log(Level.FINE, () -> "### recordAnnoatedGaugeSite for class " + pat.getAnnotatedType().getJavaClass());
  AnnotatedType<?> type = pat.getAnnotatedType();
  LOGGER.log(Level.FINE, () -> "### Processing annotations for " + type.getJavaClass().getName());
  // Register metrics based on annotations
  AnnotatedTypeConfigurator<?> configurator = pat.configureAnnotatedType();
  Class<?> clazz = configurator.getAnnotated().getJavaClass();
  // If abstract class, then handled by concrete subclasses
  if (Modifier.isAbstract(clazz.getModifiers())) {
    return;
  }
  // Process @Gauge methods keeping non-private declared on this class
  configurator.filterMethods(method -> method.getJavaMember().getDeclaringClass().equals(clazz)
      && !Modifier.isPrivate(method.getJavaMember().getModifiers())
      && method.isAnnotationPresent(Gauge.class))
      .forEach(method -> {
        Method javaMethod = method.getAnnotated().getJavaMember();
        String explicitGaugeName = method.getAnnotated().getAnnotation(Gauge.class).name();
        String gaugeName = String.format("%s.%s", clazz.getName(),
                         explicitGaugeName != null && explicitGaugeName.length() > 0
                             ? explicitGaugeName : javaMethod.getName());
        annotatedGaugeSites.put(gaugeName, method);
        LOGGER.log(Level.FINE, () -> String.format("### Recorded annotated gauge with name %s", gaugeName));
      });
}

代码示例来源:origin: org.jboss.weld.osgi/weld-osgi-core-extension

@Override
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
  return method.isAnnotationPresent(annotationType);
}

代码示例来源:origin: org.jboss.seam.solder/seam-solder

@SuppressWarnings("unchecked")
void captureProducers(AnnotatedMethod<?> method, Bean<?> bean)
{
 if (method.isAnnotationPresent(TypedMessageBundle.class))
 {
   this.bundleProducerBean = (Bean<Object>) bean;
 }
}

代码示例来源:origin: org.jboss.seam.solder/seam-solder

@SuppressWarnings("unchecked")
void captureProducers(AnnotatedMethod<?> method, Bean<?> bean)
{
 if (method.isAnnotationPresent(TypedMessageLogger.class))
 {
   this.loggerProducerBean = (Bean<Object>) bean;
 }
}

代码示例来源:origin: com.caucho/resin

private boolean isAnnotationPresent(Method m, 
                  Class<? extends Annotation> annType)
{
 if (m.isAnnotationPresent(annType))
  return true;
 
 AnnotatedMethod<?> annMethod = AnnotatedOverrideMap.getMethod(m);
 
 if (annMethod == null)
  return false;
 else
  return annMethod.isAnnotationPresent(annType);
}

代码示例来源:origin: org.demoiselle.jee/demoiselle-core

protected void startup(@Observes ProcessAnnotatedType<?> event) {
  final AnnotatedType<?> annotatedType = event.getAnnotatedType();
  for (AnnotatedMethod<?> am : annotatedType.getMethods()) {
    if (am.isAnnotationPresent(Startup.class)) {
      methodsWithStartup.add(new AnnotatedMethodProcessor(am));
    }
    if (am.isAnnotationPresent(Shutdown.class)) {
      methodsWithShutdown.add(new AnnotatedMethodProcessor(am));
    }
  }
}

代码示例来源:origin: io.smallrye.reactive/smallrye-reactive-messaging-provider

<T> void processClassesContainingMediators(@Observes ProcessManagedBean<T> event) {
  AnnotatedType<?> annotatedType = event.getAnnotatedBeanClass();
  if (annotatedType.getMethods()
      .stream()
      .anyMatch(m -> m.isAnnotationPresent(Incoming.class) || m.isAnnotationPresent(Outgoing.class))) {
    mediatorBeans.add(new MediatorBean<>(event.getBean(), event.getAnnotatedBeanClass()));
  }
}

代码示例来源:origin: weld/core

private static boolean isInterceptorMethod(AnnotatedMethod<?> annotatedMethod) {
  for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) {
    if (annotatedMethod.isAnnotationPresent(InterceptionTypeRegistry.getAnnotationClass(interceptionType))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: weld/core

private static boolean isInterceptorMethod(AnnotatedMethod<?> annotatedMethod) {
  for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) {
    if (annotatedMethod.isAnnotationPresent(InterceptionTypeRegistry.getAnnotationClass(interceptionType))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.jboss.weld.se/weld-se

private static boolean isInterceptorMethod(AnnotatedMethod<?> annotatedMethod) {
  for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) {
    if (annotatedMethod.isAnnotationPresent(InterceptionTypeRegistry.getAnnotationClass(interceptionType))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: weld/core

private static boolean isInterceptorMethod(AnnotatedMethod<?> annotatedMethod) {
  for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) {
    if (annotatedMethod.isAnnotationPresent(InterceptionTypeRegistry.getAnnotationClass(interceptionType))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.jboss.weld.se/weld-se-shaded

private static boolean isInterceptorMethod(AnnotatedMethod<?> annotatedMethod) {
  for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) {
    if (annotatedMethod.isAnnotationPresent(InterceptionTypeRegistry.getAnnotationClass(interceptionType))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.jboss.weld.se/weld-se

public static List<AnnotatedMethod<?>> getInterceptableMethods(AnnotatedType<?> type) {
  List<AnnotatedMethod<?>> annotatedMethods = new ArrayList<AnnotatedMethod<?>>();
  for (AnnotatedMethod<?> annotatedMethod : type.getMethods()) {
    boolean businessMethod = !annotatedMethod.isStatic() && !annotatedMethod.isAnnotationPresent(Inject.class)
        && !annotatedMethod.getJavaMember().isBridge();
    if (businessMethod && !isInterceptorMethod(annotatedMethod)) {
      annotatedMethods.add(annotatedMethod);
    }
  }
  return annotatedMethods;
}

代码示例来源:origin: io.smallrye/smallrye-fault-tolerance

public GenericConfig(Class<X> annotationType, AnnotatedMethod<?> annotatedMethod) {
  this(annotatedMethod.getJavaMember(), annotatedMethod,
      annotatedMethod.isAnnotationPresent(annotationType) ? annotatedMethod.getAnnotation(annotationType)
          : annotatedMethod.getDeclaringType().getAnnotation(annotationType),
      annotatedMethod.isAnnotationPresent(annotationType) ? ElementType.METHOD : ElementType.TYPE);
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

void processObserverMethod(@Observes ProcessObserverMethod<?, ?> event) {
  ObserverMethod<?> observer = event.getObserverMethod();
  AnnotatedMethod<?> method = event.getAnnotatedMethod();
  int order = 0; // the default order is 0
  if (method.isAnnotationPresent(Ordered.class)) {
    Ordered ordered = method.getAnnotation(Ordered.class);
    order = ordered.value();
  }
  observerMethodOrder.put(observer, order);
}

代码示例来源:origin: br.gov.frameworkdemoiselle/demoiselle-core

@SuppressWarnings("unchecked")
public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event) {
  final AnnotatedType<T> annotatedType = event.getAnnotatedType();
  for (AnnotatedMethod<?> am : annotatedType.getMethods()) {
    if (am.isAnnotationPresent(getAnnotationClass())) {
      processors.add(newProcessorInstance((AnnotatedMethod<T>) am));
    }
  }
}

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

private void validateManagedBean(AnnotatedType<Farm> type) {
  assert type.getBaseType().equals(Farm.class);
  assert typeSetMatches(type.getTypeClosure(), Farm.class, Object.class);
  assert type.getFields().size() == 1;
  assert type.getFields().iterator().next().isAnnotationPresent(Produces.class);
  assert type.getMethods().size() == 1;
  assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class);
}

代码示例来源:origin: org.jboss.jsr299.tck/jsr299-tck-impl

private void validateManagedBean(AnnotatedType<Farm> type)
{
 assert type.getBaseType().equals(Farm.class);
 assert rawTypeSetMatches(type.getTypeClosure(), Farm.class, Object.class);
 assert type.getFields().size() == 1;
 assert type.getFields().iterator().next().isAnnotationPresent(Produces.class);
 assert type.getMethods().size() == 1;
 assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class);
}

代码示例来源:origin: org.jboss.seam.servlet/seam-servlet

void processRequestParamProducer(@Observes ProcessProducerMethod<Object, RequestParamProducer> event) {
  if (event.getAnnotatedProducerMethod().getBaseType().equals(Object.class)
      && event.getAnnotatedProducerMethod().isAnnotationPresent(TypedParamValue.class)) {
    producerBlueprints.get(RequestParam.class).setProducer(event.getBean());
  }
}

代码示例来源:origin: org.agorava/solder-generics-impl

<X> void registerGenericBean(@Observes ProcessManagedBean<X> event) {
  AnnotatedType<X> type = event.getAnnotatedBeanClass();
  if (type.isAnnotationPresent(GenericConfiguration.class)) {
    Class<? extends Annotation> genericType = type.getAnnotation(GenericConfiguration.class).value();
    genericBeans.put(genericType, new BeanHolder<X>(event.getAnnotatedBeanClass(), event.getBean()));
    for (AnnotatedMethod<? super X> m : event.getAnnotatedBeanClass().getMethods()) {
      if (m.isAnnotationPresent(Unwraps.class)) {
        unwrapsMethods.put(genericType, m);
      }
    }
  }
}

相关文章