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