Search in sources :

Example 1 with AsyncEntityEventProcessor

use of eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor in project CzechIdMng by bcvsolutions.

the class DefaultEntityEventManager method evaluatePriority.

/**
 * Evaluate event priority by registered processors
 *
 * @param event
 * @param registeredProcessors
 * @return
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected PriorityType evaluatePriority(EntityEvent<Identifiable> event, List<EntityEventProcessor> registeredProcessors) {
    PriorityType priority = null;
    for (EntityEventProcessor processor : registeredProcessors) {
        if (!(processor instanceof AsyncEntityEventProcessor)) {
            continue;
        }
        AsyncEntityEventProcessor asyncProcessor = (AsyncEntityEventProcessor) processor;
        PriorityType processorPriority = asyncProcessor.getPriority(event);
        if (processorPriority == null) {
            // processor doesn't vote about priority - preserve original event priority.
            continue;
        }
        if (priority == null || processorPriority.getPriority() < priority.getPriority()) {
            priority = processorPriority;
        }
        if (priority == PriorityType.IMMEDIATE) {
            // nothing is higher
            break;
        }
    }
    // 
    return priority;
}
Also used : PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) EntityEventProcessor(eu.bcvsolutions.idm.core.api.event.EntityEventProcessor) AsyncEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor) AsyncEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor)

Example 2 with AsyncEntityEventProcessor

use of eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor in project CzechIdMng by bcvsolutions.

the class DefaultEntityEventManager method evaluatePriority.

/**
 * Evaluate event priority by registered processors
 *
 * @param event
 * @param registeredProcessors
 * @return
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected PriorityType evaluatePriority(EntityEvent<?> event, List<EntityEventProcessor> registeredProcessors) {
    PriorityType priority = null;
    for (EntityEventProcessor processor : registeredProcessors) {
        if (!(processor instanceof AsyncEntityEventProcessor)) {
            continue;
        }
        AsyncEntityEventProcessor asyncProcessor = (AsyncEntityEventProcessor) processor;
        PriorityType processorPriority = asyncProcessor.getPriority(event);
        if (processorPriority == null) {
            // processor doesn't vote about priority - preserve original event priority.
            continue;
        }
        if (priority == null || processorPriority.getPriority() < priority.getPriority()) {
            priority = processorPriority;
        }
        if (priority == PriorityType.IMMEDIATE) {
            // nothing is higher
            break;
        }
    }
    // 
    return priority;
}
Also used : PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) EntityEventProcessor(eu.bcvsolutions.idm.core.api.event.EntityEventProcessor) EmptyEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.EmptyEntityEventProcessor) AsyncEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor) AsyncEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor)

Aggregations

PriorityType (eu.bcvsolutions.idm.core.api.domain.PriorityType)2 AsyncEntityEventProcessor (eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor)2 EntityEventProcessor (eu.bcvsolutions.idm.core.api.event.EntityEventProcessor)2 EmptyEntityEventProcessor (eu.bcvsolutions.idm.core.api.event.EmptyEntityEventProcessor)1