if (!isExcludedDefaultInterceptors(advisor))
{
lifecycleInterceptorClasses.addAll(defaultInterceptorClasses);
}
Interceptors interceptorsAnnotation = (Interceptors) advisor.resolveAnnotation(Interceptors.class);
List<Class<?>> classInterceptorClasses = new ArrayList<Class<?>>();
if(interceptorsAnnotation != null)
{
for(Class<?> classInterceptorClass : interceptorsAnnotation.value())
{
classInterceptorClasses.add(classInterceptorClass);
// if(!interceptorClasses.contains(classInterceptorClass))
// interceptorClasses.add(classInterceptorClass);
if(!lifecycleInterceptorClasses.contains(classInterceptorClass))
lifecycleInterceptorClasses.add(classInterceptorClass);
}
}
log.debug("Found class interceptors " + classInterceptorClasses);
{
// Ordering of lifecycle interceptors
InterceptorOrder order = (InterceptorOrder) advisor.resolveAnnotation(InterceptorOrder.class);
if(order != null)
{
List<Class<?>> orderedInterceptorClasses = Arrays.asList(order.value());
if(!orderedInterceptorClasses.containsAll(lifecycleInterceptorClasses))
throw new IllegalStateException("EJB3 12.8.2 footnote 59: all applicable lifecycle interceptors must be listed in the interceptor order");
lifecycleInterceptorClasses = orderedInterceptorClasses;
}
}
this.lifecycleInterceptorClasses.addAll(lifecycleInterceptorClasses);
for(Class<?> interceptorClass : lifecycleInterceptorClasses)
{
if(!interceptorClasses.contains(interceptorClass))
interceptorClasses.add(interceptorClass);
}
Class<?> beanClass = advisor.getClazz();
// EJB3 spec says in section 12.7
// "A business method interceptor method may be defined to apply to a specific *business method*
// invocation, rather than to all of the business methods of the bean class."
// So all we need are "public" methods.
for(Method beanMethod : beanClass.getMethods())
{
interceptorsAnnotation = (Interceptors) advisor.resolveAnnotation(beanMethod, Interceptors.class);
List<Class<?>> methodInterceptorClasses = new ArrayList<Class<?>>();
if(interceptorsAnnotation != null)
{
for(Class<?> interceptorClass : interceptorsAnnotation.value())
methodInterceptorClasses.add(interceptorClass);
}
// Interceptors applicable for this bean method
List<Class<?>> methodApplicableInterceptorClasses = new ArrayList<Class<?>>();