Collections.sort(processors);
Exception failure = null;
RequestContext tempRequestContext = Beans.getReference(RequestContext.class);
SessionContext tempSessionContext = Beans.getReference(SessionContext.class);
ViewContext tempViewContext = Beans.getReference(ViewContext.class);
ConversationContext tempConversationContext = Beans.getReference(ConversationContext.class);
boolean requestActivatedHere = !tempRequestContext.isActive();
boolean sessionActivatedHere = !tempSessionContext.isActive();
boolean viewActivatedHere = !tempViewContext.isActive();
boolean conversationActivatedHere = !tempConversationContext.isActive();
if (!registered) {
if (!tempRequestContext.isActive())
tempRequestContext.activate();
if (!tempSessionContext.isActive())
tempSessionContext.activate();
if (!tempViewContext.isActive())
tempViewContext.activate();
if (!tempConversationContext.isActive())
tempConversationContext.activate();
registered = true;
}
for (Iterator<AnnotatedMethodProcessor> iter = processors.iterator(); iter.hasNext();) {
AnnotatedMethodProcessor<?> processor = iter.next();
try {
ClassLoader classLoader = Reflections.getClassLoaderForClass(processor.getAnnotatedMethod()
.getDeclaringType().getJavaClass().getCanonicalName());
if (Thread.currentThread().getContextClassLoader().equals(classLoader)) {
processor.process();
iter.remove();
}
} catch (Exception cause) {
failure = cause;
}
}
if (processors.isEmpty()) {
if (requestActivatedHere){
tempRequestContext.deactivate();
}
if (sessionActivatedHere){
tempSessionContext.deactivate();
}
if (viewActivatedHere){
tempViewContext.deactivate();
}
if (conversationActivatedHere){
tempConversationContext.deactivate();
}