Class AnnotationProvider

java.lang.Object
com.sun.faces.spi.AnnotationProvider
Direct Known Subclasses:
AnnotationScanner, FilterClassesFromFacesInitializerAnnotationProvider

public abstract class AnnotationProvider extends Object

An integration point for integrators to provide custom annotation scanning.

All AnnotationProvider implementations must scan for the following annotations:

  • FacesComponent
  • FacesConverter
  • FacesRenderer
  • FacesValidator
  • ManagedBean
  • NamedEvent
  • FacesBehavior
  • FacesBehaviorRenderer

The AnnotationProvider instance will be wrapped as a Future and executed during the environment initialization. The result of the future can be obtained by calling ConfigManager.getAnnotatedClasses(jakarta.faces.context.FacesContext).

The Future itself can be obtained from the application map using the key com.sun.faces.config.ConfigManager__ANNOTATION_SCAN_TASK.

It's important to note that the value returned by either method described above is only available while the application is being initialized and will be removed before the application is put into service.

To register a custom AnnotationProvider with the runtime, place a file named com.sun.faces.spi.annotationprovider within META-INF/services of a JAR file, with a single line referencing the fully qualified class name of the AnnotationProvider implementation. Custom AnnotationProviders can be used to decorate the default AnnotationProvider by providing a constructor that takes an AnnotationProvider as the second parameter:

public AnnotationProvider(ServletContext sc, AnnotationProvider parent)

If decoration is not desired, then the custom provider must have a constructor that takes one paramer, a ServletContext:

public AnnotationProvider(ServletContext sc)

All customer providers must extend this class.