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