org.apache.myfaces.spi.AnnotationProvider Maven / Gradle / Ivy
Show all versions of myfaces-impl Show documentation
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.myfaces.spi;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.Map;
import java.util.Set;
import javax.faces.FacesWrapper;
import javax.faces.context.ExternalContext;
/**
* This interface provide a way to override myfaces annotation scanning algorithm that
* needs to be found at startup:
*
*
* - {@link javax.faces.bean.ManagedBean}
* - {@link javax.faces.component.FacesComponent}
* - {@link javax.faces.component.behavior.FacesBehavior}
* - {@link javax.faces.convert.FacesConverter}
* - {@link javax.faces.event.NamedEvent}
* - {@link javax.faces.render.FacesRenderer}
* - {@link javax.faces.render.FacesBehaviorRenderer}
* - {@link javax.faces.validator.FacesValidator}
*
*
* 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
*/
public abstract class AnnotationProvider implements FacesWrapper
{
/**
* Retrieve a map containing the classes that contains annotations used by jsf implementation at
* startup.
* The default implementation must comply with JSF 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 element in the WEB-INF/faces-config.xml file contains metadata-complete attribute
* whose value is "true", this method should not be called.
*
*
* @param ctx The current ExternalContext
* @return A map with all classes that could contain annotations.
*/
public abstract Map,Set>> getAnnotatedClasses(ExternalContext ctx);
/**
* The returned Set<URL> urls are calculated in this way ( see JSF 2.0 spec section 11.4.2 for definitions )
*
*
* - All resources that match either "META-INF/faces-config.xml" or end with ".facesconfig.xml" directly in
* the "META-INF" directory (considered
applicationConfigurationResources)
*
*
* @return
*/
public abstract Set getBaseUrls() throws IOException;
public AnnotationProvider getWrapped()
{
return null;
}
}