public void init(FilterConfig pConfig) throws ServletException {
mServletContext = pConfig.getServletContext();
if (mEngine != null) return;
InputStream oConfigStream = null;
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();
}
}
oConfigStream = getConfigFile(pConfig);
if (mLogger.isDebugEnabled()) mLogger.debug("Initializing Rewriter Engine with configuration...");
oConfig.setConfigurationFromFile(oConfigStream);
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);