}
private Map<InterceptionType, List<MethodReference>> buildMethodMap(ClassReference interceptorClass, boolean isTargetClass)
{
Map<InterceptionType, List<MethodReference>> methodMap = new HashMap<InterceptionType, List<MethodReference>>();
ClassReference currentClass = interceptorClass;
Set<MethodHolder> foundMethods = new HashSet<MethodHolder>();
do
{
Set<InterceptionType> detectedInterceptorTypes = new HashSet<InterceptionType>();
for (MethodReference method : currentClass.getDeclaredMethods())
{
for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes())
{
if (InterceptionUtils.isInterceptorMethod(interceptionType, method, isTargetClass))
{
if (methodMap.get(interceptionType) == null)
{
methodMap.put(interceptionType, new LinkedList<MethodReference>());
}
if (detectedInterceptorTypes.contains(interceptionType))
{
throw new InterceptorMetadataException("Same interception type cannot be specified twice on the same class");
}
else
{
detectedInterceptorTypes.add(interceptionType);
}
// add method in the list - if it is there already, it means that it has been added by a subclass
ReflectionUtils.ensureAccessible(method.getJavaMethod());
if (!foundMethods.contains(MethodHolder.of(method, false)))
{
methodMap.get(interceptionType).add(0, method);
}
}
}
foundMethods.add(MethodHolder.of(method, false));
}
currentClass = currentClass.getSuperclass();
}
while (!Object.class.equals(currentClass.getJavaClass()));
return methodMap;
}