cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r691199 - in /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon: components/pipeline/impl/ environment/commandline/
Date Tue, 02 Sep 2008 11:17:56 GMT
Author: thorsten
Date: Tue Sep  2 04:17:55 2008
New Revision: 691199

URL: http://svn.apache.org/viewvc?rev=691199&view=rev
Log:
COCOON-2241 - The commandline is not working since cocoon-1985. In COCOON-1985 it was introduced
a lock to prevent problems in concurrent situations. This code change was not tested with
the CLI mode of cocoon since the cli environment does not store the http-requested object.
The introduced solution looks wheter the http-request object is null if so we will test whether
we are in cli mode and lock this object instead.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java?rev=691199&r1=691198&r2=691199&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Tue Sep  2 04:17:55 2008
@@ -36,6 +36,8 @@
 import org.apache.cocoon.caching.ComponentCacheKey;
 import org.apache.cocoon.caching.PipelineCacheKey;
 import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.commandline.AbstractCommandLineEnvironment;
 import org.apache.cocoon.environment.http.HttpEnvironment;
 import org.apache.cocoon.transformation.Transformer;
 import org.apache.cocoon.util.HashUtil;
@@ -193,6 +195,9 @@
 
             // Avoid deadlock with self (see JIRA COCOON-1985).
             Object current = env.getObjectModel().get(HttpEnvironment.HTTP_REQUEST_OBJECT);
+            if (current==null){
+              current = env.getObjectModel().get(AbstractCommandLineEnvironment.CLI_REQUEST_ID);
+            }
             if (lock != null && lock != current) {
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Waiting on Lock '" + lockKey + "'");
@@ -243,6 +248,9 @@
                     }
                 } else {
                     Object lock = env.getObjectModel().get(HttpEnvironment.HTTP_REQUEST_OBJECT);
+                    if (lock == null){
+                      lock = env.getObjectModel().get(AbstractCommandLineEnvironment.CLI_REQUEST_ID);
+                    }
                     try {
                         transientStore.store(lockKey, lock);
                     } catch (IOException e) {

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java?rev=691199&r1=691198&r2=691199&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
Tue Sep  2 04:17:55 2008
@@ -22,6 +22,7 @@
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.components.source.SourceUtil;
 import org.apache.cocoon.environment.AbstractEnvironment;
+import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
@@ -32,6 +33,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.MalformedURLException;
+import java.util.Map;
 
 /**
  * This environment is used to save the requested file to disk.
@@ -43,6 +45,8 @@
 public abstract class AbstractCommandLineEnvironment
 extends AbstractEnvironment
 implements Redirector {
+  
+    public static final String CLI_REQUEST_ID = "clirequest-id";
 
     protected String contentType;
     protected int contentLength;
@@ -56,11 +60,36 @@
                                           Logger log)
     throws MalformedURLException {
         super(uri, view, context);
-        this.enableLogging(log);
-        this.outputStream = stream;
-        this.statusCode = 0;
+        initCliEnvironment(stream, log);
+        
     }
+    private void initCliEnvironment(OutputStream stream, Logger log) {
+      this.enableLogging(log);
+      this.outputStream = stream;
+      this.statusCode = 0;
+    }
+    public AbstractCommandLineEnvironment(String uri,
+        Map attributes,
+        Map parameters,
+        Map headers,
+        String view,
+        File context,
+        CommandLineContext cliContext,
+        OutputStream stream,
+        Logger log)
+    throws MalformedURLException {
+      super(uri, view, context);
+      initCliEnvironment(stream, log);
+      CommandLineRequest request = new CommandLineRequest(this, null, uri, null, attributes,
parameters, headers);
+      this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT,
+          request);
+      this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT,
+          new CommandLineResponse());
+      this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT,
+          cliContext);
+      this.objectModel.put(CLI_REQUEST_ID, new String(uri));
 
+    }
     /**
      * Redirect the client to a new URL
      */

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java?rev=691199&r1=691198&r2=691199&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java
Tue Sep  2 04:17:55 2008
@@ -19,7 +19,6 @@
 import org.apache.avalon.framework.logger.Logger;
 
 import org.apache.cocoon.Constants;
-import org.apache.cocoon.environment.ObjectModelHelper;
 
 import java.io.File;
 import java.io.OutputStream;
@@ -51,13 +50,7 @@
                                  OutputStream stream,
                                  Logger log)
     throws MalformedURLException {
-        super(uri, null, context, stream, log);
-        this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT,
-                             new CommandLineRequest(this, null, uri, null, attributes, parameters,
headers));
-        this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT,
-                             new CommandLineResponse());
-        this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT,
-                             cliContext);
+        super(uri, attributes, parameters, headers, null, context, cliContext, stream, log);
         this.sourceLastModified = lastModified;
         if (links != null) {
             this.objectModel.put(Constants.LINK_OBJECT, links);

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java?rev=691199&r1=691198&r2=691199&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
Tue Sep  2 04:17:55 2008
@@ -29,7 +29,6 @@
 
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.cocoon.Constants;
-import org.apache.cocoon.environment.ObjectModelHelper;
 
 /**
  * This environment is sample the links of the resource.
@@ -50,16 +49,10 @@
                                    CommandLineContext cliContext,
                                    Logger log)
     throws MalformedURLException, IOException {
-        super(uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), log);
+        super(uri, attributes, parameters, headers, Constants.LINK_VIEW, contextFile, cliContext,
new ByteArrayOutputStream(), log);
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("uri = " + uri);
         }
-        this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT,
-                             new CommandLineRequest(this, null, uri, null, attributes, parameters,
headers));
-        this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT,
-                             new CommandLineResponse());
-        this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT,
-                             cliContext);
     }
 
     /**



Mime
View raw message