cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r417773 - in /cocoon/trunk/core/cocoon-core/src: main/java/org/apache/cocoon/ main/java/org/apache/cocoon/core/ main/java/org/apache/cocoon/core/servlet/ main/java/org/apache/cocoon/servlet/ test/java/org/apache/cocoon/core/
Date Wed, 28 Jun 2006 14:54:30 GMT
Author: cziegeler
Date: Wed Jun 28 07:54:29 2006
New Revision: 417773

URL: http://svn.apache.org/viewvc?rev=417773&view=rev
Log:
Simplify CoreUtil a little bit

Removed:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/servlet/CoreUtil.java
Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Constants.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java
    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Constants.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Constants.java?rev=417773&r1=417772&r2=417773&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Constants.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Constants.java Wed Jun 28
07:54:29 2006
@@ -181,9 +181,6 @@
     /** Application <code>Context</code> Key for the environmental Context */
     public static final String CONTEXT_ENVIRONMENT_CONTEXT = "environment-context";
 
-    /** Application <code>Context</code> Key for the global classloader */
-    public static final String CONTEXT_CLASS_LOADER = "class-loader";
-
     /** Application <code>Context</code> Key for the work directory path */
     public static final String CONTEXT_WORK_DIR = "work-directory";
 

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java?rev=417773&r1=417772&r2=417773&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java Wed Jun
28 07:54:29 2006
@@ -90,8 +90,6 @@
     /** The Root processor instance */
     protected Processor processor;
 
-    protected ClassLoader classloader;
-
     /** The environment context. */
     protected final Context environmentContext;
 
@@ -155,7 +153,7 @@
      * @param context     The environment context.
      * @throws Exception
      */
-    public CoreUtil(Context              context)
+    public CoreUtil(Context context)
     throws Exception {
         this(context, null);
     }
@@ -189,9 +187,9 @@
         // Create bootstrap logger
         this.log = BeanFactoryUtil.createBootstrapLogger(this.environmentContext, settings.getBootstrapLogLevel());
 
-        if (this.log.isDebugEnabled())
+        if (this.log.isDebugEnabled()) {
             this.log.debug("Context URL: " + contextUrl);
-
+        }
         // initialize some directories
         CoreUtil.initSettingsFiles(this.settings, this.log);
 
@@ -209,9 +207,8 @@
         this.log = BeanFactoryUtil.createRootLogger(this.environmentContext,
                                                     this.settings);
 
-        this.createClassloader();
         // add the Avalon context attributes that are contained in the settings
-        CoreUtil.addSettingsContext(this.appContext, this.settings, this.classloader);
+        CoreUtil.addSettingsContext(this.appContext, this.settings);
 
         // test the setup of the spring based container
         this.container = this.setupSpringContainer();
@@ -287,7 +284,7 @@
         throws ServletException, MalformedURLException {
         DefaultContext appContext = new ComponentContext();
         CoreUtil.addSourceResolverContext(appContext, environmentContext, env, contextUrl);
-        CoreUtil.addSettingsContext(appContext, settings, classLoader);
+        CoreUtil.addSettingsContext(appContext, settings);
         return appContext;
     }
 
@@ -321,7 +318,7 @@
      * @param classloader 
      * @throws MalformedURLException
      */
-    private static void addSettingsContext(DefaultContext appContext, Settings settings,
ClassLoader classloader)
+    private static void addSettingsContext(DefaultContext appContext, Settings settings)
     throws MalformedURLException {
         appContext.put(Constants.CONTEXT_WORK_DIR, new File(settings.getWorkDirectory()));
         appContext.put(Constants.CONTEXT_UPLOAD_DIR, new File(settings.getUploadDirectory()));
@@ -330,7 +327,6 @@
         	appContext.put(Constants.CONTEXT_CONFIG_URL, new URL(settings.getConfiguration()));
         }
         appContext.put(Constants.CONTEXT_DEFAULT_ENCODING, settings.getFormEncoding());
-        appContext.put(Constants.CONTEXT_CLASS_LOADER, classloader);
     }
 
     public Logger getRootLogger() {
@@ -520,14 +516,6 @@
     }
 
     /**
-     * Create the classloader 
-     * @throws Exception
-     */
-    protected void createClassloader() throws Exception {
-        this.classloader = Thread.currentThread().getContextClassLoader();
-    }
-
-    /**
      * Creates the Cocoon object and handles exception handling.
      */
     public synchronized Cocoon createCocoon()
@@ -540,10 +528,11 @@
      * Gets the current cocoon object.
      * Reload cocoon if configuration changed or we are reloading.
      * Ensure that the correct classloader is set.
+     * @param reload Should the container be reloaded?
      */
-    public Cocoon getCocoon(final String pathInfo, final String reloadParam)
+    public Cocoon getCocoon(boolean reload)
     throws Exception {
-        this.getProcessor(pathInfo, reloadParam);
+        this.getProcessor(reload);
         return (Cocoon)this.processor;
     }
 
@@ -574,13 +563,10 @@
     /**
      * Gets the current root processor object.
      * Reload the root processor if configuration changed or we are reloading.
-     * Ensure that the correct classloader is set.
+     * @param reloadContainer Should the container be reloaded?
      */
-    public Processor getProcessor(final String pathInfo, final String reloadParam)
+    public Processor getProcessor(boolean reloadContainer)
     throws Exception {
-        // set the blocks classloader for this thread
-        Thread.currentThread().setContextClassLoader(this.classloader);        
-        
         if (this.settings.isReloadingEnabled("config")) {
             boolean reload = false;
 
@@ -590,13 +576,13 @@
                         this.log.info("Configuration changed reload attempt");
                     }
                     reload = true;
-                } else if (pathInfo == null && reloadParam != null) {
+                } else if (reloadContainer) {
                     if (this.log.isInfoEnabled()) {
                         this.log.info("Forced reload attempt");
                     }
                     reload = true;
                 }
-            } else if (pathInfo == null && reloadParam != null) {
+            } else if (reloadContainer) {
                 if (this.log.isInfoEnabled()) {
                     this.log.info("Invalid configurations reload");
                 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java?rev=417773&r1=417772&r2=417773&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java
Wed Jun 28 07:54:29 2006
@@ -212,7 +212,8 @@
         // Get the cocoon engine instance
         try {
             this.exception = null;
-            this.processor = this.coreUtil.getProcessor(request.getPathInfo(), request.getParameter(Constants.RELOAD_PARAM));
+            final boolean reload = (request.getPathInfo() == null && request.getParameter(Constants.RELOAD_PARAM)
!= null);
+            this.processor = this.coreUtil.getProcessor(reload);
         } catch (Exception e) {
             this.exception = e;
         }

Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java?rev=417773&r1=417772&r2=417773&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java Wed
Jun 28 07:54:29 2006
@@ -23,13 +23,8 @@
 
     public TestCoreUtil(BootstrapEnvironment env) throws Exception {
         super(new MockContext(), env);
-        this.classloader = TestCoreUtil.class.getClassLoader();
     }
 
     // Simplified classloader handling
     protected void updateEnvironment() throws Exception {}
-
-    // No own classloader
-    protected void createClassloader() throws Exception {
-    }
 }



Mime
View raw message