haul        2003/01/31 08:22:55

  Modified:    src/java/org/apache/cocoon/components/modules/output
                        AbstractOutputModule.java RequestAttributeMap.java
                        RequestAttributeOutputModule.java
                        SessionAttributeOutputModule.java
  Log:
  optionally store values in safe place until commit
  
  Revision  Changes    Path
  1.6       +5 -3      
xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/AbstractOutputModule.java
  
  Index: AbstractOutputModule.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/AbstractOutputModule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractOutputModule.java 25 Jan 2003 02:53:41 -0000      1.5
  +++ AbstractOutputModule.java 31 Jan 2003 16:22:54 -0000      1.6
  @@ -61,6 +61,7 @@
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.util.HashMap;
  +//import java.util.HashMap;
   
   /**
    * AbstractOutputModule gives you the infrastructure for easily
  @@ -122,8 +123,9 @@
           Object temp = request.getAttribute(trans_place);
           Map aMap = null;
   
  -        if (temp == null) {
  -            aMap = new HashMap();
  +        if (temp == null) {           
  +            aMap = new java.util.HashMap();
  +            // need java.util.HashMap here since JXPath does not like the extended 
version...
           } else {
               aMap = (Map) temp;
           }
  
  
  
  1.3       +9 -1      
xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/RequestAttributeMap.java
  
  Index: RequestAttributeMap.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/RequestAttributeMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestAttributeMap.java  9 Jan 2003 17:04:17 -0000       1.2
  +++ RequestAttributeMap.java  31 Jan 2003 16:22:55 -0000      1.3
  @@ -83,6 +83,8 @@
        * @param value The attriute's value.
        * */
       public void setAttribute( Configuration modeConf, Map objectModel, String name, 
Object value ) {
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("setting transient ['"+name+"'] to ['"+value+"']");
           super.transientSetAttribute(objectModel, TRANS_PREFIX, name, value );
       }
       
  @@ -97,6 +99,8 @@
        * in data corruption!</em>
        * */
       public void rollback( Configuration modeConf, Map objectModel, Exception e ) {
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("rolling back");
           super.rollback(objectModel, TRANS_PREFIX);
       }
       
  @@ -106,6 +110,8 @@
        * successfully. See notes on @link{rollback}.
        * */
       public void commit( Configuration modeConf, Map objectModel ) {
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("prepare commit");
           Map aMap = super.prepareCommit(objectModel,TRANS_PREFIX);
           if (aMap == null) {
               // nothing to do
  @@ -123,6 +129,8 @@
               old.putAll(aMap);
           }
           request.setAttribute(prefix, old);
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("done commit to ['"+prefix+"']");
       }
       
   }
  
  
  
  1.7       +30 -1     
xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/RequestAttributeOutputModule.java
  
  Index: RequestAttributeOutputModule.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/RequestAttributeOutputModule.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RequestAttributeOutputModule.java 9 Jan 2003 17:04:17 -0000       1.6
  +++ RequestAttributeOutputModule.java 31 Jan 2003 16:22:55 -0000      1.7
  @@ -55,6 +55,7 @@
   import java.util.Map;
   
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   
  @@ -90,6 +91,8 @@
        * */
       public void setAttribute( Configuration modeConf, Map objectModel, String name, 
Object value ) {
           if (this.settings.get("isolation-level","0").equals("1")) {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("setting transient ['"+name+"'] to 
['"+value+"']");
               this.transientSetAttribute(objectModel, TRANS_PREFIX, name, value);
           } else {
               // use read uncommitted isolation level
  @@ -103,6 +106,8 @@
                   this.transientSetAttribute(objectModel, ROLLBACK_LIST, name, tmp);
               }
   
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("setting ['"+name+"'] to ['"+value+"']");
               request.setAttribute(name, value);
           }
       }
  @@ -120,9 +125,14 @@
        * */
       public void rollback( Configuration modeConf, Map objectModel, Exception e ) {
           if (this.settings.get("isolation-level","0").equals("1")) {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("rolling back");
               this.rollback(objectModel, TRANS_PREFIX);
           } else {
   
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("start rolling back");
  +            
               Request request = ObjectModelHelper.getRequest(objectModel);
               Object tmp = this.prepareCommit(objectModel,ROLLBACK_LIST);
               if (tmp != null) {
  @@ -132,14 +142,21 @@
                       String key = (String) iter.next();
                       Object val = rollbackList.get(key);
                       if (val != null) {
  +                        if (getLogger().isDebugEnabled())
  +                            getLogger().debug("rolling back ['"+key+"'] to 
['"+val+"']");
                           request.setAttribute(key, val);
                       } else {
  +                        if (getLogger().isDebugEnabled())
  +                            getLogger().debug("rolling back ['"+key+"']");
                           request.removeAttribute(key);
                       }
                   }
               }
           }
   
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("done rolling back");
  +
           String prefix = (String) this.settings.get("key-prefix", PREFIX );
           if (prefix!="") {
               
ObjectModelHelper.getRequest(objectModel).setAttribute(prefix+":",e.getMessage());
  @@ -155,6 +172,11 @@
        * */
       public void commit( Configuration modeConf, Map objectModel ) {
           if (this.settings.get("isolation-level","0").equals("1")) {
  +            
  +            Logger logger = getLogger();
  +            if (logger.isDebugEnabled())
  +                logger.debug("prepare commit");
  +
               Map aMap = this.prepareCommit(objectModel, TRANS_PREFIX);
               if (aMap == null) {
                   return;
  @@ -176,10 +198,17 @@
                   String key = (String) iter.next();
                   Object value = aMap.get(key);
                   if (prefix != null) { key = prefix + key; }
  +                if (logger.isDebugEnabled())
  +                    logger.debug("committing ['"+key+"'] to ['"+value+"']");
                   request.setAttribute(key, value);
               }
   
  +            if (logger.isDebugEnabled())
  +                logger.debug("done commit");
  +
           } else {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("commit");
               this.prepareCommit(objectModel, ROLLBACK_LIST);
           }
           
  
  
  
  1.6       +30 -1     
xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/SessionAttributeOutputModule.java
  
  Index: SessionAttributeOutputModule.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/output/SessionAttributeOutputModule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SessionAttributeOutputModule.java 9 Jan 2003 17:04:17 -0000       1.5
  +++ SessionAttributeOutputModule.java 31 Jan 2003 16:22:55 -0000      1.6
  @@ -55,6 +55,7 @@
   import java.util.Map;
   
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Session;
   
  @@ -90,6 +91,8 @@
        * */
       public void setAttribute( Configuration modeConf, Map objectModel, String name, 
Object value ) {
           if (this.settings.get("isolation-level","0").equals("1")) {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("setting transient ['"+name+"'] to 
['"+value+"']");
               this.transientSetAttribute(objectModel, TRANS_PREFIX, name, value);
           } else {
               // use read uncommitted isolation level
  @@ -103,6 +106,8 @@
                   this.transientSetAttribute(objectModel, ROLLBACK_LIST, name, tmp);
               }
   
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("setting ['"+name+"'] to ['"+value+"']");
               session.setAttribute(name, value);
           }
   
  @@ -121,9 +126,14 @@
        * */
       public void rollback( Configuration modeConf, Map objectModel, Exception e ) {
           if (this.settings.get("isolation-level","0").equals("1")) {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("rolling back");
               this.rollback(objectModel, TRANS_PREFIX);
           } else {
   
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("start rolling back");
  +            
               Session session = 
ObjectModelHelper.getRequest(objectModel).getSession();
               Object tmp = this.prepareCommit(objectModel,ROLLBACK_LIST);
               if (tmp != null) {
  @@ -133,14 +143,21 @@
                       String key = (String) iter.next();
                       Object val = rollbackList.get(key);
                       if (val != null) {
  +                        if (getLogger().isDebugEnabled())
  +                            getLogger().debug("rolling back ['"+key+"'] to 
['"+val+"']");
                           session.setAttribute(key, val);
                       } else {
  +                        if (getLogger().isDebugEnabled())
  +                            getLogger().debug("rolling back ['"+key+"']");
                           session.removeAttribute(key);
                       }
                   }
               }
           }
   
  +        if (getLogger().isDebugEnabled())
  +            getLogger().debug("done rolling back");
  +
           String prefix = (String) this.settings.get("key-prefix", PREFIX );
           if (prefix!="") {
               
ObjectModelHelper.getRequest(objectModel).getSession().setAttribute(prefix+":",e.getMessage());
  @@ -156,6 +173,11 @@
        * */
       public void commit( Configuration modeConf, Map objectModel ) {
           if (this.settings.get("isolation-level","0").equals("1")) {
  +
  +            Logger logger = getLogger();
  +            if (logger.isDebugEnabled())
  +                logger.debug("prepare commit");
  +
               Map aMap = this.prepareCommit(objectModel, TRANS_PREFIX);
               if (aMap == null) {
                   return;
  @@ -177,10 +199,17 @@
                   String key = (String) iter.next();
                   Object value = aMap.get(key);
                   if (prefix != null) { key = prefix + key; }
  +                if (logger.isDebugEnabled())
  +                    logger.debug("committing ['"+key+"'] to ['"+value+"']");
                   session.setAttribute(key, value);
               }
   
  +            if (logger.isDebugEnabled())
  +                logger.debug("done commit");
  +
           } else {
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("commit");
               this.prepareCommit(objectModel, ROLLBACK_LIST);
           }
           
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to