{
Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(type.getAnnotations());
Class<?> clazz = type.getJavaClass();
boolean hasClassInterceptors = false;
AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
if (annotationManager.getInterceptorBindingMetaAnnotations(anns).length > 0)
{
hasClassInterceptors = true;
}
else
{
Annotation[] stereoTypes = annotationManager.getStereotypeMetaAnnotations(anns);
for (Annotation stero : stereoTypes)
{
if (annotationManager.hasInterceptorBindingMetaAnnotation(stero.annotationType().getDeclaredAnnotations()))
{
hasClassInterceptors = true;
break;
}
}
}
if(ClassUtil.isFinal(clazz.getModifiers()) && hasClassInterceptors)
{
throw new WebBeansConfigurationException("Final managed bean class with name : " + clazz.getName() + " can not define any InterceptorBindings");
}
Set<AnnotatedMethod<? super X>> methods = type.getMethods();
for(AnnotatedMethod<? super X> methodA : methods)
{
Method method = methodA.getJavaMember();
int modifiers = method.getModifiers();
if (!method.isSynthetic() && !method.isBridge() && !Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && ClassUtil.isFinal(modifiers))
{
if (hasClassInterceptors)
{
throw new WebBeansConfigurationException("Maanged bean class : " + clazz.getName()
+ " can not define non-static, non-private final methods. Because it is annotated with at least one @InterceptorBinding");
}
if (annotationManager.hasInterceptorBindingMetaAnnotation(
AnnotationUtil.getAnnotationsFromSet(methodA.getAnnotations())))
{
throw new WebBeansConfigurationException("Method : " + method.getName() + "in managed bean class : " + clazz.getName()
+ " can not be defined as non-static, non-private and final . Because it is annotated with at least one @InterceptorBinding");
}