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


Java AnnotatedMethod.getAnnotation方法代码示例

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


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

示例1: getReplacement

import javax.enterprise.inject.spi.AnnotatedMethod; //导入方法依赖的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: getOrCreatePool

import javax.enterprise.inject.spi.AnnotatedMethod; //导入方法依赖的package包/类
protected ExecutorService getOrCreatePool(final InvocationContext ic)
{
    final Method method = ic.getMethod();
    ExecutorService executorService = configByMethod.get(method);
    if (executorService == null)
    {
        final AnnotatedType<?> annotatedType = beanManager.createAnnotatedType(method.getDeclaringClass());
        final AnnotatedMethod<?> annotatedMethod = AnnotatedMethods.findMethod(annotatedType, method);
        final Futureable methodConfig = annotatedMethod.getAnnotation(Futureable.class);
        final ExecutorService instance = manager.find(
                (methodConfig == null ? annotatedType.getAnnotation(Futureable.class) : methodConfig).value());
        configByMethod.putIfAbsent(method, instance);
        executorService = instance;
    }
    return executorService;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:DefaultFutureableStrategy.java

示例3: processBean

import javax.enterprise.inject.spi.AnnotatedMethod; //导入方法依赖的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: processBean

import javax.enterprise.inject.spi.AnnotatedMethod; //导入方法依赖的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

示例5: GenericConfig

import javax.enterprise.inject.spi.AnnotatedMethod; //导入方法依赖的package包/类
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);
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:7,代码来源:GenericConfig.java

示例6: getLockSupplier

import javax.enterprise.inject.spi.AnnotatedMethod; //导入方法依赖的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

示例7: getOrCreateInvoker

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