/** * @param type * @return */ public static Set<Class<? extends Throwable>> findAbsorptionLevels( final Class<?> type, final Method method) { final Set<Class<? extends Throwable>> result; final Staged staged = method.getAnnotation(Staged.class); // override class-level annotation by method-level annotation if (staged == null) result = findAbsorptionLevels(type); else result = subsume(toSignatureString(method), staged.ignore()); LOG.trace("Absorption for " + toSignatureString(method) + ": " + result); return result; }
/** @param type */ private static synchronized void findHandlers(final Class<?> type) { LOG.trace("Caching handlers for " + type.getName()); final Map<StageEvent, SortedMap<Method, Staged>> handlersByEvent = type.getSuperclass() == Object.class || type.getSuperclass() == null ? new EnumMap<StageEvent, SortedMap<Method, Staged>>(StageEvent.class) : findEventHandlers(type.getSuperclass()); stageEventHandlerCache.put(type, handlersByEvent); final Map<String, SortedMap<Method, Staged>> handlersByStage = type.getSuperclass() == Object.class || type.getSuperclass() == null ? new HashMap<String, SortedMap<Method, Staged>>() : findStageHandlers(type.getSuperclass()); customStageHandlerCache.put(type, handlersByStage); for (Class<?> iface : type.getInterfaces()) { handlersByEvent.putAll(findEventHandlers(iface)); handlersByStage.putAll(findStageHandlers(iface)); } for (Method method : type.getDeclaredMethods()) { final Staged ann = method.getAnnotation(Staged.class); if (ann == null) continue; for (StageEvent on : ann.on()) { SortedMap<Method, Staged> handlers = handlersByEvent.get(on); if (handlers == null) { handlers = new TreeMap<>(METHOD_COMPARATOR); handlersByEvent.put(on, handlers); } handlers.put(method, ann); } for (String stage : ann.onCustom()) { SortedMap<Method, Staged> handlers = handlersByStage.get(stage); if (handlers == null) { handlers = new TreeMap<>(METHOD_COMPARATOR); handlersByStage.put(stage, handlers); } handlers.put(method, ann); } } // if (handlersByEvent.isEmpty() && handlersByStage.isEmpty()) // LOG.warn("No @" + Staged.class.getSimpleName() // + " annotations found in target: " + type.getName()); }