* @param isDefinedWithWebBeans if interceptor is defined with WebBeans
* spec, not EJB spec
*/
public static void configureInterceptorMethods(Interceptor webBeansInterceptor, Class<?> clazz, Class<? extends Annotation> annotation, boolean definedInInterceptorClass, boolean definedInMethod, List<InterceptorData> stack, Method annotatedInterceptorClassMethod, boolean isDefinedWithWebBeans)
{
InterceptorData intData = null;
Method method = null;
if (annotation.equals(AroundInvoke.class))
{
method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(clazz);
}
else if (annotation.equals(PostConstruct.class))
{
if (definedInInterceptorClass)
{
method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PostConstruct.class, true);
}
else
{
method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PostConstruct.class, false);
}
}
else if (annotation.equals(PreDestroy.class))
{
if (definedInInterceptorClass)
{
method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PreDestroy.class, true);
}
else
{
method = WebBeansUtil.checkCommonAnnotationCriterias(clazz, PreDestroy.class, false);
}
}
if (method != null)
{
intData = new InterceptorDataImpl(isDefinedWithWebBeans);
intData.setDefinedInInterceptorClass(definedInInterceptorClass);
intData.setDefinedInMethod(definedInMethod);
intData.setAnnotatedMethod(annotatedInterceptorClassMethod);
intData.setWebBeansInterceptor(webBeansInterceptor);
if (definedInInterceptorClass)
{
try
{
if (isDefinedWithWebBeans)
{
Object interceptorProxy = ManagerImpl.getManager().getInstance(webBeansInterceptor);
WebBeansInterceptor interceptor = (WebBeansInterceptor) webBeansInterceptor;
interceptor.setInjections(interceptorProxy);
intData.setInterceptorInstance(interceptorProxy);
}
else
{
if (ClassUtil.isContaintNoArgConstructor(clazz) == null)
{
throw new WebBeansConfigurationException("Interceptor class : " + clazz.getName() + " must have no-arg constructor");
}
intData.setInterceptorInstance(clazz.newInstance());
}
}
catch (WebBeansConfigurationException e1)
{
throw e1;
}
catch (Exception e)
{
throw new WebBeansException(e);
}
}
intData.setInterceptor(method, annotation);
stack.add(intData);
}
}