Search in sources :

Example 1 with Exclude

use of org.apache.deltaspike.core.api.exclude.Exclude in project deltaspike by apache.

the class ExcludeExtension method vetoBeans.

/**
     * Observer which is vetoing beans based on {@link Exclude}
     * @param processAnnotatedType observed event
     */
@SuppressWarnings("UnusedDeclaration")
protected void vetoBeans(@Observes ProcessAnnotatedType processAnnotatedType, BeanManager beanManager) {
    //we need to do it before the exclude logic to keep the @Exclude support for global alternatives
    if (isGlobalAlternativeActivated) {
        activateGlobalAlternatives(processAnnotatedType, beanManager);
    }
    if (isCustomProjectStageBeanFilterActivated) {
        vetoCustomProjectStageBeans(processAnnotatedType);
    }
    if (!isActivated) {
        return;
    }
    //TODO needs further discussions for a different feature CodiStartupBroadcaster.broadcastStartup();
    //also forces deterministic project-stage initialization
    ProjectStage projectStage = ProjectStageProducer.getInstance().getProjectStage();
    Exclude exclude = extractExcludeAnnotation(processAnnotatedType.getAnnotatedType().getJavaClass());
    if (exclude == null) {
        return;
    }
    if (!evalExcludeWithoutCondition(processAnnotatedType, exclude)) {
        //veto called already
        return;
    }
    if (!evalExcludeInProjectStage(processAnnotatedType, exclude, projectStage)) {
        //veto called already
        return;
    }
    if (!evalExcludeNotInProjectStage(processAnnotatedType, exclude, projectStage)) {
        //veto called already
        return;
    }
    evalExcludeWithExpression(processAnnotatedType, exclude);
}
Also used : Exclude(org.apache.deltaspike.core.api.exclude.Exclude) ProjectStage(org.apache.deltaspike.core.api.projectstage.ProjectStage)

Example 2 with Exclude

use of org.apache.deltaspike.core.api.exclude.Exclude in project deltaspike by apache.

the class ExcludeExtension method extractExcludeAnnotation.

//only support the physical usage and inheritance if @Exclude comes from an abstract class
//TODO re-visit the impact of java.lang.annotation.Inherited (for @Exclude) for the available use-cases
protected Exclude extractExcludeAnnotation(Class<?> currentClass) {
    Exclude result = currentClass.getAnnotation(Exclude.class);
    if (result != null) {
        return result;
    }
    currentClass = currentClass.getSuperclass();
    while (!Object.class.equals(currentClass) && currentClass != null) {
        if (Modifier.isAbstract(currentClass.getModifiers())) {
            result = currentClass.getAnnotation(Exclude.class);
        }
        if (result != null) {
            return result;
        }
        currentClass = currentClass.getSuperclass();
    }
    return null;
}
Also used : Exclude(org.apache.deltaspike.core.api.exclude.Exclude)

Aggregations

Exclude (org.apache.deltaspike.core.api.exclude.Exclude)2 ProjectStage (org.apache.deltaspike.core.api.projectstage.ProjectStage)1