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

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

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

AnnotatedMethod.getAnnotation介绍

暂无

代码示例

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

/**
 * Records metric producer methods defined by the application. Ignores producers
 * with non-default qualifiers and library producers.
 *
 * @param ppm Producer method.
 */
private void recordProducerMethods(@Observes
                      ProcessProducerMethod<? extends org.eclipse.microprofile.metrics.Metric, ?> ppm) {
  LOGGER.log(Level.FINE, () -> "### recordProducerMethods " + ppm.getBean().getBeanClass());
  if (!MetricProducer.class.equals(ppm.getBean().getBeanClass())) {
    Metric metric = ppm.getAnnotatedProducerMethod().getAnnotation(Metric.class);
    if (metric != null) {
      Optional<? extends Annotation> hasQualifier
          = ppm.getAnnotatedProducerMethod()
          .getAnnotations()
          .stream()
          .filter(annotation -> annotation.annotationType().isAnnotationPresent(Qualifier.class))
          .findFirst();
      // Ignore producers with non-default qualifiers
      if (!hasQualifier.isPresent() || hasQualifier.get() instanceof Default) {
        producers.put(ppm.getBean(), ppm.getAnnotatedProducerMethod());
      }
    }
  }
}

代码示例来源: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: oracle/helidon

private void registerAnnotatedGauges(@Observes AfterDeploymentValidation adv, BeanManager bm) {
  LOGGER.log(Level.FINE, () -> "### registerGauges");
  MetricRegistry registry = getMetricRegistry();
  annotatedGaugeSites.entrySet().forEach(gaugeSite -> {
    LOGGER.log(Level.FINE, () -> "### gaugeSite " + gaugeSite.toString());
    String gaugeName = gaugeSite.getKey();
    AnnotatedMethodConfigurator<?> site = gaugeSite.getValue();
    DelegatingGauge<?> dg = buildDelegatingGauge(gaugeName, site, bm);
    Gauge gaugeAnnotation = site.getAnnotated().getAnnotation(Gauge.class);
    Metadata md = new Metadata(gaugeName,
        gaugeAnnotation.displayName(),
        gaugeAnnotation.description(),
        MetricType.GAUGE,
        gaugeAnnotation.unit(),
        toTags(gaugeAnnotation.tags()));
    LOGGER.log(Level.FINE, () -> String.format("### Registering gauge with metadata %s", md.toString()));
    registry.register(md, dg);
  });
  annotatedGaugeSites.clear();
}

代码示例来源:origin: org.jboss.forge/forge-event-bus

@Override
public <T extends Annotation> T getAnnotation(final Class<T> annotation)
{
 return method.getAnnotation(annotation);
}

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

protected <Z extends Annotation> Z getAnnotation(Class<Z> annotationType,
                         AnnotatedMethod<?> apiMethod, 
                         AnnotatedMethod<?> implMethod)
{
 Z annotation;
 annotation = apiMethod.getAnnotation(annotationType);
 if ((annotation == null) && (implMethod != null)) {
  annotation = implMethod.getAnnotation(annotationType);
 }
 return annotation;
}

代码示例来源:origin: stackoverflow.com

class CompressedPropertyNamingStrategy extends PropertyNamingStrategy {

  private static final long serialVersionUID = 1L;

  @Override
  public String nameForGetterMethod(MapperConfig<?> config, AnnotatedMethod method,
      String defaultName) {
    CompressedName compressedProperty = method.getAnnotation(CompressedName.class);
    if (compressedProperty != null) {
      return compressedProperty.value();
    }

    // Implement default value: first letter, or something else
    return defaultName;
  }
}

代码示例来源:origin: com.tomitribe.tribestream/tribestream-container

@Override
public <T extends Annotation> T getAnnotation(final Class<T> annotationType) {
  return annotationType == Filterable.class ? (T) FILTERABLE : original.getAnnotation(annotationType);
}

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

@Override
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
  return method.getAnnotation(annotationType);
}

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

private static <T> Integer getPriority(AnnotatedMethod<T> annotatedMethod) {
  Integer priority = Priority.MIN_PRIORITY;
  Priority annotation = annotatedMethod.getAnnotation(Priority.class);
  if (annotation != null) {
    priority = annotation.value();
  }
  return priority;
}

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

@Override
public ConfigProgram introspectMethod(AnnotatedMethod<?> method)
{
 EJB ejb = method.getAnnotation(EJB.class);
 
 return generateContext(method, ejb);
}

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

@Override
public ConfigProgram introspectMethod(AnnotatedMethod<?> method)
{
 DataSourceDefinition db = method.getAnnotation(DataSourceDefinition.class);
 
 return generateProgram(method, db);
}

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

/**
 * 
 * @param annotatedMethod Represents the method
 * @return Get the current Priority annotated with {@link DemoiselleLifecyclePriority}
 */
protected Integer getPriority(AnnotatedMethod<?> annotatedMethod) {
  Integer priority = DemoiselleLifecyclePriority.LEVEL_4;
  DemoiselleLifecyclePriority annotation = annotatedMethod.getAnnotation(DemoiselleLifecyclePriority.class);
  if (annotation != null) {
    priority = annotation.value();
  }
  return priority;
}

代码示例来源:origin: demoiselle/framework

/**
 * 
 * @param annotatedMethod Represents the method
 * @return Get the current Priority annotated with {@link DemoiselleLifecyclePriority}
 */
protected Integer getPriority(AnnotatedMethod<?> annotatedMethod) {
  Integer priority = DemoiselleLifecyclePriority.LEVEL_4;
  DemoiselleLifecyclePriority annotation = annotatedMethod.getAnnotation(DemoiselleLifecyclePriority.class);
  if (annotation != null) {
    priority = annotation.value();
  }
  return priority;
}

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

public InterceptorsLiteral mergeAnnotation(AnnotatedMethod<?> m)
{
 javax.interceptor.Interceptors interceptors;
 
 interceptors = m.getAnnotation(javax.interceptor.Interceptors.class);
 
 ArrayList<Class<?>> classList = new ArrayList<Class<?>>(_interceptors);
 
 if (interceptors != null) {
  for (Class<?> cl : interceptors.value())
   classList.add(cl);
 }
 
 Class<?> []values = new Class<?>[classList.size()];
 
 classList.toArray(values);
 
 return new InterceptorsLiteral(values);
}

代码示例来源: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: com.caucho/resin

@Override
public ConfigProgram introspectMethod(AnnotatedMethod<?> method)
{
 PersistenceUnit pUnit = method.getAnnotation(PersistenceUnit.class);
 
 Method javaMethod = method.getJavaMember();
 
 Class<?> param = null;
 
 if (javaMethod.getParameterTypes().length == 1)
  param = javaMethod.getParameterTypes()[0];
 
 if (param == null || ! param.isAssignableFrom(EntityManagerFactory.class)) {
  throw new ConfigException(L.l("{0}: @PersistenceUnit method must be assignable from EntityManagerFactory.",
                 getLocation(javaMethod)));
 }
 
 return generateContext(method, pUnit);
}

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

@Override
public ConfigProgram introspectMethod(AnnotatedMethod<?> method)
{
 Resource resource = method.getAnnotation(Resource.class);
 
 Method javaMethod = method.getJavaMember();
 
 String loc = getLocation(method.getJavaMember());
 
 String jndiName = (javaMethod.getDeclaringClass().getName()
           + "/" + javaMethod.getName());
 
 Class<?> bindType = javaMethod.getParameterTypes()[0];
 
 ValueGenerator gen = generateContext(loc, bindType, jndiName, resource);
 
 bindJndi(javaMethod, gen);
 
 return new MethodGeneratorProgram(method.getJavaMember(), gen);
}

代码示例来源:origin: com.kumuluz.ee.metrics/kumuluzee-metrics-core

private void metricProducerMethod(@Observes ProcessProducerMethod<? extends Metric, ?> ppm) {
  if (ppm.getAnnotatedProducerMethod().getAnnotation(org.eclipse.microprofile.metrics.annotation.Metric.class)
      != null) {
    Method member = ppm.getAnnotatedProducerMethod().getJavaMember();
    Class<?> bean = member.getDeclaringClass();
    Metadata metadata = AnnotationMetadata.buildMetadata(bean, member,
        org.eclipse.microprofile.metrics.annotation.Metric.class);
    producerMembers.add(new ProducerMemberRegistration(ppm.getBean(), ppm.getAnnotatedProducerMethod(),
        metadata));
  }
}

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

/**
 * Generates the underlying bean instance
 */
@Override
public void generateApplicationException(JavaWriter out, Class<?> exn)
  throws IOException
{
 // ejb/5070
 super.generateApplicationException(out, exn);
 // ejb/5064
 if (getMethod().getAnnotation(Remove.class) == null) {
  out.println("isValid = true;");
 }
}

代码示例来源: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);
}

相关文章