You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/04/13 10:59:19 UTC

svn commit: r161167 - in lenya/trunk/src/java/org/apache/lenya: cms/cocoon/source/LenyaSourceFactory.java cms/cocoon/source/RepositorySource.java transaction/AbstractOperation.java

Author: andreas
Date: Wed Apr 13 01:59:18 2005
New Revision: 161167

URL: http://svn.apache.org/viewcvs?view=rev&rev=161167
Log:
use request attribute instead of session attribute to store UnitOfWork

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
    lenya/trunk/src/java/org/apache/lenya/transaction/AbstractOperation.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java?view=diff&r1=161166&r2=161167
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java Wed Apr 13 01:59:18 2005
@@ -31,7 +31,7 @@
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.Request;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceFactory;
@@ -131,17 +131,14 @@
                 path = path.substring(1);
             }
 
-            UnitOfWork unit = null;
             IdentityMap map = null;
-            Session session = ContextHelper.getRequest(this.context).getSession(false);
-            if (session != null) {
-                unit = (UnitOfWork) session.getAttribute(UnitOfWork.class.getName());
-                if (unit != null) {
-                    map = unit.getIdentityMap();
-                }
-                else {
-                    map = new DocumentIdentityMap(this.manager, getLogger());
-                }
+
+            Request request = ContextHelper.getRequest(this.context);
+            UnitOfWork unit = (UnitOfWork) request.getAttribute(UnitOfWork.class.getName());
+            if (unit != null) {
+                map = unit.getIdentityMap();
+            } else {
+                map = new DocumentIdentityMap(this.manager, getLogger());
             }
 
             if (getLogger().isDebugEnabled()) {

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java?view=diff&r1=161166&r2=161167
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/RepositorySource.java Wed Apr 13 01:59:18 2005
@@ -104,10 +104,10 @@
      */
     public OutputStream getOutputStream() throws IOException {
         try {
-            this.identityMap.getUnitOfWork().registerDirty(this.node);
             if (!this.node.isLocked()) {
                 throw new RuntimeException("Cannot write to source [" + getURI() + "]: not locked!");
             }
+            this.identityMap.getUnitOfWork().registerDirty(this.node);
             return new DOMOutputStream();
         } catch (TransactionException e) {
             throw new RuntimeException(e);

Modified: lenya/trunk/src/java/org/apache/lenya/transaction/AbstractOperation.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/transaction/AbstractOperation.java?view=diff&r1=161166&r2=161167
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/transaction/AbstractOperation.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/transaction/AbstractOperation.java Wed Apr 13 01:59:18 2005
@@ -27,7 +27,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.Request;
 
 /**
  * Abstract operation implementation.
@@ -70,10 +70,8 @@
     public void setUnitOfWork(UnitOfWork unit) {
         this.unitOfWork = unit;
         ContainerUtil.enableLogging(this.unitOfWork, getLogger());
-        Session session = ContextHelper.getRequest(this.context).getSession(false);
-        if (session != null) {
-            session.setAttribute(UnitOfWork.class.getName(), unit);
-        }
+        Request request = ContextHelper.getRequest(this.context);
+        request.setAttribute(UnitOfWork.class.getName(), unit);
     }
 
     protected ServiceManager manager;
@@ -117,4 +115,4 @@
         this.context = context;
     }
 
-}
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org