in webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java [1827:1907]
private void configureInterceptors(URL bdaLocation, List<String> interceptors)
{
// the interceptors in this beans.xml
// this gets used to detect multiple definitions of the
// same interceptor in one beans.xml file.
Set<Class> interceptorsInFile = new HashSet<>();
for (String interceptor : interceptors)
{
Class<?> clazz = ClassUtil.getClassFromName(interceptor);
if (clazz == null)
{
throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Interceptor class : " +
interceptor + " not found");
}
else
{
Annotation[] classAnnotations;
AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(clazz);
if (annotatedType == null)
{
annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
}
GProcessAnnotatedType processAnnotatedEvent =
webBeansContext.getWebBeansUtil().fireProcessAnnotatedTypeEvent(annotatedType);
// if veto() is called
if (processAnnotatedEvent.isVeto())
{
return;
}
annotatedType = processAnnotatedEvent.getAnnotatedType();
processAnnotatedEvent.setStarted();
Set<Annotation> annTypeAnnotations = annotatedType.getAnnotations();
if (annTypeAnnotations != null)
{
classAnnotations = annTypeAnnotations.toArray(new Annotation[annTypeAnnotations.size()]);
}
else
{
classAnnotations = new Annotation[0];
}
if (AnnotationUtil.hasAnnotation(classAnnotations, jakarta.interceptor.Interceptor.class) &&
!webBeansContext.getAnnotationManager().hasInterceptorBindingMetaAnnotation(classAnnotations))
{
throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Interceptor class : "
+ interceptor + " must have at least one @InterceptorBinding");
}
// check if the interceptor got defined twice in this beans.xml
if (interceptorsInFile.contains(clazz))
{
throw new WebBeansDeploymentException(createConfigurationFailedMessage(bdaLocation) + "Interceptor class : "
+ interceptor + " already defined in this beans.xml file!");
}
interceptorsInFile.add(clazz);
boolean isBDAScanningEnabled = scannerService.isBDABeansXmlScanningEnabled();
if ((!isBDAScanningEnabled && interceptorsManager.isInterceptorClassEnabled(clazz)) ||
(isBDAScanningEnabled && !scannerService.getBDABeansXmlScanner().addInterceptor(clazz, bdaLocation.toExternalForm())))
{
int priority = -1;
if (!isBDAScanningEnabled)
{
priority = interceptorsManager.getPriority(clazz);
}
logger.fine( "Interceptor class : " + interceptor + " is already defined" +
(priority >= 0 ? " with priority " + priority : ""));
}
else
{
interceptorsManager.addEnabledInterceptorClass(clazz);
}
}
}
}