001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 */
016package org.nuxeo.ecm.platform.ui.web.application.config;
017
018import java.lang.annotation.Annotation;
019import java.net.URI;
020import java.util.Map;
021import java.util.Set;
022
023import javax.servlet.ServletContext;
024
025import org.apache.commons.logging.LogFactory;
026
027import com.sun.faces.spi.AnnotationProvider;
028
029/**
030 * TODO.
031 *
032 * @since 6.0
033 */
034public class JSFAnnotationProvider extends AnnotationProvider {
035
036    protected final AnnotationProvider base;
037
038    public JSFAnnotationProvider(ServletContext sc, AnnotationProvider aProvider) {
039        super(sc);
040        base = aProvider;
041    }
042
043    @Override
044    public Map<Class<? extends Annotation>, Set<Class<?>>> getAnnotatedClasses(Set<URI> urls) {
045        if (JSFContainerInitializer.self == null) {
046            LogFactory.getLog(JSFAnnotationProvider.class).warn(
047                    "container scanned classes unavailable, applying default scanning");
048            return base.getAnnotatedClasses(urls);
049        }
050        return JSFContainerInitializer.self.index;
051    }
052
053}