ResourceLookup.java revision fc407e8870fb0f64f1be3c0aa456b2ab135bcec9
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * The contents of this file are subject to the terms
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * of the Common Development and Distribution License
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * (the License). You may not use this file except in
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * compliance with the License.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * You can obtain a copy of the License at
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * https://opensso.dev.java.net/public/CDDLv1.0.html or
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * See the License for the specific language governing
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * permission and limitations under the License.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * When distributing Covered Code, include this CDDL
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Header Notice in each file and include the License file
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * If applicable, add the following below the CDDL Header,
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * with the fields enclosed by brackets [] replaced by
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * your own identifying information:
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * "Portions Copyrighted [year] [name of copyright owner]"
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * $Id: ResourceLookup.java,v 1.7 2009/05/02 22:12:04 kevinserwin Exp $
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Portions Copyrighted 2014 ForgeRock AS
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenkimport com.sun.identity.shared.search.FileLookup;
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenkimport com.sun.identity.shared.search.FileLookupException;
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * ResourceLookup is a partial replacement for implementation of FileLookup. It
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * performs the equivalent of "fstat" using ServletContext.getResource(), thus
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * increasing web container independence.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk private static final ConcurrentMap<String, String> RESOURCE_NAME_CACHE;
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk private static final boolean CACHE_ENABLED;
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk private static final Debug DEBUG = Debug.getInstance("amResourceLookup");
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk CACHE_ENABLED = SystemProperties.getAsBoolean(Constants.RESOURCE_LOOKUP_CACHE_ENABLED, true);
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk RESOURCE_NAME_CACHE = new ConcurrentHashMap<String, String>();
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * Returns the first existing resource in the ordered search paths.
4b8d88eb610aa1e0bb6ec632f792744b3d6b5f22jeff.schenk * @param context Servlet Context Reference.
.toString();
if (CACHE_ENABLED) {
return resourceName;
if (CACHE_ENABLED) {
return resourceName;
//Only try to lookup XMLs from the classpath as UI files from JAR files cannot be used by RequestDispatcher
resourceURL = Thread.currentThread().getContextClassLoader().getResource(resourceName.substring(1));
return resourceURL;