*/
public void init(FilterConfig pConfig) throws ServletException {
mServletContext = pConfig.getServletContext();
if (mEngine != null) return;
try {
RewriterConfiguration oConfig = new RewriterConfiguration(getBeanFactory());
String oPropsFile = pConfig.getInitParameter(PROPERTIES_FILE);
if (oPropsFile != null) {
String oFilePath = findPath(pConfig.getServletContext(), oPropsFile);
Properties oProps = new Properties();
FileInputStream oIS = null;
try {
oIS = new FileInputStream(oFilePath);
oProps.load(oIS);
oConfig.setProperties(oProps);
} catch (IOException oIOE) {
mLogger.error("Error loading properties file \"" + oFilePath + "\".", oIOE);
throw oIOE;
} finally {
if (oIS != null) oIS.close();
}
}
String oConfigFile = pConfig.getInitParameter(CONFIG_FILE);
if (oConfigFile == null) throw new ServletException("Must specify configuration file for filter " + pConfig.getFilterName() + " using key \"" + CONFIG_FILE + "\".");
String oFilePath = pConfig.getServletContext().getRealPath(oConfigFile);
if (oFilePath == null) throw new ServletException("Could not find configuration file within Servlet Context. Path: " + oConfigFile + ", Real Path: " + oFilePath);
if (mLogger.isDebugEnabled()) mLogger.debug("Initializing Rewriter Engine with configuration at " + oFilePath + "...");
oConfig.setConfigurationFromFile(oFilePath);
if (mLogger.isDebugEnabled()) mLogger.debug("Done reading Rewriter configuration.");
mEngine = new RewriterEngine(oConfig);
} catch (Exception e) {
mLogger.fatal("Error starting URLRewriter.", e);
throw new ServletException(e.getMessage(), e);