Java Code Examples for javax.enterprise.inject.spi.ProcessAnnotatedType#veto()

The following examples show how to use javax.enterprise.inject.spi.ProcessAnnotatedType#veto() . 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: ExcludedBeansExtension.java    From weld-junit with Apache License 2.0 5 votes vote down vote up
<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 2
Source File: MeecrowaveExtension.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
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 3
Source File: RestClientExtension.java    From cxf with Apache License 2.0 5 votes vote down vote up
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 4
Source File: RepositoryExtension.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: ExcludeExtension.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
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 6
Source File: VertxProbeExtension.java    From weld-vertx with Apache License 2.0 4 votes vote down vote up
public void vetoProbeHandlers(@Observes ProcessAnnotatedType<? extends Handler<RoutingContext>> event) {
    if (event.getAnnotatedType().getJavaClass().getName().startsWith(PROBE_PACKAGE)) {
        event.veto();
    }
}
 
Example 7
Source File: TomEEOpenAPIExtension.java    From tomee with Apache License 2.0 4 votes vote down vote up
void vetoJacksonIfNotHere(@Observes final ProcessAnnotatedType<JacksonOpenAPIYamlBodyWriter> event) {
    if (!jacksonIsPresent) {
        event.veto();
    }
}
 
Example 8
Source File: MPJWTCDIExtension.java    From tomee with Apache License 2.0 4 votes vote down vote up
void pat(@Observes final ProcessAnnotatedType<BValInterceptor> stockBvalInterceptor) {
    stockBvalInterceptor.veto();
}
 
Example 9
Source File: MakeJCacheCDIInterceptorFriendly.java    From commons-jcs with Apache License 2.0 4 votes vote down vote up
protected void vetoScannedCDIJCacheHelperQualifiers(final @Observes ProcessAnnotatedType<CDIJCacheHelper> pat) {
    if (!needHelper) { // already seen, shouldn't really happen,just a protection
        pat.veto();
    }
    needHelper = false;
}
 
Example 10
Source File: ConverterAndValidatorProxyExtension.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public <X> void findConverterAndValidatorsWhichNeedProxiesForDependencyInjectionSupport(
        @Observes ProcessAnnotatedType<X> pat, BeanManager beanManager)
{
    if (!this.isActivated)
    {
        return;
    }

    Class<X> beanClass = pat.getAnnotatedType().getJavaClass();

    if (!(Converter.class.isAssignableFrom(beanClass) || (Validator.class.isAssignableFrom(beanClass))))
    {
        return;
    }

    Bean<X> bean = new BeanBuilder<X>(beanManager).readFromType(pat.getAnnotatedType()).create();
    // veto normal converters/validators -> they will get excluded from the special handling later on
    if (!hasInjectionPoints(bean) && !hasNormalScopeAnnotation(bean, beanManager))
    {
        pat.veto();
        return;
    }

    // converters/validators without properties for tags, will be handled by the corresponding manual wrapper
    if (!hasPublicProperty(beanClass))
    {
        return;
    }

    if (!(Modifier.isFinal(beanClass.getModifiers())))
    {
        this.classesToProxy.add(beanClass);
        pat.veto();
    }
    else
    {
        LOG.warning("To use dependency-injection in converters/validators with properties, " +
                "you they aren't allowed to be 'final'.");
    }
}
 
Example 11
Source File: ExcludeExtension.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
private void veto(ProcessAnnotatedType processAnnotatedType, String vetoType)
{
    processAnnotatedType.veto();
    LOG.finer(vetoType + " based veto for bean with type: " +
            processAnnotatedType.getAnnotatedType().getJavaClass());
}