cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r530398 - in /cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src: changes/changes.xml main/java/org/apache/cocoon/generation/StatusGenerator.java
Date Thu, 19 Apr 2007 12:55:41 GMT
Author: reinhard
Date: Thu Apr 19 05:55:29 2007
New Revision: 530398

URL: http://svn.apache.org/viewvc?view=rev&rev=530398
Log:
COCOON-2047 show a list of all beans

Modified:
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/generation/StatusGenerator.java

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml?view=diff&rev=530398&r1=530397&r2=530398
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml Thu
Apr 19 05:55:29 2007
@@ -22,10 +22,18 @@
     |
     | @version $Id$
     +-->
-<document>
-  <body>
-    <release version="1.0.0-M1-SNAPSHOT" date="2007-00-00" description="unreleased">
 
-      
-    </release>
-  </body>
-</document>
+    <document>
+      <body>
+        <release version="1.0.0-RC1" date="2007-??-??" description="unreleased">  
+          <action dev="reinhard" type="add" due-to="Alexander Klimetschek" due-to-email="alexander.klimetschek@mindquarry.com"
issue="COCOON-2047">
+            StatusGenerator: Show a list of all Spring beans
+          </action>  
+        </release> 
+        <release version="1.0.0-M1" date="2007-03-02" description="released">  
+          <action dev="reinhard" type="add">
+            Initial creation.
+          </action>    
+        </release>
+      </body>
+    </document>
+    
\ No newline at end of file

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/generation/StatusGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/generation/StatusGenerator.java?view=diff&rev=530398&r1=530397&r2=530398
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/generation/StatusGenerator.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/generation/StatusGenerator.java
Thu Apr 19 05:55:29 2007
@@ -34,6 +34,7 @@
 import org.apache.cocoon.components.source.util.SourceUtil;
 import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.xml.AttributesImpl;
 import org.apache.cocoon.xml.XMLUtils;
 
@@ -43,6 +44,7 @@
 import org.apache.excalibur.source.TraversableSource;
 import org.apache.excalibur.store.Store;
 import org.apache.excalibur.store.StoreJanitor;
+import org.springframework.context.ApplicationContext;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -59,6 +61,7 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.Stack;
 import java.util.StringTokenizer;
 import java.util.TreeSet;
 
@@ -290,6 +293,7 @@
         }
         genSettings();
         genVMStatus();
+        genBeans();
         genProperties();
         if (this.showLibrary) {
             genLibrarylist();
@@ -297,6 +301,58 @@
 
         // End root element.
         super.contentHandler.endElement(NAMESPACE, "statusinfo", "statusinfo");
+    }
+
+    private void genBeans() throws SAXException {
+        startGroup("Spring Beans");
+        
+        Stack acStack = new Stack();
+
+        // get the hierarchy of Spring ApplicationContexts (BeanFactories)
+        {
+            ApplicationContext appContext =
+                WebAppContextUtils.getCurrentWebApplicationContext();
+            
+            acStack.push(appContext);
+            
+            while (appContext.getParent() != null) {
+                appContext = appContext.getParent();
+                acStack.push(appContext);
+            }
+        }
+        
+        int index = 0;
+        final int total = acStack.size();
+        
+        while (acStack.size() > 0) {
+            ApplicationContext ac = (ApplicationContext) acStack.pop();
+            
+            String acName;
+            if (index == (total-2)) {
+                acName = "Global ApplicationContext (" + ac.getDisplayName() + ")";
+            } else if (index == (total-1)) {
+                acName = "Sitemap ApplicationContext (" + ac.getDisplayName() + ")";    
           
+            } else {
+                acName = ac.getDisplayName();
+            }
+
+            List values = new ArrayList();
+            String[] names = ac.getBeanDefinitionNames();
+            for (int i=0,iEnd=names.length; i < iEnd; i++) {
+                String name = names[i];
+                Class type = ac.getType(name);
+                if (type == null) {
+                    values.add(name + " => ???");
+                } else {
+                    values.add(name + " => " + ac.getType(name).getName());
+                }
+            }
+            addMultilineValue(acName, values);
+            
+            index++;
+        }
+        
+        endGroup();
     }
 
     private void genContinuationsTree() throws SAXException {



Mime
View raw message