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


Java AnnotatedMethod类代码示例

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


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

示例1: getAnnotatedMember

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <X, A extends AnnotatedMember<? super X>> A getAnnotatedMember(Class<X> javaClass, String memberName,
		BeanManager beanManager) {
	AnnotatedType<X> type = beanManager.createAnnotatedType(javaClass);
	for (AnnotatedField<? super X> field : type.getFields()) {
		if (field.getJavaMember().getName().equals(memberName)) {
			return (A) field;
		}
	}
	for (AnnotatedMethod<? super X> method : type.getMethods()) {
		if (method.getJavaMember().getName().equals(memberName)) {
			return (A) method;
		}
	}
	throw new IllegalArgumentException("Member " + memberName + " not found on " + javaClass);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:17,代码来源:InjectSPITestCase.java

示例2: getReplacement

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
public <T> AnnotatedType<T> getReplacement(AnnotatedType<T> originalType) {

        boolean modified = false;
        Set<AnnotatedMethod<? super T>> methods = new LinkedHashSet<>();

        for (AnnotatedMethod<? super T> originalMethod : originalType.getMethods()) {
            AnnotatedMethod<? super T> replacement = getReplacement(originalType, originalMethod);
            if (replacement != null) {
                methods.add(replacement);
                modified = true;
            } else {
                methods.add(originalMethod);
            }
        }

        if (modified) {
            return new AnnotatedTypeWrapper<T>(originalType, methods);
        }
        return null;

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

示例3: findJobs

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
<T> void findJobs( @Observes @WithAnnotations({Cron.class}) ProcessAnnotatedType<T> pat, BeanManager beanManager )
{
    // Ensure we are named otherwise job won't fire as we can't locate it
    AnnotatedType<?> type = pat.getAnnotatedType();
    Class<?> clazz = type.getJavaClass();
    CDIUtils.addTypeAnnotation( pat, Named.class, () -> new NamedImpl( "Schedule_" + (id++) ) );

    if( type.isAnnotationPresent( Cron.class ) ) {
        if( Job.class.isAssignableFrom( clazz ) ) {
            jobClasses.add( clazz );
        }
        else {
            throw new UnsupportedOperationException( "@Cron on type must implement Job" );
        }
    }
    else {
        for( AnnotatedMethod<?> meth: type.getMethods() ) {
            if( meth.isAnnotationPresent( Cron.class ) ) {
                jobClasses.add( clazz );
            }
        }
    }
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:24,代码来源:SchedulerExtension.java

示例4: nameStrategy

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
private static CamelContextNameStrategy nameStrategy(Annotated annotated) {
    if (annotated.isAnnotationPresent(ContextName.class)) {
        return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value());
    } else if (annotated.isAnnotationPresent(Named.class)) {
        // TODO: support stereotype with empty @Named annotation
        String name = annotated.getAnnotation(Named.class).value();
        if (name.isEmpty()) {
            if (annotated instanceof AnnotatedField) {
                name = ((AnnotatedField) annotated).getJavaMember().getName();
            } else if (annotated instanceof AnnotatedMethod) {
                name = ((AnnotatedMethod) annotated).getJavaMember().getName();
                if (name.startsWith("get")) {
                    name = decapitalize(name.substring(3));
                }
            } else {
                name = decapitalize(getRawType(annotated.getBaseType()).getSimpleName());
            }
        }
        return new ExplicitCamelContextNameStrategy(name);
    } else {
        // Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created
        return new CdiCamelContextNameStrategy();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:CamelContextProducer.java

示例5: hasAnnotation

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
static boolean hasAnnotation(AnnotatedType<?> type, Class<? extends Annotation> annotation) {
    if (type.isAnnotationPresent(annotation)) {
        return true;
    }
    for (AnnotatedMethod<?> method : type.getMethods()) {
        if (method.isAnnotationPresent(annotation)) {
            return true;
        }
    }
    for (AnnotatedConstructor<?> constructor : type.getConstructors()) {
        if (constructor.isAnnotationPresent(annotation)) {
            return true;
        }
    }
    for (AnnotatedField<?> field : type.getFields()) {
        if (field.isAnnotationPresent(annotation)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CdiSpiHelper.java

示例6: alternatives

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
/**
 * Activates the alternatives declared with {@code @Beans} globally for the
 * application.
 * <p/>
 * For every types and every methods of every types declared with
 * {@link Beans#alternatives()}, the {@code Priority} annotation is added
 * so that the corresponding alternatives are selected globally for the
 * entire application.
 *
 * @see Beans
 */
private <T> void alternatives(@Observes @WithAnnotations(Alternative.class) ProcessAnnotatedType<T> pat) {
    AnnotatedType<T> type = pat.getAnnotatedType();

    if (!Arrays.asList(beans.alternatives()).contains(type.getJavaClass())) {
        // Only select globally the alternatives that are declared with @Beans
        return;
    }

    Set<AnnotatedMethod<? super T>> methods = new HashSet<>();
    for (AnnotatedMethod<? super T> method : type.getMethods()) {
        if (method.isAnnotationPresent(Alternative.class) && !method.isAnnotationPresent(Priority.class)) {
            methods.add(new AnnotatedMethodDecorator<>(method, PriorityLiteral.of(APPLICATION)));
        }
    }

    if (type.isAnnotationPresent(Alternative.class) && !type.isAnnotationPresent(Priority.class)) {
        pat.setAnnotatedType(new AnnotatedTypeDecorator<>(type, PriorityLiteral.of(APPLICATION), methods));
    } else if (!methods.isEmpty()) {
        pat.setAnnotatedType(new AnnotatedTypeDecorator<>(type, methods));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:CamelCdiTestExtension.java

示例7: nameStrategy

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
private static CamelContextNameStrategy nameStrategy(Annotated annotated) {
    if (annotated.isAnnotationPresent(ContextName.class)) {
        return new ExplicitCamelContextNameStrategy(annotated.getAnnotation(ContextName.class).value());
    } else if (annotated.isAnnotationPresent(Named.class)) {
        // TODO: support stereotype with empty @Named annotation
        String name = annotated.getAnnotation(Named.class).value();
        if (name.isEmpty()) {
            if (annotated instanceof AnnotatedField) {
                name = ((AnnotatedField) annotated).getJavaMember().getName();
            } else if (annotated instanceof AnnotatedMethod) {
                name = ((AnnotatedMethod) annotated).getJavaMember().getName();
                if (name.startsWith("get"))
                    name = decapitalize(name.substring(3));
            } else {
                name = decapitalize(getRawType(annotated.getBaseType()).getSimpleName());
            }
        }
        return new ExplicitCamelContextNameStrategy(name);
    } else {
        // Use a specific naming strategy for Camel CDI as the default one increments the suffix for each CDI proxy created
        return new CdiCamelContextNameStrategy();
    }
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:24,代码来源:CamelContextProducer.java

示例8: compare

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
public int compare(AnnotatedMethod<? super T> arg0, AnnotatedMethod<? super T> arg1)
{
    int result = callableComparator.compare(arg0, arg1);
    if (result != 0)
    {
        return result;
    }
    for (int i = 0; i < arg0.getJavaMember().getParameterTypes().length; ++i)
    {
        Class<?> p0 = arg0.getJavaMember().getParameterTypes()[i];
        Class<?> p1 = arg1.getJavaMember().getParameterTypes()[i];
        result = p0.getName().compareTo(p1.getName());
        if (result != 0)
        {
            return result;
        }
    }
    return 0;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:20,代码来源:Annotateds.java

示例9: isHandler

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
/**
 * Determines if the given method is a handler by looking for the {@link Handles} annotation on a parameter.
 *
 * @param method method to search
 * @return true if {@link Handles} is found, false otherwise
 */
public static boolean isHandler(final AnnotatedMethod<?> method)
{
    if (method == null)
    {
        throw new IllegalArgumentException("Method must not be null");
    }

    for (AnnotatedParameter<?> param : method.getParameters())
    {
        if (param.isAnnotationPresent(Handles.class) || param.isAnnotationPresent(BeforeHandles.class))
        {
            return true;
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:24,代码来源:HandlerMethodImpl.java

示例10: findHandlerParameter

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
public static AnnotatedParameter<?> findHandlerParameter(final AnnotatedMethod<?> method)
{
    if (!isHandler(method))
    {
        throw new IllegalArgumentException("Method is not a valid handler");
    }

    AnnotatedParameter<?> returnParam = null;

    for (AnnotatedParameter<?> param : method.getParameters())
    {
        if (param.isAnnotationPresent(Handles.class) || param.isAnnotationPresent(BeforeHandles.class))
        {
            returnParam = param;
            break;
        }
    }

    return returnParam;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:21,代码来源:HandlerMethodImpl.java

示例11: 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

示例12: newLock

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
@Override
public ReadWriteLock newLock(final AnnotatedMethod<?> method, final boolean fair)
{
    final String name = method.getJavaMember().getDeclaringClass().getName();
    ReadWriteLock lock = locks.get(name);
    if (lock == null)
    {
        lock = new ReentrantReadWriteLock(fair);
        final ReadWriteLock existing = locks.putIfAbsent(name, lock);
        if (existing != null)
        {
            lock = existing;
        }
    }
    return lock;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:LockSupplierStorage.java

示例13: findMethod

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
public static AnnotatedMethod<?> findMethod(final AnnotatedType<?> type, final Method method)
{
    AnnotatedMethod<?> annotatedMethod = null;
    for (final AnnotatedMethod<?> am : type.getMethods())
    {
        if (am.getJavaMember().equals(method))
        {
            annotatedMethod = am;
            break;
        }
    }
    if (annotatedMethod == null)
    {
        throw new IllegalStateException("No annotated method for " + method);
    }
    return annotatedMethod;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:AnnotatedMethods.java

示例14: newSemaphore

import javax.enterprise.inject.spi.AnnotatedMethod; //导入依赖的package包/类
@Override
public Semaphore newSemaphore(final AnnotatedMethod<?> method, final String name,
                              final boolean fair, final int permits)
{
    Semaphore semaphore = semaphores.get(name);
    if (semaphore == null)
    {
        semaphore = new Semaphore(permits, fair);
        final Semaphore existing = semaphores.putIfAbsent(name, semaphore);
        if (existing != null)
        {
            semaphore = existing;
        }
    }
    return semaphore;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:InvokerStorage.java

示例15: 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


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