* {@link ConfigurableComponent}, then its init() method will be called.
*/
protected void addInterceptor(Map<LifecycleStage, Collection<Interceptor>> map,
Interceptor interceptor) {
Class<? extends Interceptor> type = interceptor.getClass();
Intercepts intercepts = type.getAnnotation(Intercepts.class);
if (intercepts == null) {
log.error("An interceptor of type ", type.getName(), " was configured ",
"but was not marked with an @Intercepts annotation. As a ",
"result it is not possible to determine at which ",
"lifecycle stages the interceptor should be applied. This ",
"interceptor will be ignored.");
return;
}
else {
log.debug("Configuring interceptor '", type.getSimpleName(),
"', for lifecycle stages: ", intercepts.value());
}
// call init() if the interceptor implements ConfigurableComponent
if (interceptor instanceof ConfigurableComponent) {
try {
((ConfigurableComponent) interceptor).init(this);
}
catch (Exception e) {
log.error("Error initializing interceptor of type " + type.getName(), e);
}
}
for (LifecycleStage stage : intercepts.value()) {
Collection<Interceptor> stack = map.get(stage);
if (stack == null) {
stack = new LinkedList<Interceptor>();
map.put(stage, stack);
}