javax.enterprise.inject.spi.ProcessAnnotatedType Java Examples
The following examples show how to use
javax.enterprise.inject.spi.ProcessAnnotatedType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AxonCdiExtension.java From cdi with Apache License 2.0 | 6 votes |
/** * Scans all annotated types with the {@link Aggregate} annotation and * collects them for registration. * * @param processAnnotatedType annotated type processing event. */ // Mark: All I need to do here is look up what the aggregate classes are // and what the value of the @Aggregate annotation is. This feels a little // overkill. That said, currently I do need these values in afterBeanDiscovery // and this might be the most efficient way of collecting these anyway. // Other than being a bit ugly, this is not anything that is causing any // functional issues. <T> void processAggregate(@Observes @WithAnnotations({Aggregate.class}) final ProcessAnnotatedType<T> processAnnotatedType) { // TODO Aggregate classes may need to be vetoed so that CDI does not // actually try to manage them. final Class<?> clazz = processAnnotatedType.getAnnotatedType().getJavaClass(); logger.debug("Found aggregate: {}.", clazz); aggregates.add(new AggregateDefinition(clazz)); }
Example #2
Source File: ExcludeExtension.java From deltaspike with Apache License 2.0 | 6 votes |
private boolean evalExcludeNotInProjectStage(ProcessAnnotatedType processAnnotatedType, Exclude exclude, ProjectStage currentlyConfiguredProjectStage) { Class<? extends ProjectStage>[] notIn = exclude.exceptIfProjectStage(); if (notIn.length == 0) { return true; } if (!isInProjectStage(notIn, currentlyConfiguredProjectStage)) { veto(processAnnotatedType, "ExceptIfProjectState"); return false; } return true; }
Example #3
Source File: ExcludeExtension.java From deltaspike with Apache License 2.0 | 6 votes |
private boolean evalExcludeInProjectStage(ProcessAnnotatedType processAnnotatedType, Exclude exclude, ProjectStage currentlyConfiguredProjectStage) { Class<? extends ProjectStage>[] activatedIn = exclude.ifProjectStage(); if (activatedIn.length == 0) { return true; } if (isInProjectStage(activatedIn, currentlyConfiguredProjectStage)) { veto(processAnnotatedType, "IfProjectState"); return false; } return true; }
Example #4
Source File: MappedJsf2ScopeExtension.java From deltaspike with Apache License 2.0 | 6 votes |
protected void convertJsf2Scopes(@Observes ProcessAnnotatedType processAnnotatedType) { if (!isActivated) { return; } //TODO //CodiStartupBroadcaster.broadcastStartup(); Class<? extends Annotation> jsf2ScopeAnnotation = getJsf2ScopeAnnotation(processAnnotatedType); if (jsf2ScopeAnnotation != null && !isBeanWithManagedBeanAnnotation(processAnnotatedType)) { processAnnotatedType.setAnnotatedType( convertBean(processAnnotatedType.getAnnotatedType(), jsf2ScopeAnnotation)); } }
Example #5
Source File: MessageBundleExtension.java From deltaspike with Apache License 2.0 | 6 votes |
@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); } } }
Example #6
Source File: NamingConventionAwareMetadataFilter.java From deltaspike with Apache License 2.0 | 6 votes |
public void ensureNamingConvention(@Observes ProcessAnnotatedType processAnnotatedType) { Class<?> beanClass = processAnnotatedType.getAnnotatedType().getJavaClass(); Named namedAnnotation = beanClass.getAnnotation(Named.class); if (namedAnnotation != null && namedAnnotation.value().length() > 0 && Character.isUpperCase(namedAnnotation.value().charAt(0))) { AnnotatedTypeBuilder builder = new AnnotatedTypeBuilder(); builder.readFromType(beanClass); String beanName = namedAnnotation.value(); String newBeanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1); builder.removeFromClass(Named.class) .addToClass(new NamedLiteral(newBeanName)); processAnnotatedType.setAnnotatedType(builder.create()); } }
Example #7
Source File: ViewConfigExtension.java From deltaspike with Apache License 2.0 | 6 votes |
@SuppressWarnings("UnusedDeclaration") protected void buildViewConfigMetaDataTree(@Observes final ProcessAnnotatedType pat) { if (!isActivated) { return; } buildViewConfigMetaDataTreeFor( pat.getAnnotatedType().getJavaClass(), pat.getAnnotatedType().getAnnotations(), new VetoCallback() { @Override public void veto() { pat.veto(); } }); }
Example #8
Source File: RestClientExtension.java From cxf with Apache License 2.0 | 5 votes |
public void findClients(@Observes @WithAnnotations({RegisterRestClient.class}) ProcessAnnotatedType<?> pat) { Class<?> restClient = pat.getAnnotatedType().getJavaClass(); if (restClient.isInterface()) { restClientClasses.add(restClient); pat.veto(); } else { errors.add(new IllegalArgumentException("The class " + restClient + " is not an interface")); } }
Example #9
Source File: FaultToleranceExtension.java From smallrye-fault-tolerance with Apache License 2.0 | 5 votes |
void changeInterceptorPriority(@Observes ProcessAnnotatedType<FaultToleranceInterceptor> event) { ConfigProvider.getConfig() .getOptionalValue("mp.fault.tolerance.interceptor.priority", Integer.class) .ifPresent(configuredInterceptorPriority -> { event.configureAnnotatedType() .remove(ann -> ann instanceof Priority) .add(new PriorityLiteral(configuredInterceptorPriority)); }); }
Example #10
Source File: JerseyCdiExtension.java From hammock with Apache License 2.0 | 5 votes |
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()); } }
Example #11
Source File: JerseyCdiExtension.java From hammock with Apache License 2.0 | 5 votes |
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()); } }
Example #12
Source File: TomEESecurityExtension.java From tomee with Apache License 2.0 | 5 votes |
void processAuthenticationMechanismDefinitions(@Observes @WithAnnotations({ BasicAuthenticationMechanismDefinition.class, FormAuthenticationMechanismDefinition.class }) final ProcessAnnotatedType<?> processAnnotatedType) { final AnnotatedType<?> annotatedType = processAnnotatedType.getAnnotatedType(); if (annotatedType.isAnnotationPresent(BasicAuthenticationMechanismDefinition.class)) { basicAuthentication.add(annotatedType); } if (annotatedType.isAnnotationPresent(FormAuthenticationMechanismDefinition.class)) { formAuthentication.add(annotatedType); } }
Example #13
Source File: RepositoryExtension.java From deltaspike with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") <X> void processAnnotatedType(@Observes ProcessAnnotatedType<X> event) { if (!isActivated) { return; } if (isVetoed(event.getAnnotatedType())) { event.veto(); } else if (isRepository(event.getAnnotatedType())) { Class<X> repositoryClass = event.getAnnotatedType().getJavaClass(); LOG.log(Level.FINER, "getHandlerClass: Repository annotation detected on {0}", event.getAnnotatedType()); if (Deactivatable.class.isAssignableFrom(repositoryClass) && !ClassDeactivationUtils.isActivated((Class<? extends Deactivatable>) repositoryClass)) { LOG.log(Level.FINER, "Class {0} is Deactivated", repositoryClass); return; } repositoryClasses.add(repositoryClass); REPOSITORY_CLASSES.add(repositoryClass); } }
Example #14
Source File: MappedJsf2ScopeExtension.java From deltaspike with Apache License 2.0 | 5 votes |
private Class<? extends Annotation> getJsf2ScopeAnnotation(ProcessAnnotatedType processAnnotatedType) { for (Class<? extends Annotation> currentJsfScope : this.mappedJsfScopes.keySet()) { if (processAnnotatedType.getAnnotatedType().getJavaClass().isAnnotationPresent(currentJsfScope)) { return currentJsfScope; } } return null; }
Example #15
Source File: PartialBeanBindingExtension.java From deltaspike with Apache License 2.0 | 5 votes |
protected <X> Class<? extends Annotation> extractBindingClass(ProcessAnnotatedType<X> pat) { for (Annotation annotation : pat.getAnnotatedType().getAnnotations()) { if (annotation.annotationType().isAnnotationPresent(PartialBeanBinding.class)) { return annotation.annotationType(); } } return null; }
Example #16
Source File: GlobalInterceptorExtension.java From deltaspike with Apache License 2.0 | 5 votes |
protected void promoteInterceptors(@Observes ProcessAnnotatedType pat) { if (priorityAnnotationInstance == null) //not CDI 1.1 or the extension is deactivated { return; } String beanClassName = pat.getAnnotatedType().getJavaClass().getName(); if (beanClassName.startsWith(DS_PACKAGE_NAME)) { if (pat.getAnnotatedType().isAnnotationPresent(Interceptor.class)) { //noinspection unchecked pat.setAnnotatedType(new GlobalInterceptorWrapper(pat.getAnnotatedType(), priorityAnnotationInstance)); } //currently not needed, because we don't use our interceptors internally -> check for the future else if (!beanClassName.contains(".test.")) { for (Annotation annotation : pat.getAnnotatedType().getAnnotations()) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { //once we see this warning we need to introduce double-call prevention logic due to WELD-1780 LOG.warning(beanClassName + " is an bean from DeltaSpike which is intercepted."); } } } } }
Example #17
Source File: InterDynExtension.java From deltaspike with Apache License 2.0 | 5 votes |
public void processAnnotatedType(@Observes ProcessAnnotatedType pat) { if (enabled) { AnnotatedType at = pat.getAnnotatedType(); String beanClassName = at.getJavaClass().getName(); AnnotatedTypeBuilder atb = null; for (AnnotationRule rule : interceptorRules) { if (beanClassName.matches(rule.getRule())) { if (rule.requiresProxy() && !ClassUtils.isProxyableClass(at.getJavaClass())) { logger.info("Skipping unproxyable class " + beanClassName + " even if matches rule=" + rule.getRule()); return; } if (atb == null) { atb = new AnnotatedTypeBuilder(); atb.readFromType(at); } atb.addToClass(rule.getAdditionalAnnotation()); logger.info("Adding Dynamic Interceptor " + rule.getAdditionalAnnotation() + " to class " + beanClassName ); } } if (atb != null) { pat.setAnnotatedType(atb.create()); } } }
Example #18
Source File: ExcludeExtension.java From deltaspike with Apache License 2.0 | 5 votes |
protected void vetoCustomProjectStageBeans(ProcessAnnotatedType processAnnotatedType) { //currently there is a veto for all project-stage implementations, //but we still need @Typed() for the provided implementations in case of the deactivation of this behaviour if (ProjectStage.class.isAssignableFrom(processAnnotatedType.getAnnotatedType().getJavaClass())) { processAnnotatedType.veto(); } }
Example #19
Source File: ExcludeExtension.java From deltaspike with Apache License 2.0 | 5 votes |
private boolean evalExcludeWithoutCondition(ProcessAnnotatedType processAnnotatedType, Exclude exclude) { if (exclude.ifProjectStage().length == 0 && exclude.exceptIfProjectStage().length == 0 && "".equals(exclude.onExpression())) { veto(processAnnotatedType, "Stateless"); return false; } return true; }
Example #20
Source File: ExcludeExtension.java From deltaspike with Apache License 2.0 | 5 votes |
private void evalExcludeWithExpression(ProcessAnnotatedType processAnnotatedType, Exclude exclude) { if ("".equals(exclude.onExpression())) { return; } if (isDeactivated(exclude, PropertyExpressionInterpreter.class)) { veto(processAnnotatedType, "Expression"); } }
Example #21
Source File: ConfigurationExtension.java From deltaspike with Apache License 2.0 | 5 votes |
@SuppressWarnings("UnusedDeclaration") public void collectUserConfigSources(@Observes ProcessAnnotatedType<? extends PropertyFileConfig> pat) { if (!isActivated) { return; } Class<? extends PropertyFileConfig> pcsClass = pat.getAnnotatedType().getJavaClass(); if (pcsClass.isAnnotation() || pcsClass.isInterface() || pcsClass.isSynthetic() || pcsClass.isArray() || pcsClass.isEnum() ) { // we only like to add real classes return; } if (pat.getAnnotatedType().isAnnotationPresent(Exclude.class)) { // We only pick up PropertyFileConfigs if they are not excluded // This can be the case for PropertyFileConfigs which are registered via java.util.ServiceLoader return; } propertyFileConfigClasses.add(pcsClass); }
Example #22
Source File: ConfigurationExtension.java From deltaspike with Apache License 2.0 | 5 votes |
public void findDynamicConfigurationBeans(@Observes ProcessAnnotatedType<?> pat) { if (!pat.getAnnotatedType().isAnnotationPresent(Configuration.class)) { return; } final Class<?> javaClass = pat.getAnnotatedType().getJavaClass(); if (!javaClass.isInterface()) { return; } dynamicConfigurationBeanClasses.add(javaClass); }
Example #23
Source File: MeecrowaveExtension.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
void onPat(@Observes final ProcessAnnotatedType<?> pat, final BeanManager bm) { final AnnotatedType<?> at = pat.getAnnotatedType(); if (isJaxRsEndpoint(bm, at)) { pat.setAnnotatedType(new JAXRSFIeldInjectionAT(this, at)); } else if (isVetoedMeecrowaveCore(at.getJavaClass().getName())) { pat.veto(); } }
Example #24
Source File: GraphQlClientExtension.java From smallrye-graphql with Apache License 2.0 | 5 votes |
public void registerGraphQlClientApis(@Observes @WithAnnotations(GraphQlClientApi.class) ProcessAnnotatedType<?> type) { Class<?> javaClass = type.getAnnotatedType().getJavaClass(); if (javaClass.isInterface()) { log.info("register {}", javaClass.getName()); apis.add(javaClass); } else { log.error("failed to register", new IllegalArgumentException( "a GraphQlClientApi must be an interface: " + javaClass.getName())); } }
Example #25
Source File: MetricCdiInjectionExtension.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private <X> void findAnnotatedInterfaces(@Observes @WithAnnotations({ Counted.class, Gauge.class, Metered.class, SimplyTimed.class, Timed.class, ConcurrentGauge.class }) ProcessAnnotatedType<X> pat) { Class<X> clazz = pat.getAnnotatedType().getJavaClass(); Package pack = clazz.getPackage(); if (pack != null && pack.getName().equals(GaugeRegistrationInterceptor.class.getPackage().getName())) { return; } if (clazz.isInterface()) { // All declared metrics of an annotated interface are registered during AfterDeploymentValidation metricsInterfaces.add(clazz); } }
Example #26
Source File: MetricCdiInjectionExtension.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private <X> void applyMetricsBinding(@Observes @WithAnnotations({ Gauge.class }) ProcessAnnotatedType<X> pat) { Class<X> clazz = pat.getAnnotatedType().getJavaClass(); Package pack = clazz.getPackage(); if (pack == null || !pack.getName().equals(GaugeRegistrationInterceptor.class.getPackage().getName())) { if (!clazz.isInterface()) { AnnotatedTypeDecorator newPAT = new AnnotatedTypeDecorator<>(pat.getAnnotatedType(), METRICS_BINDING); pat.setAnnotatedType(newPAT); } } }
Example #27
Source File: AxonCdiExtension.java From cdi with Apache License 2.0 | 5 votes |
<T> void processSaga(@Observes @WithAnnotations({Saga.class}) final ProcessAnnotatedType<T> processAnnotatedType) { // TODO Saga classes may need to be vetoed so that CDI does not // actually try to manage them. final Class<?> clazz = processAnnotatedType.getAnnotatedType().getJavaClass(); logger.debug("Found saga: {}.", clazz); sagas.add(new SagaDefinition(clazz)); }
Example #28
Source File: ExcludedBeansExtension.java From weld-junit with Apache License 2.0 | 5 votes |
<T> void excludeBeans(@Observes @WithAnnotations({Scope.class, NormalScope.class}) ProcessAnnotatedType<T> pat) { if (excludedBeanClasses.contains(pat.getAnnotatedType().getJavaClass())) { pat.veto(); return; } Set<Type> typeClosure = pat.getAnnotatedType().getTypeClosure(); for (Type excludedBeanType : excludedBeanTypes) { if (typeClosure.contains(excludedBeanType)) { pat.veto(); return; } } }
Example #29
Source File: TestInstanceInjectionExtension.java From weld-junit with Apache License 2.0 | 5 votes |
<T> void rewriteTestClassScope(@Observes ProcessAnnotatedType<T> pat, BeanManager beanManager) { AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { // Replace any test class's scope with @Singleton Set<Annotation> annotations = annotatedType.getAnnotations().stream() .filter(annotation -> beanManager.isScope(annotation.annotationType())) .collect(Collectors.toSet()); annotations.add(SINGLETON_LITERAL); pat.setAnnotatedType(new AnnotationRewritingAnnotatedType<>(annotatedType, annotations)); } }
Example #30
Source File: ServiceProxyExtension.java From weld-vertx with Apache License 2.0 | 5 votes |
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()); } }