当前位置: 首页>>代码示例>>Java>>正文


Java Annotated.getAnnotation方法代码示例

本文整理汇总了Java中javax.enterprise.inject.spi.Annotated.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java Annotated.getAnnotation方法的具体用法?Java Annotated.getAnnotation怎么用?Java Annotated.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.enterprise.inject.spi.Annotated的用法示例。


在下文中一共展示了Annotated.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAppDataValueAsString

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@AppData("PRODUCER")
public String getAppDataValueAsString(InjectionPoint injectionPoint) {
  Annotated annotated = injectionPoint.getAnnotated();
  String key = null;
  String value = null;

  if (annotated.isAnnotationPresent(AppData.class)) {
    AppData annotation = annotated.getAnnotation(AppData.class);
    key = annotation.value();
    value = properties.getProperty(key);
  }

  if (value == null) {
    throw new IllegalArgumentException("No AppData value found for key " + key);
  }

  return value;
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:20,代码来源:AppDataProducer.java

示例2: exposeLegacyLink

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@LegacyLink
public String exposeLegacyLink(InjectionPoint ip) {
    Annotated field = ip.getAnnotated();
    LegacyLink link = field.getAnnotation(LegacyLink.class);
    String linkName = link.name();
    if (linkName.isEmpty()) {
        linkName = ip.getMember().getName().toUpperCase();
    }
    int portNumber = link.portNumber();
    String resource = link.path();
    if (resource.isEmpty()) {
        return URIProvider.computeURIWithEnvironmentEntries(linkName, portNumber);
    } else {
        return URIProvider.computeURIWithEnvironmentEntries(linkName, portNumber, resource);
    }
}
 
开发者ID:AdamBien,项目名称:servicelink,代码行数:18,代码来源:URIExposer.java

示例3: expose

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@Link
public String expose(InjectionPoint ip) {
    Annotated field = ip.getAnnotated();
    Link link = field.getAnnotation(Link.class);
    String linkName = link.name();
    if (linkName.isEmpty()) {
        linkName = ip.getMember().getName().toUpperCase();
    }
    int portNumber = link.portNumber();
    String resource = link.path();
    if (resource.isEmpty()) {
        return URIProvider.computeUri(linkName, portNumber);
    } else {
        return URIProvider.computeUri(linkName, portNumber, resource);
    }
}
 
开发者ID:AdamBien,项目名称:servicelink,代码行数:18,代码来源:URIExposer.java

示例4: exposeCache

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
public <K, V> Cache<K, V> exposeCache(InjectionPoint ip) {
    Annotated annotated = ip.getAnnotated();
    CacheContext annotation = annotated.getAnnotation(CacheContext.class);
    //single cache defined in DD, no annotation
    if (doesConventionApply(annotation)) {
        return (Cache<K, V>) this.caches.values().iterator().next();
    }
    //annotation defined, name is used to lookup cache
    if (annotation != null) {
        String cacheName = annotation.value();
        Cache<K, V> cache = (Cache<K, V>) this.caches.get(cacheName);
        if (cache == null) {
            throw new IllegalStateException("Unsatisfied cache dependency error. Cache with name: " + cacheName + " does not exist");
        }
        return cache;
    }
    String fieldName = ip.getMember().getDeclaringClass().getName() + "." + ip.getMember().getName();
    if (this.caches.isEmpty()) {
        throw new IllegalStateException("No caches defined " + fieldName);
    } else {
        throw new IllegalStateException("Ambiguous caches exception: " + this.caches.keySet() + " for field name " + fieldName);
    }
}
 
开发者ID:wesleyegberto,项目名称:javaee_projects,代码行数:25,代码来源:CacheExposer.java

示例5: get

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces @Property
public String get(InjectionPoint ip) {
	Annotated annotated = ip.getAnnotated();
	Property property = annotated.getAnnotation(Property.class);
	String key = property.value();
	if (isNullOrEmpty(key)) {
		key = ip.getMember().getName();
	}
	
	String defaultValue = property.defaultValue();
	if(!isNullOrEmpty(defaultValue)){
		return environment.get(key, defaultValue);
	}
	
	return environment.get(key);
}
 
开发者ID:caelum,项目名称:vraptor4,代码行数:17,代码来源:EnvironmentPropertyProducer.java

示例6: extractAnnotation

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
/**
 * @param annotated element to search in
 * @param targetType target type to search for
 * @param <T> type of the Annotation which get searched
 * @return annotation instance extracted from the annotated member
 */
public static <T extends Annotation> T extractAnnotation(Annotated annotated, Class<T> targetType)
{
    T result = annotated.getAnnotation(targetType);

    if (result == null)
    {
        for (Annotation annotation : annotated.getAnnotations())
        {
            result = annotation.annotationType().getAnnotation(targetType);

            if (result != null)
            {
                break;
            }
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:26,代码来源:BeanUtils.java

示例7: createBank

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@BankProducer
public Bank createBank(@Any Instance<Bank> instance, InjectionPoint injectionPoint) {

    Annotated annotated = injectionPoint.getAnnotated();
    BankType bankTypeAnnotation = annotated.getAnnotation(BankType.class);
    Class<? extends Bank> bankType = bankTypeAnnotation.value().getBankType();
    return instance.select(bankType).get();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:10,代码来源:BankFactory.java

示例8: getResourceAnnotation

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
private Resource getResourceAnnotation(InjectionPoint injectionPoint) {
    Annotated annotated = injectionPoint.getAnnotated();
    if (annotated instanceof AnnotatedParameter<?>) {
        annotated = ((AnnotatedParameter<?>) annotated).getDeclaringCallable();
    }
    return annotated.getAnnotation(Resource.class);
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:8,代码来源:MockResourceInjectionServices.java

示例9: produce

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@IConfig
public Config produce(InjectionPoint injectionPoint) throws IOException {
    Annotated annotated = injectionPoint.getAnnotated();
    IConfig iConfig = annotated.getAnnotation(IConfig.class);
    String key = iConfig.value();
    if (!configs.containsKey(key)) {
        Config config = new Config();
        config.load(key);
        configs.put(key, config);
    }
    return configs.get(key);
}
 
开发者ID:igorzg,项目名称:payara-micro-docker-starter-kit,代码行数:14,代码来源:ConfigProducer.java

示例10: produceProperties

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
@Produces
@Dependent
@PropertyResource
public Properties produceProperties(InjectionPoint point) {
    final Annotated annotated = point.getAnnotated();

    if (point.getType() != Properties.class) {
        throw new InjectionException(Properties.class + " can not be injected to type " + point.getType());
    }

    final Class<?> beanType = point.getBean().getBeanClass();
    final ClassLoader loader = beanType.getClassLoader();
    final PropertyResource annotation = annotated.getAnnotation(PropertyResource.class);
    final PropertyResourceFormat format = annotation.format();

    String locator = annotation.url();

    if (locator.isEmpty()) {
        locator = beanType.getName().replace('.', '/') + ".properties";
    }

    try {
        return factory.getProperties(loader, locator, format);
    } catch (Exception e) {
        throw new InjectionException(e);
    }
}
 
开发者ID:xlate,项目名称:property-inject,代码行数:28,代码来源:PropertyResourceProducerBean.java

示例11: getWebRoutes

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
private WebRoute[] getWebRoutes(Annotated annotated) {
    WebRoute webRoute = annotated.getAnnotation(WebRoute.class);
    if (webRoute != null) {
        return new WebRoute[] { webRoute };
    }
    Annotation container = annotated.getAnnotation(WebRoutes.class);
    if (container != null) {
        WebRoutes webRoutes = (WebRoutes) container;
        return webRoutes.value();
    }
    return new WebRoute[] {};
}
 
开发者ID:weld,项目名称:weld-vertx,代码行数:13,代码来源:RouteExtension.java

示例12: getAnnotation

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
public static <A extends Annotation> Optional<A> getAnnotation(BeanManager beanManager, Annotated annotated, Class<A> annotationType) {

        annotated.getAnnotation(annotationType);

        if (annotated.getAnnotations().isEmpty()) {
            return empty();
        }

        if (annotated.isAnnotationPresent(annotationType)) {
            return Optional.of(annotated.getAnnotation(annotationType));
        }

        Queue<Annotation> annotations = new LinkedList<>(annotated.getAnnotations());

        while (!annotations.isEmpty()) {
            Annotation annotation = annotations.remove();

            if (annotation.annotationType().equals(annotationType)) {
                return Optional.of(annotationType.cast(annotation));
            }

            if (beanManager.isStereotype(annotation.annotationType())) {
                annotations.addAll(
                        beanManager.getStereotypeDefinition(
                                annotation.annotationType()
                        )
                );
            }
        }

        return empty();
    }
 
开发者ID:rdebusscher,项目名称:octopus-jsr375,代码行数:33,代码来源:CdiUtils.java

示例13: getPipelineName

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
String getPipelineName(InjectionPoint ip) {
    Annotated annotated = ip.getAnnotated();
    Dedicated dedicated = annotated.getAnnotation(Dedicated.class);
    String name;
    if (dedicated != null && !Dedicated.DEFAULT.equals(dedicated.value())) {
        name = dedicated.value();
    } else {
        name = ip.getMember().getName();
    }
    return name;
}
 
开发者ID:AdamBien,项目名称:porcupine,代码行数:12,代码来源:ExecutorServiceExposer.java

示例14: getLogger

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
/**
 *
 * @param injectionPoint : argument injected
 * @return
 */
@Produces
@OcelotLogger
public Logger getLogger(InjectionPoint injectionPoint) {
	Annotated annotated = injectionPoint.getAnnotated();
	OcelotLogger annotation = annotated.getAnnotation(OcelotLogger.class);
	String loggerName = annotation.name();
	if(loggerName.isEmpty()) {
		loggerName = injectionPoint.getMember().getDeclaringClass().getName();
	}
	return LoggerFactory.getLogger(loggerName);
}
 
开发者ID:ocelotds,项目名称:ocelot,代码行数:17,代码来源:LoggerProducer.java

示例15: newKey

import javax.enterprise.inject.spi.Annotated; //导入方法依赖的package包/类
private Key newKey(final InjectionPoint ip) {
    final Annotated annotated = ip.getAnnotated();
    final JMSConnectionFactory jmsConnectionFactory = annotated.getAnnotation(JMSConnectionFactory.class);
    final JMSSessionMode sessionMode = annotated.getAnnotation(JMSSessionMode.class);
    final JMSPasswordCredential credential = annotated.getAnnotation(JMSPasswordCredential.class);

    final String jndi = "openejb:Resource/" +
        (jmsConnectionFactory == null ? findAnyConnectionFactory() : findMatchingConnectionFactory(jmsConnectionFactory.value()));
    return new Key(
        jndi,
        credential != null ? credential.userName() : null,
        credential != null ? credential.password() : null,
        sessionMode != null ? sessionMode.value() : null);
}
 
开发者ID:apache,项目名称:tomee,代码行数:15,代码来源:JMS2CDIExtension.java


注:本文中的javax.enterprise.inject.spi.Annotated.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。