pier 2003/01/29 11:40:42 Modified: src/java/org/apache/cocoon/servlet CocoonServlet.java Log: Give the possibility to the CocoonServlet to read logkit.xconf and cocoon.xml from somewhere _outside_ of its context: - First try to get the configuration file using the usual "getResource()" method of the context. - Then try to get the configuration file as if the parameter specified a file on the disk. This is helpful in cases where Cocoon wants to run as a standalone servlet (without the entire bogus web-application concept). Revision Changes Path 1.45 +15 -2 xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java Index: CocoonServlet.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- CocoonServlet.java 25 Nov 2002 14:06:38 -0000 1.44 +++ CocoonServlet.java 29 Jan 2003 19:40:42 -0000 1.45 @@ -92,6 +92,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; @@ -833,7 +834,8 @@ logkitConfig = "/WEB-INF/logkit.xconf"; } - final InputStream is = this.servletContext.getResourceAsStream(logkitConfig); + InputStream is = this.servletContext.getResourceAsStream(logkitConfig); + if (is == null) is = new FileInputStream(logkitConfig); final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); final Configuration conf = builder.build(is); logKitManager.configure(conf); @@ -880,6 +882,17 @@ String msg = "Init parameter 'configurations' is invalid : " + usedFileName; log.error(msg, mue); throw new ServletException(msg, mue); + } + + if (result == null) { + File resultFile = new File(usedFileName); + if (resultFile.isFile()) try { + result = resultFile.getCanonicalFile().toURL(); + } catch (Exception iomue) { + String msg = "Init parameter 'configurations' is invalid : " + usedFileName; + log.error(msg, iomue); + throw new ServletException(msg, iomue); + } } if (result == null) {
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]