{
Asserts.nullCheckForClass(clazz);
Annotation[] anns = clazz.getDeclaredAnnotations();
boolean hasClassInterceptors = false;
AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
if (annotationManager.getInterceptorBindingMetaAnnotations(anns).length > 0)
{
hasClassInterceptors = true;
}
else
{
Annotation[] stereoTypes = annotationManager.getStereotypeMetaAnnotations(clazz.getDeclaredAnnotations());
for (Annotation stero : stereoTypes)
{
if (annotationManager.hasInterceptorBindingMetaAnnotation(stero.annotationType().getDeclaredAnnotations()))
{
hasClassInterceptors = true;
break;
}
}
}
//Simple webbeans
if(ClassUtil.isFinal(clazz.getModifiers()) && hasClassInterceptors)
{
throw new WebBeansConfigurationException("Final Simple class with name : " + clazz.getName() + " can not define any InterceptorBindings");
}
Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
for (Method method : methods)
{
int modifiers = method.getModifiers();
if (!method.isSynthetic() && !method.isBridge() && !Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && ClassUtil.isFinal(modifiers))
{
if (hasClassInterceptors)
{
throw new WebBeansConfigurationException("Simple web bean class : " + clazz.getName()
+ " can not define non-static, non-private final methods. "
+ "Because it is annotated with at least one @InterceptorBinding");
}
else
{
if (annotationManager.hasInterceptorBindingMetaAnnotation(
method.getDeclaredAnnotations()))
{
throw new WebBeansConfigurationException("Method : " + method.getName() + "in simple web bean class : "
+ clazz.getName()
+ " can not be defined as non-static, non-private and final. "