Class AnnotationProvider

  • All Implemented Interfaces:
    FacesWrapper<AnnotationProvider>
    Direct Known Subclasses:
    AnnotationProviderWrapper, DefaultAnnotationProvider

    public abstract class AnnotationProvider
    extends Object
    implements FacesWrapper<AnnotationProvider>
    This interface provide a way to override myfaces annotation scanning algorithm that needs to be found at startup:

    This is provided to allow application containers solve the following points

    • It is common application containers to have its own protocols to handle files. It is not the same to scan annotation inside a jar than look on a directory.
    • If the application container has some optimization related to annotation scanning or it already did that task, it is better to reuse that information instead do the same thing twice.

    To override this class, create a file on a jar file with the following entry name: /META-INF/services/org.apache.myfaces.spi.AnnotationProvider and put the desired class name of the class that will override or extend the default AnnotationProvider.

    To wrap the default AnnotationProvider, use a constructor like CustomAnnotationProvider(AnnotationProvider ap)

    Since:
    2.0.2
    Author:
    Leonardo Uribe
    • Constructor Detail

      • AnnotationProvider

        public AnnotationProvider()
    • Method Detail

      • getAnnotatedClasses

        public abstract Map<Class<? extends Annotation>,​Set<Class<?>>> getAnnotatedClasses​(ExternalContext ctx)
        Retrieve a map containing the classes that contains annotations used by jsf implementation at startup.

        The default implementation must comply with Faces 2.0 spec section 11.5.1 Requirements for scanning of classes for annotations.

        This method could call getBaseUrls() to obtain a list of URL that could be used to indicate jar files of annotations in the classpath.

        If the <faces-config> element in the WEB-INF/faces-config.xml file contains metadata-complete attribute whose value is "true", this method should not be called.

        Parameters:
        ctx - The current ExternalContext
        Returns:
        A map with all classes that could contain annotations.
      • getBaseUrls

        public abstract Set<URL> getBaseUrls​(ExternalContext ctx)
                                      throws IOException

        The returned Set<URL> urls are calculated in this way ( see Faces 2.0 spec section 11.4.2 for definitions )

        1. All resources that match either "META-INF/faces-config.xml" or end with ".facesconfig.xml" directly in the "META-INF" directory (considered applicationConfigurationResources)
        Parameters:
        ctx -
        Returns:
        Throws:
        IOException
        Since:
        2.1.9, 2.0.15