All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.metawidget.config.impl.ServletResourceResolver Maven / Gradle / Ivy

There is a newer version: 4.2
Show newest version
// Metawidget
//
// This file is dual licensed under both the LGPL
// (http://www.gnu.org/licenses/lgpl-2.1.html) and the EPL
// (http://www.eclipse.org/org/documents/epl-v10.php). As a
// recipient of Metawidget, you may choose to receive it under either
// the LGPL or the EPL.
//
// Commercial licenses are also available. See http://metawidget.org
// for details.

package org.metawidget.config.impl;

import java.io.InputStream;
import java.net.URL;

import javax.servlet.ServletContext;

import org.metawidget.inspector.iface.InspectorException;

/**
 * Specialized ResourceResolver for Servlets.
 * 

* Resolves references by looking in /WEB-INF/ first. Defined here, rather than in * org.metawidget.jsp, because needs to be shared by various Web-based frameworks * including GWT. * * @author Richard Kennard */ public class ServletResourceResolver extends SimpleResourceResolver { // // Private members // private ServletContext mContext; // // Constructor // public ServletResourceResolver( ServletContext context ) { mContext = context; } // // Protected methods // /** * Overridden to try /WEB-INF/ first. */ @Override public InputStream openResource( String resource ) { try { URL url = mContext.getResource( "/WEB-INF/" + resource ); if ( url != null ) { return url.openStream(); } } catch ( Exception e ) { throw InspectorException.newException( e ); } return super.openResource( resource ); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy