001/*******************************************************************************
002 * Copyright (c) 2006-2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 ******************************************************************************/
009package org.nuxeo.ecm.platform.ui.web.application.config;
010
011import java.lang.annotation.Annotation;
012import java.net.URI;
013import java.util.Map;
014import java.util.Set;
015
016import javax.servlet.ServletContext;
017
018import org.apache.commons.logging.LogFactory;
019
020import com.sun.faces.spi.AnnotationProvider;
021
022public class JSFAnnotationProvider extends AnnotationProvider {
023
024    protected final AnnotationProvider base;
025
026    public JSFAnnotationProvider(ServletContext sc, AnnotationProvider aProvider) {
027        super(sc);
028        base = aProvider;
029    }
030
031    @Override
032    public Map<Class<? extends Annotation>, Set<Class<?>>> getAnnotatedClasses(Set<URI> urls) {
033        if (JSFContainerInitializer.self == null) {
034            LogFactory.getLog(JSFAnnotationProvider.class).warn(
035                    "container scanned classes unavailable, applying default scanning");
036            return base.getAnnotatedClasses(urls);
037        }
038        return JSFContainerInitializer.self.index;
039    }
040
041}