本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
}
示例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[] {};
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}