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


Java WithAnnotations类代码示例

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


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

示例1: findJobs

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

示例2: alternatives

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

示例3: observeResources

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
/**
 * Discover all classes that implements HealthCheckProcedure
 */
public void observeResources(@Observes @WithAnnotations({Health.class})  ProcessAnnotatedType<? extends HealthCheck> event) {
   AnnotatedType<? extends HealthCheck> annotatedType = event.getAnnotatedType();
   Class<? extends HealthCheck> javaClass = annotatedType.getJavaClass();
   MicroProfileHealthLogger.ROOT_LOGGER.debugf("Discovered health check procedure %s", javaClass);
   delegates.add(annotatedType);
}
 
开发者ID:jmesnil,项目名称:wildfly-microprofile-health,代码行数:10,代码来源:CDIExtension.java

示例4: processAnnotatedType

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
<T> void processAnnotatedType(@Observes @WithAnnotations(EnableSnoopEEClient.class) ProcessAnnotatedType<T> pat) {

        // workaround for WELD bug revealed by JDK8u60
        final ProcessAnnotatedType<T> snoopAnnotated = pat;

        LOGGER.config(() -> "Found @EnableSnoopEEClient annotated class: " + snoopAnnotated.getAnnotatedType().getJavaClass().getName());
        snoopEnabled = true;
        serviceName = snoopAnnotated.getAnnotatedType().getAnnotation(EnableSnoopEEClient.class).serviceName();
        LOGGER.config(() -> "SnoopEE Service name is: " + serviceName);
    }
 
开发者ID:ivargrimstad,项目名称:snoopee,代码行数:11,代码来源:SnoopEEScannerExtension.java

示例5: findServiceInterfaces

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的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());
    }
}
 
开发者ID:weld,项目名称:weld-vertx,代码行数:8,代码来源:ServiceProxyExtension.java

示例6: observeResources

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
public <T> void observeResources(@Observes @WithAnnotations({Health.class}) ProcessAnnotatedType<T> event) {

        AnnotatedType<T> annotatedType = event.getAnnotatedType();
        Class<T> javaClass = annotatedType.getJavaClass();
        for (Class<?> intf : javaClass.getInterfaces()) {
            if (intf.getName().equals(HealthCheck.class.getName())) {
                log.info(">> Discovered health check procedure " + javaClass);
                delegates.add(annotatedType);
            }
        }
    }
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:12,代码来源:HealthExtension.java

示例7: processAnnotatedType

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
<T> void processAnnotatedType(@Observes @WithAnnotations(EnableSnoopClient.class) ProcessAnnotatedType<T> pat) {

        // workaround for WELD bug revealed by JDK8u60
        final ProcessAnnotatedType<T> snoopAnnotated = pat;

        LOGGER.config(() -> "Found @EnableSnoopClient annotated class: " + snoopAnnotated.getAnnotatedType().getJavaClass().getName());
        snoopEnabled = true;
        serviceName = snoopAnnotated.getAnnotatedType().getAnnotation(EnableSnoopClient.class).serviceName();
        LOGGER.config(() -> "Snoop Service name is: " + serviceName);
    }
 
开发者ID:ivargrimstad,项目名称:snoop,代码行数:11,代码来源:SnoopScannerExtension.java

示例8: processAnnotatedType

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
<T> void processAnnotatedType(@Observes @WithAnnotations({EnableEurekaClient.class}) ProcessAnnotatedType<T> pat) {
   
   LOGGER.config(() -> "Found @EnableEurekaClient annotated class: " + pat.getAnnotatedType().getJavaClass().getName());
   eurekaEnabled = true;
   applicationName = pat.getAnnotatedType().getAnnotation(EnableEurekaClient.class).name();
   LOGGER.config(() -> "Eureka application name is: " + applicationName);
}
 
开发者ID:ivargrimstad,项目名称:snoop,代码行数:8,代码来源:SnoopEurekaScannerExtension.java

示例9: processAnnotatedType

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

示例10: detectMongoClientDefinition

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

示例11: observeResources

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
public <T> void observeResources(@WithAnnotations({ Path.class }) @Observes ProcessAnnotatedType<T> event) {
    AnnotatedType<T> annotatedType = event.getAnnotatedType();

    if (!annotatedType.getJavaClass().isInterface()) {
        this.resources.add(annotatedType.getJavaClass());
    }
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:8,代码来源:JerseyCdiExtension.java

示例12: observeProviders

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
public <T> void observeProviders(@WithAnnotations({ Provider.class }) @Observes ProcessAnnotatedType<T> event) {
    AnnotatedType<T> annotatedType = event.getAnnotatedType();

    if (!annotatedType.getJavaClass().isInterface()) {
        this.providers.add(annotatedType.getJavaClass());
    }
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:8,代码来源:JerseyCdiExtension.java

示例13: processStandaloneController

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
public <T> void processStandaloneController(@WithAnnotations({StandaloneController.class}) @Observes ProcessAnnotatedType<T> event) {
    LOGGER.info("Processing standalone controller class: {}", event.getAnnotatedType().getJavaClass());
    StandaloneController a = event.getAnnotatedType().getJavaClass().getAnnotation(StandaloneController.class);
    if (a != null && ControllerUtils.useEmbeddedController()) {
        LOGGER.info("Removing standalone controller class {} from CDI context", event.getAnnotatedType().getJavaClass());
        event.veto();
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:9,代码来源:ControllerExtension.java

示例14: processEmbeddedController

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
public <T> void processEmbeddedController(@WithAnnotations({EmbeddedController.class}) @Observes ProcessAnnotatedType<T> event) {
    LOGGER.info("Processing embedded controller class: {}", event.getAnnotatedType().getJavaClass());
    EmbeddedController a = event.getAnnotatedType().getJavaClass().getAnnotation(EmbeddedController.class);
    if (a != null && ControllerUtils.useEmbeddedController() == false) {
        LOGGER.info("Removing embedded controller class {} from CDI context", event.getAnnotatedType().getJavaClass());
        event.veto();
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:9,代码来源:ControllerExtension.java

示例15: processAnnotatedTypeWithAnnotations

import javax.enterprise.inject.spi.WithAnnotations; //导入依赖的package包/类
<T> void processAnnotatedTypeWithAnnotations(
		@Observes @WithAnnotations({ Named.class }) ProcessAnnotatedType<T> pat) {
	logger.info("scanning type: " + pat.getAnnotatedType().getJavaClass().getName());
	processAnnotatedTypeWithAnnotations++;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:6,代码来源:ObserverExtension.java


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