本文整理汇总了Java中javax.enterprise.inject.spi.AnnotatedType.isAnnotationPresent方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedType.isAnnotationPresent方法的具体用法?Java AnnotatedType.isAnnotationPresent怎么用?Java AnnotatedType.isAnnotationPresent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.enterprise.inject.spi.AnnotatedType
的用法示例。
在下文中一共展示了AnnotatedType.isAnnotationPresent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findJobs
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的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 );
}
}
}
}
示例2: addTypeAnnotation
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
/**
* Ensure we have an annotation present
* <p>
* @param <T>
* @param pat
* @param clazz
* @param s
* <p>
* @return
*/
public static <T> AnnotatedType<T> addTypeAnnotation( ProcessAnnotatedType<T> pat, Class<? extends Annotation> clazz, Supplier<Annotation> s )
{
AnnotatedType<T> t = pat.getAnnotatedType();
if( !t.isAnnotationPresent( clazz ) ) {
MutableAnnotatedType<T> mat;
if( t instanceof MutableAnnotatedType ) {
mat = (MutableAnnotatedType<T>) t;
}
else {
mat = new MutableAnnotatedType<>( t );
pat.setAnnotatedType( mat );
}
mat.add( s.get() );
return mat;
}
return t;
}
示例3: hasAnnotation
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的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;
}
示例4: alternatives
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的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));
}
}
示例5: 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);
}
}
示例6: detectInterfaces
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
protected void detectInterfaces(@Observes ProcessAnnotatedType processAnnotatedType)
{
if (!isActivated)
{
return;
}
AnnotatedType<?> type = processAnnotatedType.getAnnotatedType();
if (type.isAnnotationPresent(MessageBundle.class))
{
if (validateMessageBundle(type.getJavaClass()))
{
messageBundleTypes.add(type);
}
}
}
示例7: findServiceInterfaces
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
void findServiceInterfaces(@Observes @WithAnnotations(ProxyGen.class) ProcessAnnotatedType<?> event, BeanManager beanManager) {
AnnotatedType<?> annotatedType = event.getAnnotatedType();
if (annotatedType.isAnnotationPresent(ProxyGen.class) && annotatedType.getJavaClass().isInterface()) {
LOGGER.debug("Service interface {0} discovered", annotatedType.getJavaClass());
serviceInterfaces.add(annotatedType.getJavaClass());
}
}
示例8: forEachType
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
/**
* Pass an AnnotatedType to a consumer if an annotation is present
*
* @param <T>
* @param pat
* @param annotationType
* @param c
*/
public static <T> void forEachType( ProcessAnnotatedType<T> pat, Class<? extends Annotation> annotationType,
Consumer<? super AnnotatedType<? extends Object>> c )
{
AnnotatedType<?> type = pat.getAnnotatedType();
if( type.isAnnotationPresent( annotationType ) ) {
c.accept( type );
}
}
示例9: 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
}
}
示例10: 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);
}
}
}
}
示例11: processAnnotatedType
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
/**
* Collect types of all mappers annotated with Mapper.
*
* @param <T> the generic type
* @param pat the pat
*/
@SuppressWarnings("UnusedDeclaration")
protected <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> pat) {
final AnnotatedType<T> at = pat.getAnnotatedType();
if (at.isAnnotationPresent(Mapper.class)) {
LOGGER.log(Level.INFO, "MyBatis CDI Module - Found class with @Mapper-annotation: {0}",
at.getJavaClass().getSimpleName());
this.mapperTypes.add(at.getBaseType());
}
}
示例12: isRepository
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
private <X> boolean isRepository(AnnotatedType<X> annotatedType)
{
return (annotatedType.isAnnotationPresent(Repository.class) ||
annotatedType.getJavaClass().isAnnotationPresent(Repository.class)) &&
!InvocationHandler.class.isAssignableFrom(annotatedType.getJavaClass());
}
示例13: processAnnotatedType
import javax.enterprise.inject.spi.AnnotatedType; //导入方法依赖的package包/类
public <X> void processAnnotatedType(@Observes ProcessAnnotatedType<X> pat) {
AnnotatedType<?> type = pat.getAnnotatedType();
if (type.isAnnotationPresent(Config.class)) {
schemas.add(pat.getAnnotatedType().getJavaClass());
}
}