You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2005/09/25 11:36:28 UTC

svn commit: r291398 - in /cocoon/trunk: src/java/org/apache/cocoon/core/osgi/ src/osgi-servlet/org/apache/cocoon/service/servlet/impl/ src/webapp/WEB-INF/ tools/targets/

Author: danielf
Date: Sun Sep 25 02:36:19 2005
New Revision: 291398

URL: http://svn.apache.org/viewcvs?rev=291398&view=rev
Log:
Continued work on a servlet for OSGi usage, CoreUtil is now created outside the servlet. Commented away some unused targets in the logkit.xconf that didin't work in the OSGi context. Improved the OSGi build so that one can build the webap more than once without getting faulty configuration files.

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java
    cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java
    cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/BlocksServlet.java
    cocoon/trunk/src/webapp/WEB-INF/logkit.xconf
    cocoon/trunk/tools/targets/osgi-build.xml

Modified: cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java?rev=291398&r1=291397&r2=291398&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/core/osgi/OSGiBootstrapEnvironment.java Sun Sep 25 02:36:19 2005
@@ -63,7 +63,7 @@
         if (pathURL == null)
             throw new FileNotFoundException("Unable to get resource '/WEB-INF/block.xml' from bundle ." + bundle);
         String path = pathURL.toString();
-        path = path.substring(0, path.length() - this.configuration.length() - 1);
+        path = path.substring(0, path.length() - (this.configuration.length() - 1));
         this.contextPath = path;
 
         this.environmentContext = new OSGiContext(bundle);
@@ -118,9 +118,11 @@
     }
     
     public void configure(MutableSettings settings) {
-        settings.setConfiguration(this.configuration);
+        // FIXME: Should be found from block.xml
+        settings.setConfiguration("/WEB-INF/cocoon.xconf");
         settings.setWorkDirectory("work");
         settings.setInitClassloader(true);
+        settings.setLoggingConfiguration("/WEB-INF/logkit.xconf");
     }
 
     public void configureLoggingContext(DefaultContext context) {
@@ -162,6 +164,8 @@
      * @throws Exception
      */
     public URL getConfigFile(String configFileName) throws Exception {
+        this.logger.debug("getConfigFile: contextPath=" + this.contextPath +
+                          " configFileName=" + configFileName);
         return new URL(this.contextPath + configFileName);
     }
 
@@ -226,13 +230,7 @@
         }
 
         public String getRealPath(String path) {
-            try {
-                URL pathURL = getResource(path);
-                return pathURL == null ? null : pathURL.toString();
-            } catch (MalformedURLException me) {
-                // Will not happen, Bundle getResource does not throw MalformedURLException
-                return null;
-            }
+            return null;
         }
 
         public String getMimeType(String file) {

Modified: cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java?rev=291398&r1=291397&r2=291398&view=diff
==============================================================================
--- cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java (original)
+++ cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/Activator.java Sun Sep 25 02:36:19 2005
@@ -16,25 +16,17 @@
 package org.apache.cocoon.service.servlet.impl;
 
 import java.util.Hashtable;
-import java.net.URL;
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.cocoon.core.BootstrapEnvironment;
 import org.apache.cocoon.core.CoreUtil;
 import org.apache.cocoon.core.osgi.OSGiBootstrapEnvironment;
-import org.apache.cocoon.environment.Context;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.HttpService;
 
 /**
@@ -48,10 +40,7 @@
     static final String  SITEMAP = "sitemap";
 
     private Hashtable registrations = new Hashtable();
-    private Bundle sitemapBundle;
     private ClassLoader classLoader = getClass().getClassLoader();;
-    private String contextURL;
-    private Context environmentContext;
     private Logger logger;
     private CoreUtil coreUtil;
 
@@ -63,19 +52,12 @@
             env.log("OSGiBootstrapEnvironment created");
             this.coreUtil = new CoreUtil(env);
             env.log("CoreUtil created");
-            this.contextURL = env.getContextURL();
-            this.environmentContext = env.getEnvironmentContext();
             this.logger = env.getBootstrapLogger(null);
         } catch (Exception e) {
             e.printStackTrace();
             throw new BundleException("Failed to create core util", e);
         }
 
-        // FIXME: Add a BundleListener to detect if a sitemap bundle
-        // is installed, updated or uninstalled.
-        this.sitemapBundle = getSitemapBundle();
-        this.logger.info("set sitemap bundle " + this.sitemapBundle);
-
         ServiceListener listener = new ServiceListener() {
                 public void serviceChanged(ServiceEvent ev) {
                     ServiceReference sr = ev.getServiceReference();
@@ -109,29 +91,6 @@
     public void stop(BundleContext bc) throws BundleException {
     }
 
-    private Bundle getSitemapBundle() {
-        Bundle[] bundles = this.bc.getBundles();
-        for (int i = 0; i < bundles.length; i++) {
-            Bundle bundle = bundles[i];
-            try {
-                this.logger.info("checking bundle " + bundle + " name=" + bundle.getHeaders().get(Constants.BUNDLE_NAME) + " category=" + bundle.getHeaders().get(Constants.BUNDLE_CATEGORY) + " state=" + bundle.getState());
-                if ((bundle.getState() == Bundle.INSTALLED ||
-                     bundle.getState() == Bundle.RESOLVED ||
-                     bundle.getState() == Bundle.ACTIVE)) {
-                    this.logger.info("ok state");
-                    if (SITEMAP.equals(bundle.getHeaders().get(Constants.BUNDLE_CATEGORY))) {
-                        this.logger.info("sitemap");
-                        return bundle;
-                    }
-                }
-            } catch (NullPointerException e) {
-                // BUNDLE_CATEGORY not present in the headers of the
-                // bundle, nothing to do.
-            }
-        }
-        return null;
-    }
-
     private void setRoot(ServiceReference sr) {
         
         if(registrations.containsKey(sr)) {
@@ -142,41 +101,15 @@
 
         HttpService http = (HttpService)bc.getService(sr);
 
-        HttpContext context = new HttpContext() {
-                public boolean handleSecurity(HttpServletRequest  request,
-                                              HttpServletResponse response) 
-                    throws IOException {
-                    return true;
-                }
-        
-                public URL getResource(String name) {
-                    if (sitemapBundle != null) {
-                        return sitemapBundle.getResource(name);
-                    } else {
-                        return null;
-                    }
-                }
-        
-                public String getMimeType(String reqEntry) {
-                    return null; // server decides type
-                }
-            };
-    
         try {
-            Hashtable parameters = new Hashtable();
-            parameters.put("init-classloader", "true");
-            parameters.put("work-directory", "work");
             http.registerServlet(SERVLET_ALIAS,
-                                 new BlocksServlet(),
-//                                   new CocoonServlet(this.classLoader,
-//                                                     this.contextURL,
-//                                                     this.environmentContext,
-//                                                     this.logger,
-//                                                     this.coreUtil),
-                                 parameters,
-                                 context);
+                                 new BlocksServlet(this.classLoader,
+                                                   this.logger,
+                                                   this.coreUtil),
+                                 new Hashtable(),
+                                 null);
 
-            registrations.put(sr, context);
+            registrations.put(sr, null);
         } catch (Exception e) {
             this.logger.info("Failed to register resource", e);
         }

Modified: cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/BlocksServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/BlocksServlet.java?rev=291398&r1=291397&r2=291398&view=diff
==============================================================================
--- cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/BlocksServlet.java (original)
+++ cocoon/trunk/src/osgi-servlet/org/apache/cocoon/service/servlet/impl/BlocksServlet.java Sun Sep 25 02:36:19 2005
@@ -16,32 +16,18 @@
 package org.apache.cocoon.service.servlet.impl;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.MalformedURLException;
 import java.net.SocketException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
 
 import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.avalon.excalibur.logger.ServletLogger;
-import org.apache.avalon.framework.context.DefaultContext;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.cocoon.Cocoon;
 import org.apache.cocoon.ConnectionResetException;
@@ -50,19 +36,12 @@
 import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
 import org.apache.cocoon.components.notification.Notifier;
 import org.apache.cocoon.components.notification.Notifying;
-import org.apache.cocoon.core.BootstrapEnvironment;
+import org.apache.cocoon.core.Core;
 import org.apache.cocoon.core.CoreUtil;
-import org.apache.cocoon.core.MutableSettings;
-import org.apache.cocoon.core.Settings;
-import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.http.HttpContext;
 import org.apache.cocoon.environment.http.HttpEnvironment;
-import org.apache.cocoon.servlet.SettingsHelper;
 import org.apache.cocoon.servlet.multipart.MultipartHttpServletRequest;
 import org.apache.cocoon.servlet.multipart.RequestFactory;
-import org.apache.cocoon.util.IOUtils;
-import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.time.StopWatch;
 
 /**
@@ -99,22 +78,8 @@
 
     private String containerEncoding;
 
-    protected ServletContext servletContext;
-
     /** The classloader that will be set as the context classloader if init-classloader is true */
-    protected ClassLoader classLoader = getClass().getClassLoader();
-
-    /**
-     * This is the path to the servlet context (or the result
-     * of calling getRealPath('/') on the ServletContext.
-     * Note, that this can be null.
-     */
-    protected String servletContextPath;
-
-    /**
-     * This is the url to the servlet context directory
-     */
-    protected String servletContextURL;
+    protected ClassLoader classLoader;
 
     /**
      * The RequestFactory is responsible for wrapping multipart-encoded
@@ -122,13 +87,23 @@
      */
     protected RequestFactory requestFactory;
 
+    /** Core */
+    protected Core core;
+
     /** CoreUtil */
     protected CoreUtil coreUtil;
 
     /** The logger */
     protected Logger log;
 
-    protected Context environmentContext;
+    public BlocksServlet(ClassLoader classLoader,
+                         Logger logger,
+                         CoreUtil coreUtil) {
+        this.classLoader = classLoader;
+        this.log = logger;
+        this.coreUtil = coreUtil;
+        this.core = coreUtil.getCore();
+    }
 
     /**
      * Initialize this <code>BlocksServlet</code> instance.  You will
@@ -144,87 +119,16 @@
      */
     public void init(ServletConfig conf)
     throws ServletException {
-        this.servletContext = conf.getServletContext();
-        this.servletContext.log("Initializing Apache Cocoon " + Constants.VERSION);
-
         super.init(conf);
 
-        this.servletContextPath = this.servletContext.getRealPath("/");
-        String path = this.servletContextPath;
-        // these two variables are just for debugging. We can't log at this point
-        // as the logger isn't initialized yet.
-        String debugPathOne = null, debugPathTwo = null;
-        if (path == null) {
-            // Try to figure out the path of the root from that of WEB-INF/web.xml
-            try {
-                path = this.servletContext.getResource("/WEB-INF/web.xml").toString();
-            } catch (MalformedURLException me) {
-                throw new ServletException("Unable to get resource 'WEB-INF/web.xml'.", me);
-            }
-            debugPathOne = path;
-            path = path.substring(0, path.length() - "WEB-INF/web.xml".length());
-            debugPathTwo = path;
-        }
-        try {
-            if (path.indexOf(':') > 1) {
-                this.servletContextURL = path;
-            } else {
-                this.servletContextURL = new File(path).toURL().toExternalForm();
-            }
-        } catch (MalformedURLException me) {
-            // VG: Novell has absolute file names starting with the
-            // volume name which is easily more then one letter.
-            // Examples: sys:/apache/cocoon or sys:\apache\cocoon
-            try {
-                this.servletContextURL = new File(path).toURL().toExternalForm();
-            } catch (MalformedURLException ignored) {
-                throw new ServletException("Unable to determine servlet context URL.", me);
-            }
-        }
-
-        try {
-            // FIXME (VG): We shouldn't have to specify these. Need to override
-            // jaxp implementation of weblogic before initializing logger.
-            // This piece of code is also required in the Cocoon class.
-            String value = System.getProperty("javax.xml.parsers.SAXParserFactory");
-            if (value != null && value.startsWith("weblogic")) {
-                System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
-                System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-            }
-        } catch (Exception e) {
-            // Ignore security exception
-            this.servletContext.log("BlocksServlet: Could not check system properties, got: " + e);
-        }
-
-        // initialize settings
-        ServletBootstrapEnvironment env = new ServletBootstrapEnvironment(conf, this.classLoader, this.servletContextPath, this.servletContextURL);
-
-        try {
-            this.coreUtil = new CoreUtil(env);
-            this.environmentContext = env.getEnvironmentContext();
-            this.log = env.logger;
-        } catch (Exception e) {
-            if ( e instanceof ServletException ) {
-                throw (ServletException)e;
-            }
-            throw new ServletException(e);
-        }
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug(this.coreUtil.getSettings().toString());
-            getLogger().debug("getRealPath for /: " + this.servletContextPath);
-            if (this.servletContextPath == null) {
-                getLogger().debug("getResource for /WEB-INF: " + debugPathOne);
-                getLogger().debug("Path for Root: " + debugPathTwo);
-            }
-        }
+        this.getLogger().info("Initializing Apache Cocoon " + Constants.VERSION);
 
         this.containerEncoding = this.getInitParameter("container-encoding", "ISO-8859-1");
-        this.requestFactory = new RequestFactory(coreUtil.getSettings().isAutosaveUploads(),
-                                                 new File(coreUtil.getCore().getSettings().getUploadDirectory()),
-                                                 coreUtil.getSettings().isAllowOverwrite(),
-                                                 coreUtil.getSettings().isSilentlyRename(),
-                                                 coreUtil.getSettings().getMaxUploadSize(),
+        this.requestFactory = new RequestFactory(this.core.getSettings().isAutosaveUploads(),
+                                                 new File(this.core.getSettings().getUploadDirectory()),
+                                                 this.core.getSettings().isAllowOverwrite(),
+                                                 this.core.getSettings().isSilentlyRename(),
+                                                 this.core.getSettings().getMaxUploadSize(),
                                                  this.containerEncoding);
 
         try {
@@ -234,10 +138,10 @@
             this.exception = e;
         }
         if (this.exception == null) {
-            this.servletContext.log("Apache Cocoon " + Constants.VERSION + " is up and ready.");
+            this.getLogger().info("Apache Cocoon " + Constants.VERSION + " is up and ready.");
         } else {
             final String message = "Errors during initializing Apache Cocoon " + Constants.VERSION + " : " + this.exception.getMessage();
-            this.servletContext.log(message, this.exception);
+            this.getLogger().error(message, this.exception);
         }
     }
 
@@ -245,17 +149,14 @@
      * Dispose Cocoon when servlet is destroyed
      */
     public void destroy() {
-        this.servletContext.log("Destroying Cocoon Servlet.");
+        this.getLogger().info("Destroying Cocoon Servlet.");
         if (this.coreUtil != null) {
-            this.coreUtil.destroy();
             this.coreUtil = null;
             // coreUtil will dispose it.
             this.cocoon = null;
         }
 
         this.requestFactory = null;
-        this.servletContext = null;
-        this.environmentContext = null;
         this.classLoader = null;
         this.log = null;
         super.destroy();
@@ -268,9 +169,8 @@
     public void service(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
 
-        /* HACK for reducing class loader problems.                                     */
-        /* example: xalan extensions fail if someone adds xalan jars in tomcat3.2.1/lib */
-        if (this.coreUtil.getSettings().isInitClassloader()) {
+        /* Needed in OSGi environment */
+        if (this.core.getSettings().isInitClassloader()) {
             try {
                 Thread.currentThread().setContextClassLoader(this.classLoader);
             } catch (Exception e) {
@@ -283,14 +183,14 @@
         stopWatch.start();
 
         // add the cocoon header timestamp
-        if (this.coreUtil.getSettings().isShowCocoonVersion()) {
+        if (this.core.getSettings().isShowCocoonVersion()) {
             res.addHeader("X-Cocoon-Version", Constants.VERSION);
         }
 
         // get the request (wrapped if contains multipart-form data)
         HttpServletRequest request;
         try{
-            if (this.coreUtil.getSettings().isEnableUploads()) {
+            if (this.core.getSettings().isEnableUploads()) {
                 request = requestFactory.getServletRequest(req);
             } else {
                 request = req;
@@ -445,7 +345,7 @@
 
             if (contentType != null && contentType.equals("text/html")) {
                 String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
-                boolean show = this.coreUtil.getSettings().isShowTime();
+                boolean show = this.core.getSettings().isShowTime();
                 if (showTime != null) {
                     show = !showTime.equalsIgnoreCase("no");
                 }
@@ -453,7 +353,7 @@
                     if ( timeString == null ) {
                         timeString = processTime(stopWatch.getTime());
                     }
-                    boolean hide = this.coreUtil.getSettings().isHideShowTime();
+                    boolean hide = this.core.getSettings().isHideShowTime();
                     if (showTime != null) {
                         hide = showTime.equalsIgnoreCase("hide");
                     }
@@ -503,7 +403,7 @@
                                    String title, String message, String description,
                                    Exception e)
     throws IOException {
-        if (this.coreUtil.getSettings().isManageExceptions()) {
+        if (this.core.getSettings().isManageExceptions()) {
             if (env != null) {
                 env.tryResetResponse();
             } else {
@@ -561,14 +461,14 @@
 
         String formEncoding = req.getParameter("cocoon-form-encoding");
         if (formEncoding == null) {
-            formEncoding = this.coreUtil.getSettings().getFormEncoding();
+            formEncoding = this.core.getSettings().getFormEncoding();
         }
         env = new HttpEnvironment(uri,
-                                  this.servletContextURL,
+                                  null,
                                   req,
                                   res,
-                                  this.servletContext,
-                                  this.environmentContext,
+                                  null,
+                                  this.core.getEnvironmentContext(),
                                   this.containerEncoding,
                                   formEncoding);
         env.enableLogging(getLogger());
@@ -623,332 +523,5 @@
 
     protected Logger getLogger() {
         return this.log;
-    }
-
-    protected static final class ServletBootstrapEnvironment
-    implements BootstrapEnvironment {
-
-        private final ServletConfig config;
-        private final ClassLoader   classLoader;
-        private final File          writeableContextPath;
-        private final String        contextPath;
-        public Logger logger;
-        private final HttpContext   environmentContext;
-
-        public ServletBootstrapEnvironment(ServletConfig config,
-                                           ClassLoader   cl,
-                                           String        writeablePath,
-                                           String        path) {
-            this.config = config;
-            this.classLoader = cl;
-            if ( writeablePath == null ) {
-                this.writeableContextPath = null;
-            } else {
-                this.writeableContextPath = new File(writeablePath);
-            }
-            this.contextPath = path;
-            this.environmentContext = new HttpContext(this.config.getServletContext());
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getBootstrapLogger(org.apache.cocoon.core.BootstrapEnvironment.LogLevel)
-         */
-        public Logger getBootstrapLogger(BootstrapEnvironment.LogLevel logLevel) {
-            return new ServletLogger(this.config, logLevel.getLevel());
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#log(java.lang.String)
-         */
-        public void log(String message) {
-            this.config.getServletContext().log(message);
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#log(java.lang.String, java.lang.Throwable)
-         */
-        public void log(String message, Throwable error) {
-            this.config.getServletContext().log(message, error);
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#setLogger(org.apache.avalon.framework.logger.Logger)
-         */
-        public void setLogger(Logger rootLogger) {
-            this.logger = rootLogger;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.cocoon.core.MutableSettings)
-         */
-        public void configure(MutableSettings settings) {
-            // fill from the servlet parameters
-            SettingsHelper.fill(settings, this.config);
-            if ( settings.getWorkDirectory() == null ) {
-                final File workDir = (File)this.config.getServletContext().getAttribute("javax.servlet.context.tempdir");
-                settings.setWorkDirectory(workDir.getAbsolutePath());
-            }
-            if ( settings.getLoggingConfiguration() == null ) {
-                settings.setLoggingConfiguration("/WEB-INF/logkit.xconf");
-            }
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getInitClassLoader()
-         */
-        public ClassLoader getInitClassLoader() {
-            return this.classLoader;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getEnvironmentContext()
-         */
-        public Context getEnvironmentContext() {
-            return this.environmentContext;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextURL()
-         */
-        public String getContextURL() {
-            return this.contextPath;
-        }
-
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextForWriting()
-         */
-        public File getContextForWriting() {
-            return this.writeableContextPath;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#configureLoggingContext(org.apache.avalon.framework.context.DefaultContext)
-         */
-        public void configureLoggingContext(DefaultContext context) {
-            context.put("servlet-context", this.config.getServletContext());
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.avalon.framework.context.DefaultContext)
-         */
-        public void configure(DefaultContext context) {
-            context.put(CONTEXT_SERVLET_CONFIG, this.config);
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getConfigFile(java.lang.String)
-         */
-        public URL getConfigFile(final String configFileName)
-        throws Exception {
-            final String usedFileName;
-
-            if (configFileName == null) {
-                if (this.logger.isWarnEnabled()) {
-                    this.logger.warn("Servlet initialization argument 'configurations' not specified, attempting to use '/WEB-INF/cocoon.xconf'");
-                }
-                usedFileName = "/WEB-INF/cocoon.xconf";
-            } else {
-                usedFileName = configFileName;
-            }
-
-            if (this.logger.isDebugEnabled()) {
-                this.logger.debug("Using configuration file: " + usedFileName);
-            }
-
-            URL result;
-            try {
-                // test if this is a qualified url
-                if (usedFileName.indexOf(':') == -1) {
-                    result = this.config.getServletContext().getResource(usedFileName);
-                } else {
-                    result = new URL(usedFileName);
-                }
-            } catch (Exception mue) {
-                String msg = "Init parameter 'configurations' is invalid : " + usedFileName;
-                this.logger.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 e) {
-                        String msg = "Init parameter 'configurations' is invalid : " + usedFileName;
-                        this.logger.error(msg, e);
-                        throw new ServletException(msg, e);
-                    }
-                }
-            }
-
-            if (result == null) {
-                String msg = "Init parameter 'configuration' doesn't name an existing resource : " + usedFileName;
-                this.logger.error(msg);
-                throw new ServletException(msg);
-            }
-            return result;
-        }
-
-        /**
-         * This builds the important ClassPath used by this Servlet.  It
-         * does so in a Servlet Engine neutral way.  It uses the
-         * <code>ServletContext</code>'s <code>getRealPath</code> method
-         * to get the Servlet 2.2 identified classes and lib directories.
-         * It iterates in alphabetical order through every file in the
-         * lib directory and adds it to the classpath.
-         *
-         * Also, we add the files to the ClassLoader for the Cocoon system.
-         * In order to protect ourselves from skitzofrantic classloaders,
-         * we need to work with a known one.
-         *
-         * We need to get this to work properly when Cocoon is in a war.
-         *
-         */
-        public String getClassPath(Settings settings) {
-            StringBuffer buildClassPath = new StringBuffer();
-
-            File root = null;
-            if (this.getContextForWriting() != null) {
-                // Old method.  There *MUST* be a better method than this...
-
-                String classDir = this.config.getServletContext().getRealPath("/WEB-INF/classes");
-                String libDir = this.config.getServletContext().getRealPath("/WEB-INF/lib");
-
-                if (libDir != null) {
-                    root = new File(libDir);
-                }
-
-                if (classDir != null) {
-                    buildClassPath.append(classDir);
-                }
-            } else {
-                // New(ish) method for war'd deployments
-                URL classDirURL = null;
-                URL libDirURL = null;
-
-                try {
-                    classDirURL = this.config.getServletContext().getResource("/WEB-INF/classes");
-                } catch (MalformedURLException me) {
-                    this.logger.warn("Unable to add WEB-INF/classes to the classpath", me);
-                }
-
-                try {
-                    libDirURL = this.config.getServletContext().getResource("/WEB-INF/lib");
-                } catch (MalformedURLException me) {
-                    this.logger.warn("Unable to add WEB-INF/lib to the classpath", me);
-                }
-
-                if (libDirURL != null && libDirURL.toExternalForm().startsWith("file:")) {
-                    root = new File(libDirURL.toExternalForm().substring("file:".length()));
-                }
-
-                if (classDirURL != null) {
-                    buildClassPath.append(classDirURL.toExternalForm());
-                }
-            }
-
-            // Unable to find lib directory. Going the hard way.
-            if (root == null) {
-                root = this.extractLibraries(settings);
-            }
-
-            if (root != null && root.isDirectory()) {
-                File[] libraries = root.listFiles();
-                Arrays.sort(libraries);
-                for (int i = 0; i < libraries.length; i++) {
-                    String fullName = IOUtils.getFullFilename(libraries[i]);
-                    buildClassPath.append(File.pathSeparatorChar).append(fullName);
-                }
-            }
-
-            buildClassPath.append(File.pathSeparatorChar)
-                          .append(SystemUtils.JAVA_CLASS_PATH);
-
-            return buildClassPath.toString();
-        }
-
-        private File extractLibraries(Settings settings) {
-            try {
-                URL manifestURL = this.config.getServletContext().getResource("/META-INF/MANIFEST.MF");
-                if (manifestURL == null) {
-                    this.logger.fatalError("Unable to get Manifest");
-                    return null;
-                }
-
-                Manifest mf = new Manifest(manifestURL.openStream());
-                Attributes attr = mf.getMainAttributes();
-                String libValue = attr.getValue("Cocoon-Libs");
-                if (libValue == null) {
-                    this.logger.fatalError("Unable to get 'Cocoon-Libs' attribute from the Manifest");
-                    return null;
-                }
-
-                List libList = new ArrayList();
-                for (StringTokenizer st = new StringTokenizer(libValue, " "); st.hasMoreTokens();) {
-                    libList.add(st.nextToken());
-                }
-
-                File root = new File(settings.getWorkDirectory(), "lib");
-                root.mkdirs();
-
-                File[] oldLibs = root.listFiles();
-                for (int i = 0; i < oldLibs.length; i++) {
-                    String oldLib = oldLibs[i].getName();
-                    if (!libList.contains(oldLib)) {
-                        this.logger.debug("Removing old library " + oldLibs[i]);
-                        oldLibs[i].delete();
-                    }
-                }
-
-                this.logger.warn("Extracting libraries into " + root);
-                byte[] buffer = new byte[65536];
-                for (Iterator i = libList.iterator(); i.hasNext();) {
-                    String libName = (String) i.next();
-
-                    long lastModified = -1;
-                    try {
-                        lastModified = Long.parseLong(attr.getValue("Cocoon-Lib-" + libName.replace('.', '_')));
-                    } catch (Exception e) {
-                        this.logger.debug("Failed to parse lastModified: " + attr.getValue("Cocoon-Lib-" + libName.replace('.', '_')));
-                    }
-
-                    File lib = new File(root, libName);
-                    if (lib.exists() && lib.lastModified() != lastModified) {
-                        this.logger.debug("Removing modified library " + lib);
-                        lib.delete();
-                    }
-
-                    InputStream is = this.config.getServletContext().getResourceAsStream("/WEB-INF/lib/" + libName);
-                    if (is == null) {
-                        this.logger.warn("Skipping " + libName);
-                    } else {
-                        this.logger.debug("Extracting " + libName);
-                        OutputStream os = null;
-                        try {
-                            os = new FileOutputStream(lib);
-                            int count;
-                            while ((count = is.read(buffer)) > 0) {
-                                os.write(buffer, 0, count);
-                            }
-                        } finally {
-                            if (is != null) is.close();
-                            if (os != null) os.close();
-                        }
-                    }
-
-                    if (lastModified != -1) {
-                        lib.setLastModified(lastModified);
-                    }
-                }
-
-                return root;
-            } catch (IOException e) {
-                this.logger.fatalError("Exception while processing Manifest file", e);
-                return null;
-            }
-        }
-
     }
 }

Modified: cocoon/trunk/src/webapp/WEB-INF/logkit.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/logkit.xconf?rev=291398&r1=291397&r2=291398&view=diff
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/logkit.xconf (original)
+++ cocoon/trunk/src/webapp/WEB-INF/logkit.xconf Sun Sep 25 02:36:19 2005
@@ -42,8 +42,8 @@
       +-->
   <factories>
     <factory type="cocoon" class="org.apache.cocoon.util.log.CocoonTargetFactory"/>
-    <factory type="servlet" class="org.apache.avalon.excalibur.logger.factory.ServletTargetFactory"/>
-    <factory type="stream" class="org.apache.avalon.excalibur.logger.factory.StreamTargetFactory"/>
+    <!--factory type="servlet" class="org.apache.avalon.excalibur.logger.factory.ServletTargetFactory"/-->
+    <!--factory type="stream" class="org.apache.avalon.excalibur.logger.factory.StreamTargetFactory"/-->
   </factories>
 
   <!--+
@@ -104,6 +104,9 @@
       <append>@logappend@</append>
     </cocoon>
 
+    <!--+
+        | These targets are used for the more elaborate examples below.
+        |
     <servlet id="servlet">
       <format type="extended">%5.5{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\n</format>
     </servlet>
@@ -112,6 +115,7 @@
       <stream>System.out</stream>
       <format type="extended">%5.5{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\n</format>
     </stream>
+        +-->
   </targets>
 
   <!--+

Modified: cocoon/trunk/tools/targets/osgi-build.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/targets/osgi-build.xml?rev=291398&r1=291397&r2=291398&view=diff
==============================================================================
--- cocoon/trunk/tools/targets/osgi-build.xml (original)
+++ cocoon/trunk/tools/targets/osgi-build.xml Sun Sep 25 02:36:19 2005
@@ -79,6 +79,7 @@
   </target>
   
   <target name="osgi.prepare-webapp" depends="osgi.init">
+    <delete dir="${build.osgi.webapp}"/>
     <copy file="${webapp}/welcome.xml" tofile="${build.osgi.webapp}/welcome.xml" filtering="on"/>
     <copy file="${webapp}/not-found.xml" tofile="${build.osgi.webapp}/not-found.xml" filtering="on"/>
     <copy file="${webapp}/welcome.xslt" tofile="${build.osgi.webapp}/welcome.xslt" filtering="on"/>