cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation StatusGenerator.java
Date Wed, 19 May 2004 11:32:02 GMT
cziegeler    2004/05/19 04:32:02

  Modified:    src/webapp/samples sitemap.xmap
               src/java/org/apache/cocoon/acting
                        ClearPersistentStoreAction.java
               src/java/org/apache/cocoon/generation StatusGenerator.java
  Added:       src/webapp/samples no-persistent-store.xml
  Log:
  ClearPersistentStore actions clears now the persistent store - if available
  StatusGenerator checks for persistent store as well
  
  Revision  Changes    Path
  1.26      +6 -3      cocoon-2.1/src/webapp/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/sitemap.xmap,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- sitemap.xmap	9 Apr 2004 07:23:45 -0000	1.25
  +++ sitemap.xmap	19 May 2004 11:32:02 -0000	1.26
  @@ -148,11 +148,14 @@
      <map:match pattern="clearpersistentstore.html">
       <map:act type="clear-persistent-store">
        <map:generate src="status" type="status"/>
  -    <map:transform src="context://stylesheets/system/status2html.xslt">
  +     <map:transform src="context://stylesheets/system/status2html.xslt">
         <map:parameter name="contextPath" value="{request:contextPath}"/>
  -    </map:transform>
  +     </map:transform>
        <map:serialize/>
       </map:act>
  +    <map:generate src="no-persistent-store.xml"/>
  +    <map:transform src="context://stylesheets/system/xml2html.xslt"/>
  +    <map:serialize type="html"/>
      </map:match>
   
      <map:match pattern="request.html">
  
  
  
  1.1                  cocoon-2.1/src/webapp/samples/no-persistent-store.xml
  
  Index: no-persistent-store.xml
  ===================================================================
  <information>
    You have no persistent store configured (This is no error if you're using
    JCS or EHCache for your store).
  </information>
  
  
  1.5       +14 -9     cocoon-2.1/src/java/org/apache/cocoon/acting/ClearPersistentStoreAction.java
  
  Index: ClearPersistentStoreAction.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/acting/ClearPersistentStoreAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClearPersistentStoreAction.java	19 May 2004 08:44:26 -0000	1.4
  +++ ClearPersistentStoreAction.java	19 May 2004 11:32:02 -0000	1.5
  @@ -37,16 +37,21 @@
                       String src,
                       Parameters par
       ) throws Exception {
  -        Store store_persistent = (Store)this.manager.lookup(Store.ROLE);
  +        if ( this.manager.hasService( Store.PERSISTENT_STORE) ) {
  +            final Store store_persistent = (Store)this.manager.lookup(Store.ROLE);
   
  -        try {
  -            store_persistent.clear();
  -            return EMPTY_MAP;
  -        } catch (Exception ex) {
  -            getLogger().debug("Exception while trying to Clearing the Store", ex);
  +            try {
  +                store_persistent.clear();
  +                return EMPTY_MAP;
  +            } catch (Exception ex) {
  +                getLogger().debug("Exception while trying to Clearing the Store", ex);
  +                return null;
  +            } finally {
  +                this.manager.release( store_persistent );
  +            }
  +        } else {
  +            getLogger().info("Unable to clear persistent store as no persistent store is
configured.");
               return null;
  -        } finally {
  -            this.manager.release( store_persistent );
           }
       }
   }
  
  
  
  1.7       +64 -55    cocoon-2.1/src/java/org/apache/cocoon/generation/StatusGenerator.java
  
  Index: StatusGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/StatusGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StatusGenerator.java	19 May 2004 08:44:27 -0000	1.6
  +++ StatusGenerator.java	19 May 2004 11:32:02 -0000	1.7
  @@ -99,12 +99,17 @@
        */
       public void service(ServiceManager manager) throws ServiceException {
           super.service(manager);
  -        try {
  +        if ( this.manager.hasService(StoreJanitor.ROLE) ) {
               this.storejanitor = (StoreJanitor)manager.lookup(StoreJanitor.ROLE);
  -            this.store_persistent = (Store)this.manager.lookup(Store.ROLE);
  -        } catch(ServiceException ce) {
  +        } else {
               getLogger().info("StoreJanitor is not available. Sorry, no cache statistics");
           }
  +        if ( this.manager.hasService(Store.PERSISTENT_STORE) ) {
  +            this.store_persistent = (Store)this.manager.lookup(Store.PERSISTENT_STORE);
  +        } else {
  +            getLogger().info("Persistent Store is not available. We will use the general
store instead.");
  +            this.store_persistent = (Store)this.manager.lookup(Store.ROLE);
  +        }
       }
       
       public void dispose() {
  @@ -209,36 +214,75 @@
           // END ClassPath
   
           // BEGIN Cache
  -        startGroup(ch, "Store-Janitor");
  -
  -        // For each element in StoreJanitor
  -        Iterator i = this.storejanitor.iterator();
  -        while (i.hasNext()) {
  -            Store store = (Store) i.next();
  -            startGroup(ch, store.getClass().getName()+" (hash = 0x"+Integer.toHexString(store.hashCode())+")"
);
  +        if ( this.storejanitor != null ) {
  +            startGroup(ch, "Store-Janitor");
  +    
  +            // For each element in StoreJanitor
  +            Iterator i = this.storejanitor.iterator();
  +            while (i.hasNext()) {
  +                Store store = (Store) i.next();
  +                startGroup(ch, store.getClass().getName()+" (hash = 0x"+Integer.toHexString(store.hashCode())+")"
);
  +                int size = 0;
  +                int empty = 0;
  +                atts.clear();
  +                atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
  +                ch.startElement(namespace, "value", "value", atts);
  +                // For each element in Store
  +                Enumeration e = store.keys();
  +                atts.clear();
  +                while( e.hasMoreElements() ) {
  +                    size++;
  +                    Object key  = e.nextElement();
  +                    Object val  = store.get( key );
  +                    String line = null;
  +                    if (val == null) {
  +                        empty++;
  +                    } else {
  +                        line = key + " (class: " + val.getClass().getName() + ")";
  +                        ch.startElement(namespace, "line", "line", atts);
  +                        ch.characters(line.toCharArray(), 0, line.length());
  +                        ch.endElement(namespace, "line", "line");
  +                    }
  +                }
  +    
  +                if (size == 0) {
  +                    ch.startElement(namespace, "line", "line", atts);
  +                    String value = "[empty]";
  +                    ch.characters(value.toCharArray(), 0, value.length());
  +                    ch.endElement(namespace, "line", "line");
  +                }
  +                ch.endElement(namespace, "value", "value");
  +    
  +                addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty
+ " are empty)");
  +                endGroup(ch);
  +            }
  +            endGroup(ch);        
  +        }
  +        
  +        if ( this.store_persistent != null ) {
  +            startGroup(ch, store_persistent.getClass().getName()+" (hash = 0x"+Integer.toHexString(store_persistent.hashCode())+")");
               int size = 0;
               int empty = 0;
               atts.clear();
               atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
               ch.startElement(namespace, "value", "value", atts);
  -            // For each element in Store
  -            Enumeration e = store.keys();
  -            atts.clear();
  -            while( e.hasMoreElements() ) {
  +            Enumeration enum = this.store_persistent.keys();
  +            while (enum.hasMoreElements()) {
                   size++;
  -                Object key  = e.nextElement();
  -                Object val  = store.get( key );
  +    
  +                Object key  = enum.nextElement();
  +                Object val  = store_persistent.get (key);
                   String line = null;
                   if (val == null) {
                       empty++;
                   } else {
  -                    line = key + " (class: " + val.getClass().getName() + ")";
  +                    line = key + " (class: " + val.getClass().getName() +  ")";
                       ch.startElement(namespace, "line", "line", atts);
                       ch.characters(line.toCharArray(), 0, line.length());
                       ch.endElement(namespace, "line", "line");
                   }
               }
  -
  +    
               if (size == 0) {
                   ch.startElement(namespace, "line", "line", atts);
                   String value = "[empty]";
  @@ -246,45 +290,10 @@
                   ch.endElement(namespace, "line", "line");
               }
               ch.endElement(namespace, "value", "value");
  -
  +    
               addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty + "
are empty)");
               endGroup(ch);
           }
  -        endGroup(ch);        
  -
  -        startGroup(ch, store_persistent.getClass().getName()+" (hash = 0x"+Integer.toHexString(store_persistent.hashCode())+")");
  -        int size = 0;
  -        int empty = 0;
  -        atts.clear();
  -        atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
  -        ch.startElement(namespace, "value", "value", atts);
  -        Enumeration enum = this.store_persistent.keys();
  -        while (enum.hasMoreElements()) {
  -            size++;
  -
  -            Object key  = enum.nextElement();
  -            Object val  = store_persistent.get (key);
  -            String line = null;
  -            if (val == null) {
  -                empty++;
  -            } else {
  -                line = key + " (class: " + val.getClass().getName() +  ")";
  -                ch.startElement(namespace, "line", "line", atts);
  -                ch.characters(line.toCharArray(), 0, line.length());
  -                ch.endElement(namespace, "line", "line");
  -            }
  -        }
  -
  -        if (size == 0) {
  -            ch.startElement(namespace, "line", "line", atts);
  -            String value = "[empty]";
  -            ch.characters(value.toCharArray(), 0, value.length());
  -            ch.endElement(namespace, "line", "line");
  -        }
  -        ch.endElement(namespace, "value", "value");
  -
  -        addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty + " are
empty)");
  -        endGroup(ch);
           // END Cache
   
           // BEGIN OS info
  
  
  

Mime
View raw message