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


Java AnnotatedType.getAnnotation方法代码示例

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


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

示例1: getReplacement

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
private <T> AnnotatedMethod<? super T> getReplacement(AnnotatedType<T> type,
                                                      AnnotatedMethod<? super T> method) {

    boolean isResourceMethod = method.getAnnotation(GET.class) != null ||
        method.getAnnotation(POST.class) != null || method.getAnnotation(PUT.class) != null ||
        method.getAnnotation(HEAD.class) != null || method.getAnnotation(DELETE.class) != null;

    boolean hasControllerAnnotation =
        method.getAnnotation(Controller.class) != null || type.getAnnotation(Controller.class) != null;

    if (isResourceMethod && hasControllerAnnotation) {

        log.log(Level.FINE, "Found controller method: {0}#{1}", new Object[]{
            type.getJavaClass().getName(),
            method.getJavaMember().getName()
        });

        return new AnnotatedMethodWrapper<>(
            method, Collections.singleton(() -> ValidationInterceptorBinding.class)
        );

    }

    return null;

}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:27,代码来源:AnnotatedTypeProcessor.java

示例2: initializePropertyLoading

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
/**
 * Prepares the injection process of properties from a property file.
 *
 * @param pit
 * 		The actual target of process injection
 * @param <T>
 * 		the generic type of the injection target
 */
public <T> void initializePropertyLoading(@Observes final ProcessInjectionTarget<T> pit) throws IOException {
	AnnotatedType<T> at = pit.getAnnotatedType();
	if (!at.isAnnotationPresent(PropertyFile.class)) {
		return;
	}
	try {
		PropertyFile propertyFile = at.getAnnotation(PropertyFile.class);
		Properties properties = loadProperties(propertyFile, pit.getAnnotatedType().getJavaClass());
		Map<Field, Object> fieldValues = assignPropertiesToFields(at.getFields(), properties);
		InjectionTarget<T> wrapped = new PropertyInjectionTarget<T>(fieldValues, pit, pit.getInjectionTarget());
		pit.setInjectionTarget(wrapped);
	} catch (Exception e) {
		pit.addDefinitionError(e);
	}
}
 
开发者ID:coders-kitchen,项目名称:CDIProperties,代码行数:24,代码来源:CDIPropertiesExtension.java

示例3: processBean

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
<X> void processBean(@Observes ProcessManagedBean<X> event) {
    AnnotatedType<X> annotatedType = event.getAnnotatedBeanClass();
    Transactional classTx = annotatedType.getAnnotation(Transactional.class);
    for (AnnotatedMethod<? super X> am : annotatedType.getMethods()) {
        Transactional methodTx = am.getAnnotation(Transactional.class);
        if (classTx != null || methodTx != null) {
            Method method = am.getJavaMember();
            Transactional attrType = mergeTransactionAttributes(classTx, methodTx);
            transactionAttributes.put(method, attrType);
        }
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:13,代码来源:TransactionExtension.java

示例4: processAnnotatedType

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
public <T> void processAnnotatedType(
        @Observes @WithAnnotations({ FilterParameters.class, FilterParameter.class }) final ProcessAnnotatedType<T> event) {
    final AnnotatedType<T> annotatedType = event.getAnnotatedType();
    if (annotatedType.isAnnotationPresent(FilterParameters.class)) {
        final FilterParameters annotation = annotatedType.getAnnotation(FilterParameters.class);
        addFilterParameters(annotation);
    }
    if (annotatedType.isAnnotationPresent(FilterParameter.class)) {
        // TODO deal with single parameters
    }
}
 
开发者ID:cbensemann,项目名称:SimplePersistence,代码行数:12,代码来源:HibernateFilterExtension.java

示例5: detectMongoClientDefinition

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
/**
 * Looks for {@link MongoClientDefinition} annotation to capture it.
 * Also Checks if the application contains more than one of these definition
 */
void detectMongoClientDefinition(
        @Observes @WithAnnotations(MongoClientDefinition.class) ProcessAnnotatedType<?> pat) {
    AnnotatedType at = pat.getAnnotatedType();

    MongoClientDefinition md = at.getAnnotation(MongoClientDefinition.class);
    String name = md.name();

    if (mongoDef != null) {
        moreThanOne = true;
    } else {
        mongoDef = md;
    }
}
 
开发者ID:antoinesd,项目名称:javaee-nosql,代码行数:18,代码来源:MongoExtension.java

示例6: alternativeFor

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
public Class<?> alternativeFor(Class<?> javaClass) {
    for (Class<?> alternative : currentAlternativesSet()) {
        AnnotatedType type = beanManager.getExtension(TestScopeExtension.class).decoratedTypeFor(alternative);
        if (type != null) {
            ActivatableTestImplementation activatableTestImplementation = type.getAnnotation(
            ActivatableTestImplementation.class);
            for (Class<?> overriden : activatableTestImplementation.value()) {
                if (overriden.equals(javaClass)) {
                    return alternative;
                }
            }
        }
    }
    return null;
}
 
开发者ID:guhilling,项目名称:cdi-test,代码行数:16,代码来源:InvocationTargetManager.java

示例7: processBean

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
/**
 * Observes {@link ProcessManagedBean} event.
 *
 * @param event {@link ProcessManagedBean} event.
 */
<X> void processBean(
    @Observes ProcessManagedBean<X> event)
{
    boolean sessionBean = event instanceof ProcessSessionBean<?>;
    AnnotatedType<X> annotatedType = event.getAnnotatedBeanClass();
    boolean hasClassInterceptor = annotatedType
        .isAnnotationPresent(Transactional.class);
    if (hasClassInterceptor && sessionBean)
    {
        event.addDefinitionError(new RuntimeException(
            "@Transactional is forbidden for session bean "
                + event.getBean()));
    }
    else
    {
        TransactionAttribute classAttr = annotatedType
            .getAnnotation(TransactionAttribute.class);
        for (AnnotatedMethod<? super X> am : annotatedType.getMethods())
        {
            boolean hasMethodInterceptor = am
                .isAnnotationPresent(Transactional.class);
            if (hasMethodInterceptor && sessionBean)
            {
                event.addDefinitionError(new RuntimeException(
                    "@Transactional is forbidden for session bean method "
                    + am));
            }
            else if (hasClassInterceptor || hasMethodInterceptor)
            {
                TransactionAttribute attr = am
                    .getAnnotation(TransactionAttribute.class);
                Method method = am.getJavaMember();
                TransactionAttributeType attrType =
                    mergeTransactionAttributes(classAttr, attr);
                transactionAttributes.put(method, attrType);
            }
        }
    }
}
 
开发者ID:arkhipov,项目名称:transaction-cdi,代码行数:45,代码来源:TransactionExtension.java

示例8: getLockSupplier

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
protected LockSupplier getLockSupplier(final InvocationContext ic)
{
    final Method key = ic.getMethod();
    LockSupplier operation = lockSuppliers.get(key);
    if (operation == null)
    {
        final Class declaringClass = key.getDeclaringClass();
        final AnnotatedType<Object> annotatedType = beanManager.createAnnotatedType(declaringClass);
        final AnnotatedMethod<?> annotatedMethod = AnnotatedMethods.findMethod(annotatedType, key);

        Locked config = annotatedMethod.getAnnotation(Locked.class);
        if (config == null)
        {
            config = annotatedType.getAnnotation(Locked.class);
        }
        final Locked.LockFactory factory = config.factory() != Locked.LockFactory.class ?
                Locked.LockFactory.class.cast(
                        beanManager.getReference(beanManager.resolve(
                                beanManager.getBeans(
                                        config.factory())),
                                Locked.LockFactory.class, null)) : this;

        final ReadWriteLock writeLock = factory.newLock(annotatedMethod, config.fair());
        final long timeout = config.timeoutUnit().toMillis(config.timeout());
        final Lock lock = config.operation() == READ ? writeLock.readLock() : writeLock.writeLock();

        if (timeout > 0)
        {
            operation = new LockSupplier()
            {
                @Override
                public Lock get()
                {
                    try
                    {
                        if (!lock.tryLock(timeout, TimeUnit.MILLISECONDS))
                        {
                            throw new IllegalStateException("Can't lock for " + key + " in " + timeout + "ms");
                        }
                    }
                    catch (final InterruptedException e)
                    {
                        Thread.interrupted();
                        throw new IllegalStateException("Locking interrupted", e);
                    }
                    return lock;
                }
            };
        }
        else
        {
            operation = new LockSupplier()
            {
                @Override
                public Lock get()
                {
                    lock.lock();
                    return lock;
                }
            };
        }

        final LockSupplier existing = lockSuppliers.putIfAbsent(key, operation);
        if (existing != null)
        {
            operation = existing;
        }
    }
    return operation;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:71,代码来源:LockSupplierStorage.java

示例9: getOrCreateInvoker

import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
Invoker getOrCreateInvoker(final InvocationContext ic)
{
    final Method method = ic.getMethod();
    Invoker i = providers.get(method);
    if (i == null)
    {
        final Class declaringClass = method.getDeclaringClass();
        final AnnotatedType<Object> annotatedType = beanManager.createAnnotatedType(declaringClass);
        final AnnotatedMethod<?> annotatedMethod = AnnotatedMethods.findMethod(annotatedType, method);

        Throttled config = annotatedMethod.getAnnotation(Throttled.class);
        if (config == null)
        {
            config = annotatedType.getAnnotation(Throttled.class);
        }
        Throttling sharedConfig = annotatedMethod.getAnnotation(Throttling.class);
        if (sharedConfig == null)
        {
            sharedConfig = annotatedType.getAnnotation(Throttling.class);
        }

        final Throttling.SemaphoreFactory factory =
                sharedConfig != null && sharedConfig.factory() != Throttling.SemaphoreFactory.class ?
                        Throttling.SemaphoreFactory.class.cast(
                                beanManager.getReference(beanManager.resolve(
                                        beanManager.getBeans(
                                                sharedConfig.factory())),
                                        Throttling.SemaphoreFactory.class, null)) : this;

        final Semaphore semaphore = factory.newSemaphore(
                annotatedMethod,
                sharedConfig != null && !sharedConfig.name().isEmpty() ?
                        sharedConfig.name() : declaringClass.getName(),
                sharedConfig != null && sharedConfig.fair(),
                sharedConfig != null ? sharedConfig.permits() : 1);
        final long timeout = config.timeoutUnit().toMillis(config.timeout());
        final int weigth = config.weight();
        i = new Invoker(semaphore, weigth, timeout);
        final Invoker existing = providers.putIfAbsent(ic.getMethod(), i);
        if (existing != null)
        {
            i = existing;
        }
    }
    return i;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:47,代码来源:InvokerStorage.java


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