continue;
}
if (found)
{
throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
+ " annotation is declared more than one method in the class : " + clazz.getName());
}
found = true;
result = method;
// Check method criterias
if (methodB.getParameters().isEmpty())
{
if (!invocationContext)
{
throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in class : " + clazz.getName()
+ " can not take any formal arguments");
}
List<AnnotatedParameter<T>> parameters = methodB.getParameters();
List<Class<?>> clazzParameters = new ArrayList<Class<?>>();
for(AnnotatedParameter<T> parameter : parameters)
{
clazzParameters.add(ClassUtil.getClazz(parameter.getBaseType()));
}
Class<?>[] params = clazzParameters.toArray(new Class<?>[clazzParameters.size()]);
if (params.length != 1 || !params[0].equals(InvocationContext.class))
{
throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in class : " + clazz.getName()
+ " can not take any formal arguments other than InvocationContext");
}
}
else if(invocationContext)
{
throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in class : " + clazz.getName()
+ " must take a parameter with class type javax.interceptor.InvocationContext.");
}
if (!ClassUtil.getReturnType(method).equals(Void.TYPE))
{
throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in class : " + clazz.getName()
+ " must return void type");
}
if (isNoCheckedExceptionEnforced() && ClassUtil.isMethodHasCheckedException(method))
{
throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in class : " + clazz.getName()
+ " can not throw any checked exception");
}
if (Modifier.isStatic(method.getModifiers()))
{
throw new WebBeansConfigurationException("@" + commonAnnotation.getSimpleName()
+ " annotated method : " + method.getName() + " in class : " + clazz.getName()
+ " can not be static");
}
}