geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r814983 [1/5] - in /geronimo/server/trunk/plugins: ./ console/console-core/src/main/java/org/apache/geronimo/console/util/ debugviews/debugviews-console-jetty/ debugviews/debugviews-console-jetty/src/main/history/ debugviews/debugviews-cons...
Date Tue, 15 Sep 2009 03:31:08 GMT
Author: rwonly
Date: Tue Sep 15 03:31:07 2009
New Revision: 814983

URL: http://svn.apache.org/viewvc?rev=814983&view=rev
Log:
GERONIMO-4790 Migrate debug-views code to base on the up-to-date dojo: Sub-task 1

Added:
    geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/Tree.java   (with props)
    geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/TreeEntry.java   (with props)
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewHelper.java   (with props)
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewHelper.java   (with props)
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jndiview/JNDIViewHelper.java   (with props)
Removed:
    geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/StringTree.java
    geronimo/server/trunk/plugins/dojo-legacy/
Modified:
    geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/pom.xml
    geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/pom.xml
    geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_en.properties
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_zh.properties
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewPortlet.java
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/jndiview/JNDIViewPortlet.java
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerHelper.java
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/ldapmanager/LDAPManagerPortlet.java
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/classloaderview/view.jsp
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/dependencyview/view.jsp
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/jmxmanager/viewJMXServer.jsp
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/jndiview/view.jsp
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/ldapmanager/viewLDAPServer.jsp
    geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/web.xml
    geronimo/server/trunk/plugins/pom.xml

Added: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/Tree.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/Tree.java?rev=814983&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/Tree.java (added)
+++ geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/Tree.java Tue Sep 15 03:31:07 2009
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.directwebremoting.annotations.DataTransferObject;
+
+/*
+ * DWR data transfer object used by debugviews portlets and openejb portlets
+ */
+@DataTransferObject
+public class Tree {
+
+    private String label;
+
+    private String identifier;
+
+    private List<TreeEntry> items;
+
+    public Tree(String identifier, String label) {
+        this.label = label;
+        this.identifier = identifier;
+        this.items = new ArrayList<TreeEntry>();
+    }
+    
+    /*
+     * methods
+     */
+    public void addItem(TreeEntry item){
+        this.items.add(item);
+    }
+    
+    /*
+     * getters and setters
+     */
+    public List<TreeEntry> getItems() {
+        return items;
+    }
+    
+    public void setItems(List<TreeEntry> items) {
+        this.items = items;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public void setId(String identifier) {
+        this.identifier = identifier;
+    }
+}

Propchange: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/Tree.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/TreeEntry.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/TreeEntry.java?rev=814983&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/TreeEntry.java (added)
+++ geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/TreeEntry.java Tue Sep 15 03:31:07 2009
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.directwebremoting.annotations.DataTransferObject;
+
+/*
+ * DWR data transfer object used by debugviews portlets and openejb portlets
+ */
+@DataTransferObject
+public class TreeEntry {
+    
+
+    // Always Tree's label = "name"
+    private String name; 
+    
+    // We always specify the Tree's identifier = null, because we hope the id can be auto-generated so that keeping unique
+    // But in ClassLoaderViewHelper.java, we have to assign the id of node explicitly
+    private String id;
+        
+    // type
+    private String type;
+    
+    // values is used to record assistant information, 
+    private String[] values;
+    
+    // children
+    private List<TreeEntry> children;
+    
+    /*
+     * constructors
+     */
+    public TreeEntry(){
+        // Not recommended.
+    } 
+    
+    public TreeEntry(String name){
+        this(name, null, null);
+    }
+    
+    public TreeEntry(String name, String type){
+        this(name, type, null);
+    }
+    
+    public TreeEntry(String name, String type, String[] values){
+        this.name = name;
+        this.type = type;
+        this.values = values;
+        this.children = new ArrayList<TreeEntry>();
+    }
+
+    /*
+     * getters and setters
+     */
+    public List<TreeEntry> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<TreeEntry> children) {
+        this.children = children;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public String getId()
+    {
+        return this.id;
+    }
+    
+    public void setId(String id)
+    {
+        this.id = id;
+    }
+    
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String[] getValues() {
+        return values;
+    }
+
+    public void setValues(String[] values) {
+        this.values = values;
+    }
+    
+    /*
+     * methods
+     */
+    public void addChild(TreeEntry child){
+        this.children.add(child);
+    }
+
+    public TreeEntry findEntry(String name) {
+        if (name == null)
+            return null;
+        if (this.name != null && this.name.equals(name))
+            return this;
+        Iterator<TreeEntry> iter = children.iterator();
+        while (iter.hasNext()) {
+            TreeEntry entry = iter.next().findEntry(name);
+            if (entry != null)
+                return entry;
+        }
+        return null;
+    }
+}

Propchange: geronimo/server/trunk/plugins/console/console-core/src/main/java/org/apache/geronimo/console/util/TreeEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/pom.xml?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/pom.xml (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/pom.xml Tue Sep 15 03:31:07 2009
@@ -56,6 +56,7 @@
             <type>war</type>
             <scope>provided</scope>
         </dependency>
+
 <!--
         <dependency>
             <groupId>org.apache.geronimo.plugins</groupId>
@@ -63,6 +64,7 @@
             <version>${version}</version>
         </dependency>
 -->
+
         <dependency>
             <groupId>org.apache.geronimo.plugins</groupId>
             <artifactId>console-jetty</artifactId>
@@ -80,7 +82,7 @@
 
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
-            <artifactId>dojo-legacy-jetty</artifactId>
+            <artifactId>dojo-jetty</artifactId>
             <version>${version}</version>
             <type>car</type>
         </dependency>

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/src/main/history/dependencies.xml?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-console-jetty/src/main/history/dependencies.xml Tue Sep 15 03:31:07 2009
@@ -8,7 +8,7 @@
     </module-id>
     <dependency>
         <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>dojo-legacy-jetty</artifactId>
+        <artifactId>dojo-jetty</artifactId>
         <type>car</type>
     </dependency>
     <dependency>

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/pom.xml?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/pom.xml (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/pom.xml Tue Sep 15 03:31:07 2009
@@ -57,7 +57,8 @@
             <scope>provided</scope>
         </dependency>
 
-<!--        <dependency>
+<!--
+        <dependency>
             <groupId>org.apache.geronimo.plugins</groupId>
             <artifactId>console-core</artifactId>
             <version>${version}</version>
@@ -81,7 +82,7 @@
 
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
-            <artifactId>dojo-legacy-tomcat</artifactId>
+            <artifactId>dojo-tomcat</artifactId>
             <version>${version}</version>
             <type>car</type>
         </dependency>

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/src/main/history/dependencies.xml?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-console-tomcat/src/main/history/dependencies.xml Tue Sep 15 03:31:07 2009
@@ -8,7 +8,7 @@
     </module-id>
     <dependency>
         <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>dojo-legacy-tomcat</artifactId>
+        <artifactId>dojo-tomcat</artifactId>
         <type>car</type>
     </dependency>
     <dependency>

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_en.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_en.properties?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_en.properties (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_en.properties Tue Sep 15 03:31:07 2009
@@ -23,6 +23,9 @@
 
 debugviews.common.find     = Find
 debugviews.common.findNext = Find Next
+debugviews.common.notFound = Can not find
+debugviews.common.pleaseSelect = Please selecte one node
+debugviews.common.noText   = No text to search
 
 dependencyview.help.summary            = This view can be used to all the modules and its dependencies.
 dependencyview.help.title              = This is the help for the Geronimo Administration Dependency VIEW page.

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_zh.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_zh.properties?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_zh.properties (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/i18n-resources/debugviews_zh.properties Tue Sep 15 03:31:07 2009
@@ -23,6 +23,9 @@
 
 debugviews.common.find     = 查找
 debugviews.common.findNext = 查找下一个
+debugviews.common.notFound = 未能找到
+debugviews.common.pleaseSelect = 请选择一个节点
+debugviews.common.noText   = 请指定关键词
 
 dependencyview.help.summary            = 这个视图可以用于查看所有模块和它们的依赖项。
 dependencyview.help.title              = 这是一个帮助页面,指导你如何使用Geronimo控制台的依赖视图。

Added: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewHelper.java?rev=814983&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewHelper.java (added)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewHelper.java Tue Sep 15 03:31:07 2009
@@ -0,0 +1,221 @@
+package org.apache.geronimo.console.classloaderview;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.geronimo.console.util.TreeEntry;
+import org.apache.geronimo.kernel.config.MultiParentClassLoader;
+import org.apache.geronimo.kernel.util.ClassLoaderRegistry;
+import org.directwebremoting.annotations.RemoteMethod;
+import org.directwebremoting.annotations.RemoteProxy;
+
+@RemoteProxy
+public class ClassLoaderViewHelper {
+    Map<String, TreeEntry> nodeHash;
+    private static final String NO_CHILD = "none";
+    
+    private static final String NORMAL_TYPE = "normal";
+    
+    private static final CmpTreeEntry cmp = new CmpTreeEntry();
+
+    @RemoteMethod
+    public String getTrees(boolean inverse) {
+        nodeHash = new HashMap<String, TreeEntry>();
+
+        List list = ClassLoaderRegistry.getList();
+        Iterator iter = list.iterator();
+        while (iter.hasNext()) {
+            if (!inverse)
+                updateTree((ClassLoader) iter.next());
+            else
+                inverseTree((ClassLoader) iter.next());
+        }
+
+        return this.printClassLoaders();
+    }
+
+    public TreeEntry inverseTree(ClassLoader classloader) {
+        TreeEntry node = nodeHash.get(classloader.toString());
+        if (null != node)
+            return node;
+        node = new TreeEntry(classloader.toString(), "root");
+        node = addClasses(node, classloader);
+        nodeHash.put(node.getName(), node);
+
+        if (classloader instanceof MultiParentClassLoader) {
+            MultiParentClassLoader mpclassloader = (MultiParentClassLoader) classloader;
+            ClassLoader[] parents = mpclassloader.getParents();
+            if (null != parents && 0 < parents.length) {
+                for (int i = 0; i < parents.length; i++) {
+                    TreeEntry parentNode = inverseTree(parents[i]);
+                    node.addChild(parentNode);
+                }
+            }
+        } else if (classloader.getParent() != null) {
+            TreeEntry parentNode = inverseTree(classloader.getParent());
+            node.addChild(parentNode);
+        }
+
+        return node;
+    }
+
+    public TreeEntry updateTree(ClassLoader classloader) {
+
+        TreeEntry node = nodeHash.get(classloader.toString());
+        if (null != node)
+            return node;
+
+        node = new TreeEntry(classloader.toString(), NORMAL_TYPE);
+        node = addClasses(node, classloader);
+        nodeHash.put(node.getName(), node);
+
+        if (classloader instanceof MultiParentClassLoader) {
+            MultiParentClassLoader mpclassloader = (MultiParentClassLoader) classloader;
+            ClassLoader[] parents = mpclassloader.getParents();
+            if (null != parents && 0 < parents.length) {
+                for (int i = 0; i < parents.length; i++) {
+                    TreeEntry parentNode = updateTree(parents[i]);
+                    parentNode.addChild(node);
+                }
+            }
+        } else if (classloader.getParent() != null) {
+            TreeEntry parentNode = updateTree(classloader.getParent());
+            parentNode.addChild(node);
+        } else {
+            node.setType("root");
+        }
+
+        return node;
+    }
+
+    private TreeEntry addClasses(TreeEntry node, ClassLoader loader) {
+        try {
+            java.lang.reflect.Field CLASSES_VECTOR_FIELD = ClassLoader.class.getDeclaredField("classes");
+
+            if (CLASSES_VECTOR_FIELD.getType() != java.util.Vector.class) {
+                return node;
+            }
+            CLASSES_VECTOR_FIELD.setAccessible(true);
+
+            final java.util.Vector classes = (java.util.Vector) CLASSES_VECTOR_FIELD.get(loader);
+            if (classes == null)
+                return node;
+
+            final Class[] result;
+
+            synchronized (classes) {
+                result = new Class[classes.size()];
+                classes.toArray(result);
+            }
+
+            CLASSES_VECTOR_FIELD.setAccessible(false);
+
+            TreeEntry classNames = new TreeEntry("Classes", NORMAL_TYPE);
+            TreeEntry interfaceNames = new TreeEntry("Interfaces", NORMAL_TYPE);
+            node.addChild(classNames);
+            node.addChild(interfaceNames);
+
+            for (int i = 0; i < result.length; i++) {
+                if (result[i].isInterface())
+                    interfaceNames.addChild(new TreeEntry(result[i].toString(), NORMAL_TYPE));
+                else
+                    classNames.addChild(new TreeEntry(result[i].toString(), NORMAL_TYPE));
+            }
+            if (classNames.getChildren().size() < 1)
+                classNames.addChild(new TreeEntry(NO_CHILD, NORMAL_TYPE));
+            if (interfaceNames.getChildren().size() < 1)
+                interfaceNames.addChild(new TreeEntry(NO_CHILD, NORMAL_TYPE));
+            return node;
+        } catch (Exception e) {
+            return node;
+        }
+    }
+
+    /*
+     * Usually we can directly give the java objects to clients via dwr, but we found that it is too slow when the
+     * objects become larger and more complex because of the bad efficiency of dwr. So we need to translate the java
+     * object to json text by hand in such cases. But it is more specific to the implementation of dojo, so it is not
+     * very recommended.
+     */
+    String printClassLoaders() {
+        // generate an ordered id
+        List<TreeEntry> rootNodes = new ArrayList<TreeEntry>();
+        for (TreeEntry entry : nodeHash.values()) {
+            if (entry.getType().equals("root"))
+                rootNodes.add(entry);
+        }
+        markupId(-1, rootNodes); // here root nodes have already been sorted
+
+        List<TreeEntry> allNodes = rootNodes;
+        for (TreeEntry entry : nodeHash.values()) {
+            if (!entry.getType().equals("root"))
+                allNodes.add(entry);
+        }
+        StringBuilder sb = new StringBuilder(512);
+
+        sb.append("{label:\"name\",identifier:\"id\",items:[");
+        Iterator<TreeEntry> list = allNodes.iterator();
+        while (list.hasNext()) {
+            TreeEntry curr = list.next();
+            sb.append("{name:\"").append(curr.getName())
+            .append("\",id:\"").append(curr.getId())
+            .append("\",type:\"").append(curr.getType())
+            .append("\",children:[");
+
+            Iterator<TreeEntry> children = curr.getChildren().iterator();
+            // the first child is Classes and the second one is Interfaces
+            printClasses(sb, children.next());
+            sb.append(",");
+            printClasses(sb, children.next());
+            while (children.hasNext()) {
+                TreeEntry child = children.next();
+                sb.append(",{_reference:\"").append(child.getId()).append("\"}");
+            }
+            if (list.hasNext())
+                sb.append("]},");
+            else
+                sb.append("]}");
+        }
+        sb.append("]}");
+        return sb.toString();
+    }
+
+    private void printClasses(StringBuilder sb, TreeEntry classes) {
+        sb.append("{name:\"").append(classes.getName())
+        .append("\",id:\"").append(classes.getId())
+        .append("\",children:[");
+        Iterator<TreeEntry> children = classes.getChildren().iterator();
+        while (children.hasNext()) {
+            TreeEntry child = children.next();
+            sb.append("{name:\"").append(child.getName())
+            .append("\",id:\"").append(child.getId())
+            .append("\"}");
+            if (children.hasNext())
+                sb.append(",");
+        }
+        sb.append("]}");
+    }
+
+    private int markupId(int pre, List<TreeEntry> list) {
+        Collections.sort(list, cmp);
+        for (TreeEntry child : list) {
+            if (null == child.getId())
+                child.setId(String.valueOf(++pre));
+            pre = markupId(pre, child.getChildren());
+        }
+        return pre;
+    }
+
+    static class CmpTreeEntry implements Comparator<TreeEntry> {
+        public int compare(TreeEntry x, TreeEntry y) {
+            if (x.getName() == null)
+                return -1;
+            return x.getName().compareTo(y.getName());
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java Tue Sep 15 03:31:07 2009
@@ -17,14 +17,6 @@
 package org.apache.geronimo.console.classloaderview;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Collections;
-
-import org.apache.geronimo.console.BasePortlet;
-import org.apache.geronimo.console.util.StringTree;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -35,7 +27,7 @@
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 
-import org.apache.geronimo.kernel.util.ClassLoaderRegistry;
+import org.apache.geronimo.console.BasePortlet;
 
 public class ClassLoaderViewPortlet extends BasePortlet {
 
@@ -51,18 +43,8 @@
 
     private PortletRequestDispatcher helpView;
     
-    private boolean inverse;
-
     public void processAction(ActionRequest actionRequest,
             ActionResponse actionResponse) throws PortletException, IOException {
-    	// set selectedNode
-        actionRequest.getPortletSession().setAttribute("selectedNode", actionRequest.getParameter("snNode"));
-        // toggle between inverse and non-inverse each time the form is processed
-        inverse = actionRequest.getParameter("inverse").equalsIgnoreCase("true")? true : false;
-        // toggle
-        inverse = (!inverse);
-        // store inverse variable for the jsp
-        actionRequest.getPortletSession().setAttribute("invert", inverse );
     }
 
     protected void doView(RenderRequest renderRequest,
@@ -70,10 +52,6 @@
         if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
             return;
         }
-        renderRequest.getPortletSession().setAttribute("classloaderTree", this);
-        renderRequest.setAttribute("inverse", inverse);
-        renderRequest.getPortletSession().setAttribute("inverse", inverse);
-
         if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
             normalView.include(renderRequest, renderResponse);
         } else {
@@ -94,7 +72,6 @@
                 MAXIMIZEDVIEW_JSP);
         helpView = portletConfig.getPortletContext().getRequestDispatcher(
                 HELPVIEW_JSP);
-        inverse = false;
     }
 
     public void destroy() {
@@ -103,151 +80,4 @@
         helpView = null;
         super.destroy();
     }
-
-    public String getJSONTrees(boolean inverse) {
-        List list = getTrees(inverse);
-        if (list == null)
-            return "[]";
-
-        StringBuffer stb = new StringBuffer();
-        stb.append("[");
-        Hashtable htLinks = new Hashtable();
-        // First level cannot be a link
-        for (int i = 0; i < list.size(); i++) {
-            StringTree node = (StringTree) list.get(i);
-            htLinks.put(node.name, ""+i);
-        }
-        for (int i = 0; i < list.size(); i++) {
-            StringTree node = (StringTree) list.get(i);
-            if (i != 0)
-                stb.append(",");
-            stb.append(node.toJSONObject("" + i, htLinks, true));
-        }
-        stb.append("]");
-        list = null;
-        return stb.toString();
-    }
-
-    public ArrayList getTrees(boolean inverse) {
-        ArrayList parentNodes = new ArrayList();
-        List list = ClassLoaderRegistry.getList();
-        Iterator iter = list.iterator();
-        while (iter.hasNext()) {
-            if(!inverse)
-                updateTree((ClassLoader) iter.next(), parentNodes);
-            else
-                inverseTree((ClassLoader) iter.next(), parentNodes);
-        }
-        Collections.sort(parentNodes);
-        return parentNodes;
-    }
-
-    public StringTree inverseTree(ClassLoader classloader, ArrayList parentNodes) {
-        
-        StringTree node = new StringTree(classloader.toString());
-        int index = parentNodes.indexOf(node);
-        if(index != -1)
-            return (StringTree)parentNodes.get(index);
-        
-        node = addClasses(node, classloader);
-        
-        if (classloader instanceof org.apache.geronimo.kernel.config.MultiParentClassLoader) {
-            org.apache.geronimo.kernel.config.MultiParentClassLoader mpclassloader = (org.apache.geronimo.kernel.config.MultiParentClassLoader) classloader;
-            ClassLoader[] parents = mpclassloader.getParents();
-            if (parents != null)
-                for (int i = 0; i < parents.length; i++) {
-                    StringTree parentNode = inverseTree(parents[i],parentNodes);
-                    node.addChild(parentNode);
-                }
-        } else if (classloader.getParent() != null) {
-            StringTree parentNode = inverseTree(classloader.getParent(),parentNodes);
-            node.addChild(parentNode);
-        }        
-        if(!parentNodes.contains(node))
-            parentNodes.add(node);
-        
-        return node;
-    }
-
-    public StringTree updateTree(ClassLoader classloader, ArrayList parentNodes) {
-
-        Iterator iter = parentNodes.iterator();
-        StringTree node = null;
-        while (iter.hasNext()) {
-            StringTree currNode = (StringTree) iter.next();
-            node = currNode.findNode(classloader.toString());
-            if (node != null)
-                return node;
-        }
-
-        if (node == null) {
-            node = new StringTree(classloader.toString());
-            node = addClasses(node, classloader);
-
-            if (classloader instanceof org.apache.geronimo.kernel.config.MultiParentClassLoader) {
-                org.apache.geronimo.kernel.config.MultiParentClassLoader mpclassloader = (org.apache.geronimo.kernel.config.MultiParentClassLoader) classloader;
-                ClassLoader[] parents = mpclassloader.getParents();
-                if (parents == null)
-                    parentNodes.add(node);
-                else if (parents.length == 0)
-                    parentNodes.add(node);
-                else {
-                    for (int i = 0; i < parents.length; i++) {
-                        StringTree parentNode = updateTree(parents[i],
-                                parentNodes);
-                        parentNode.addChild(node);
-                    }
-                }
-            } else if (classloader.getParent() != null) {
-                StringTree parentNode = updateTree(classloader.getParent(),
-                        parentNodes);
-                parentNode.addChild(node);
-            } else
-                parentNodes.add(node);
-        }
-        return node;
-    }
-
-    private StringTree addClasses(StringTree node, ClassLoader loader) {
-        try {
-            java.lang.reflect.Field CLASSES_VECTOR_FIELD = ClassLoader.class
-                    .getDeclaredField("classes");
-
-            if (CLASSES_VECTOR_FIELD.getType() != java.util.Vector.class) {
-                return node;
-            }
-            CLASSES_VECTOR_FIELD.setAccessible(true);
-
-            final java.util.Vector classes = (java.util.Vector) CLASSES_VECTOR_FIELD
-                    .get(loader);
-            if (classes == null)
-                return node;
-
-            final Class[] result;
-
-            synchronized (classes) {
-                result = new Class[classes.size()];
-                classes.toArray(result);
-            }
-
-            CLASSES_VECTOR_FIELD.setAccessible(false);
-
-            StringTree classNames = new StringTree("Classes");
-            StringTree interfaceNames = new StringTree("Interfaces");
-            node.addChild(classNames);
-            node.addChild(interfaceNames);
-
-            for (int i = 0; i < result.length; i++) {
-                if (result[i].isInterface())
-                    interfaceNames.addChild(result[i].toString());
-                else
-                    classNames.addChild(result[i].toString());
-            }
-
-            return node;
-        } catch (Exception e) {
-            return node;
-        }
-    }
-
 }

Added: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewHelper.java?rev=814983&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewHelper.java (added)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewHelper.java Tue Sep 15 03:31:07 2009
@@ -0,0 +1,211 @@
+package org.apache.geronimo.console.dependencyview;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.geronimo.console.util.Tree;
+import org.apache.geronimo.console.util.TreeEntry;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ListableRepository;
+import org.apache.geronimo.management.geronimo.J2EEServer;
+import org.directwebremoting.annotations.RemoteMethod;
+import org.directwebremoting.annotations.RemoteProxy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RemoteProxy
+public class DependencyViewHelper {
+
+    private static final String NO_CHILD = "none";
+    
+    private static final String NOT_LEAF_TYPE = "not_leaf";
+    
+    private static final String NORMAL_TYPE = "normal";
+    
+    private static final Logger logger = LoggerFactory.getLogger(DependencyViewHelper.class);
+
+    public static void addDependencies(TreeEntry curr, Configuration conf) {
+        if (curr == null || conf == null)
+            return;
+        TreeEntry dep = new TreeEntry("dependencies", NOT_LEAF_TYPE);
+        curr.addChild(dep);
+        for (Iterator iterator = conf.getDependencies().iterator(); iterator.hasNext();) {
+            dep.addChild(new TreeEntry(iterator.next().toString(), NORMAL_TYPE));
+        }
+        for (Iterator iterator = conf.getServiceParents().iterator(); iterator.hasNext();) {
+            Configuration config = (Configuration) iterator.next();
+            dep.addChild(new TreeEntry(config.getId().toString(), NORMAL_TYPE));
+        }
+    }
+
+    @RemoteMethod
+    public static Tree getTrees(HttpSession session) {
+        Tree dependencyTree = new Tree(null, "name");
+
+        TreeEntry treeEAR = new TreeEntry("Enterprise Applications", NOT_LEAF_TYPE);
+        dependencyTree.addItem(treeEAR);
+
+        TreeEntry treeEJB = new TreeEntry("EJBModule", NOT_LEAF_TYPE);
+        dependencyTree.addItem(treeEJB);
+
+        TreeEntry treeWeb = new TreeEntry("WebModule", NOT_LEAF_TYPE);
+        dependencyTree.addItem(treeWeb);
+
+        TreeEntry treeRAR = new TreeEntry("ResourceAdapterModule", NOT_LEAF_TYPE);
+        dependencyTree.addItem(treeRAR);
+
+        TreeEntry treeCLI = new TreeEntry("AppClientModule", NOT_LEAF_TYPE);
+        dependencyTree.addItem(treeCLI);
+
+        TreeEntry treeSys = new TreeEntry("System Module", NOT_LEAF_TYPE);
+        dependencyTree.addItem(treeSys);
+
+        org.apache.geronimo.kernel.Kernel kernel = org.apache.geronimo.kernel.KernelRegistry.getSingleKernel();
+
+        ConfigurationManager configManager = ConfigurationUtil.getConfigurationManager(kernel);
+
+        List infos = configManager.listConfigurations();
+        for (Iterator infoIterator = infos.iterator(); infoIterator.hasNext();) {
+            ConfigurationInfo info = (ConfigurationInfo) infoIterator.next();
+            Configuration conf = configManager.getConfiguration(info.getConfigID());
+            if (conf != null) {
+                TreeEntry curr = new TreeEntry(info.getConfigID().toString(), NORMAL_TYPE);
+                switch (info.getType().getValue()) {
+                case 0:// EAR
+                {
+                    treeEAR.addChild(curr);
+                    break;
+                }
+                case 1:// EJB
+                {
+                    treeEJB.addChild(curr);
+                    break;
+                }
+                case 2:// CAR
+                {
+                    treeCLI.addChild(curr);
+                    break;
+                }
+
+                case 3:// RAR
+                {
+                    treeRAR.addChild(curr);
+                    break;
+                }
+                case 4:// WAR
+                {
+                    treeWeb.addChild(curr);
+                    break;
+                }
+                case 5:// SERVICE
+                {
+                    treeSys.addChild(curr);
+                    break;
+                }
+                }
+
+                addDependencies(curr, conf);
+
+                if (info.getType().getValue() == ConfigurationModuleType.EAR.getValue()) {
+                    TreeEntry nodeEJB = new TreeEntry("EJBModule", NOT_LEAF_TYPE);
+                    curr.addChild(nodeEJB);
+
+                    TreeEntry nodeWeb = new TreeEntry("WebModule", NOT_LEAF_TYPE);
+                    curr.addChild(nodeWeb);
+
+                    TreeEntry nodeRAR = new TreeEntry("ResourceAdapterModule", NOT_LEAF_TYPE);
+                    curr.addChild(nodeRAR);
+
+                    TreeEntry nodeCLI = new TreeEntry("AppClientModule", NOT_LEAF_TYPE);
+                    curr.addChild(nodeCLI);
+
+                    Map<String, String> query = new HashMap<String, String>();
+                    query.put("j2eeType", "EJBModule");
+                    query.put("J2EEApplication", info.getConfigID().toString());
+                    Set<AbstractName> setEnt = kernel.listGBeans(new AbstractNameQuery(null, query));
+                    for (AbstractName gb : setEnt) {
+                        TreeEntry subCurr = new TreeEntry(info.getConfigID().getGroupId() + "/"
+                                + info.getConfigID().getArtifactId() + "_" + gb.getNameProperty("name") + "/"
+                                + info.getConfigID().getVersion() + "/" + info.getConfigID().getType(), NORMAL_TYPE);
+                        nodeEJB.addChild(subCurr);
+                        addDependencies(subCurr, configManager.getConfiguration(gb.getArtifact()));
+                    }
+
+                    Map<String, String> query1 = new HashMap<String, String>();
+                    query1.put("j2eeType", "ResourceAdapterModule");
+                    query1.put("J2EEApplication", info.getConfigID().toString());
+                    Set<AbstractName> setEnt1 = kernel.listGBeans(new AbstractNameQuery(null, query1));
+
+                    for (AbstractName gb : setEnt1) {
+                        TreeEntry subCurr = new TreeEntry(info.getConfigID().getGroupId() + "/"
+                                + info.getConfigID().getArtifactId() + "_" + gb.getNameProperty("name") + "/"
+                                + info.getConfigID().getVersion() + "/" + info.getConfigID().getType(), NORMAL_TYPE);
+                        nodeRAR.addChild(subCurr);
+                        addDependencies(subCurr, configManager.getConfiguration(gb.getArtifact()));
+                    }
+
+                    for (Configuration config : conf.getChildren()) {
+                        TreeEntry subCurr = new TreeEntry(config.getAbstractName().toString(), NORMAL_TYPE);
+                        nodeWeb.addChild(subCurr);
+                        addDependencies(subCurr, config);
+                    }
+
+                    for (Artifact name : conf.getOwnedConfigurations()) {
+                        TreeEntry subCurr = new TreeEntry(name.toString(), NORMAL_TYPE);
+                        nodeCLI.addChild(subCurr);
+                        addDependencies(subCurr, configManager.getConfiguration(name));
+                    }
+
+                }
+
+            }
+
+        }
+
+        TreeEntry treeRepo = new TreeEntry("Repository", NORMAL_TYPE);
+        dependencyTree.addItem(treeRepo);
+        J2EEServer server = (J2EEServer) session.getAttribute(DependencyViewPortlet.Server_Key);
+        if (null == server) {
+            logger.error("can not find expected J2EEServer object");
+            treeRepo.addChild(new TreeEntry("Not found the content of repository", NORMAL_TYPE));// Ignore the error at client
+            return dependencyTree;
+        }
+        session.removeAttribute(DependencyViewPortlet.Server_Key);
+        ListableRepository[] repos = server.getRepositories();
+        for (int i = 0; i < repos.length; i++) {
+            ListableRepository repo = repos[i];
+            final SortedSet artifacts = repo.list();
+            for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
+                String fileName = iterator.next().toString();
+                treeRepo.addChild(new TreeEntry(fileName, NORMAL_TYPE));
+            }
+        }
+        check_no_child(dependencyTree.getItems());
+        return dependencyTree;
+    }
+
+    private static void check_no_child(List<TreeEntry> list) {
+        List<TreeEntry> children;
+        for (TreeEntry entry : list) {
+            children = entry.getChildren();
+            if (children.size() > 0)
+                check_no_child(children);
+            else if (entry.getType().equals(NOT_LEAF_TYPE))
+                children.add(new TreeEntry(NO_CHILD, NORMAL_TYPE));
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewPortlet.java?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewPortlet.java (original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/java/org/apache/geronimo/console/dependencyview/DependencyViewPortlet.java Tue Sep 15 03:31:07 2009
@@ -17,35 +17,19 @@
 package org.apache.geronimo.console.dependencyview;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
 import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 
 import org.apache.geronimo.console.BasePortlet;
 import org.apache.geronimo.console.util.PortletManager;
-import org.apache.geronimo.console.util.StringTree;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.ConfigurationInfo;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
-import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.ListableRepository;
 
 public class DependencyViewPortlet extends BasePortlet {
 
@@ -55,12 +39,14 @@
 
     private static final String HELPVIEW_JSP = "/WEB-INF/view/dependencyview/help.jsp";
 
+    static final String Server_Key = "org.apache.geronimo.console.dependencyview.J2EESever";
+    
     private PortletRequestDispatcher normalView;
 
     private PortletRequestDispatcher maximizedView;
 
     private PortletRequestDispatcher helpView;
-
+    
     public void processAction(ActionRequest actionRequest,
             ActionResponse actionResponse) throws PortletException, IOException {
     }
@@ -70,10 +56,9 @@
         if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
             return;
         }
-
-        renderRequest.getPortletSession().setAttribute("dependencyTree",
-                getJSONTrees(renderRequest));
-
+        //a little workaround
+        renderRequest.getPortletSession(true)
+            .setAttribute(Server_Key, PortletManager.getCurrentServer(renderRequest), PortletSession.APPLICATION_SCOPE);
         if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
             normalView.include(renderRequest, renderResponse);
         } else {
@@ -103,198 +88,4 @@
         helpView = null;
         super.destroy();
     }
-
-    private static ArrayList parentNodes = new ArrayList();
-
-    public static String getJSONTrees(RenderRequest renderRequest) {
-        List list = getTrees(renderRequest);
-        if (list == null)
-            return "[]";
-
-        StringBuffer stb = new StringBuffer();
-        stb.append("[");
-        for (int i = 0; i < list.size(); i++) {
-            StringTree node = (StringTree) list.get(i);
-            if (i != 0)
-                stb.append(",");
-            stb.append(node.toJSONObject("" + i));
-        }
-        stb.append("]");
-        return stb.toString();
-    }
-
-    public static void addDependencies(StringTree curr, Configuration conf) {
-        if (curr == null || conf == null)
-            return;
-        StringTree dep = new StringTree("dependencies");
-        curr.addChild(dep);
-        for (Iterator iterator = conf.getDependencies().iterator(); iterator
-                .hasNext();) {
-            dep.addChild(iterator.next().toString());
-        }
-        for (Iterator iterator = conf.getServiceParents().iterator(); iterator
-                .hasNext();) {
-            Configuration config = (Configuration) iterator.next();
-            dep.addChild(config.getId().toString());
-        }
-    }
-
-    public static ArrayList getTrees(RenderRequest request) {
-
-        ArrayList arryList = new ArrayList();
-        StringTree treeEAR = new StringTree("Enterprise Applications");
-        arryList.add(treeEAR);
-
-        StringTree treeEJB = new StringTree("EJBModule");
-        arryList.add(treeEJB);
-
-        StringTree treeWeb = new StringTree("WebModule");
-        arryList.add(treeWeb);
-
-        StringTree treeRAR = new StringTree("ResourceAdapterModule");
-        arryList.add(treeRAR);
-
-        StringTree treeCLI = new StringTree("AppClientModule");
-        arryList.add(treeCLI);
-
-        StringTree treeSys = new StringTree("System Module");
-        arryList.add(treeSys);
-
-        org.apache.geronimo.kernel.Kernel kernel = org.apache.geronimo.kernel.KernelRegistry
-                .getSingleKernel();
-
-        ConfigurationManager configManager = ConfigurationUtil
-                .getConfigurationManager(kernel);
-
-        List infos = configManager.listConfigurations();
-        for (Iterator infoIterator = infos.iterator(); infoIterator.hasNext();) {
-            ConfigurationInfo info = (ConfigurationInfo) infoIterator.next();
-            Configuration conf = configManager.getConfiguration(info
-                    .getConfigID());
-            if (conf != null) {
-                StringTree curr = new StringTree(info.getConfigID().toString());
-                switch (info.getType().getValue()) {
-                case 0:// EAR
-                {
-                    treeEAR.addChild(curr);
-                    break;
-                }
-                case 1:// EJB
-                {
-                    treeEJB.addChild(curr);
-                    break;
-                }
-                case 2:// CAR
-                {
-                    treeCLI.addChild(curr);
-                    break;
-                }
-
-                case 3:// RAR
-                {
-                    treeRAR.addChild(curr);
-                    break;
-                }
-                case 4:// WAR
-                {
-                    treeWeb.addChild(curr);
-                    break;
-                }
-                case 5:// SERVICE
-                {
-                    treeSys.addChild(curr);
-                    break;
-                }
-                }
-
-                addDependencies(curr, conf);
-
-                if (info.getType().getValue() == ConfigurationModuleType.EAR.getValue()) {
-                    StringTree nodeEJB = new StringTree("EJBModule");
-                    curr.addChild(nodeEJB);
-
-                    StringTree nodeWeb = new StringTree("WebModule");
-                    curr.addChild(nodeWeb);
-
-                    StringTree nodeRAR = new StringTree("ResourceAdapterModule");
-                    curr.addChild(nodeRAR);
-
-                    StringTree nodeCLI = new StringTree("AppClientModule");
-                    curr.addChild(nodeCLI);
-
-                    Map<String, String> query = new HashMap<String, String>();
-                    query.put("j2eeType", "EJBModule");
-                    query.put("J2EEApplication", info.getConfigID().toString());
-                    Set<AbstractName> setEnt = kernel.listGBeans(new AbstractNameQuery(null, query));
-                    for (AbstractName gb : setEnt) {
-                        StringTree subCurr = new StringTree(info.getConfigID().getGroupId()
-                                + "/"
-                                + info.getConfigID().getArtifactId()
-                                + "_"
-                                + gb.getNameProperty("name")
-                                + "/"
-                                + info.getConfigID().getVersion()
-                                + "/"
-                                + info.getConfigID().getType());
-                        nodeEJB.addChild(subCurr);
-                        addDependencies(subCurr, configManager
-                                .getConfiguration(gb.getArtifact()));
-                    }
-
-                    Map<String, String> query1 = new HashMap<String, String>();
-                    query1.put("j2eeType", "ResourceAdapterModule");
-                    query1.put("J2EEApplication", info.getConfigID().toString());
-                    Set<AbstractName> setEnt1 = kernel.listGBeans(new AbstractNameQuery(null, query1));
-
-                    for (AbstractName gb : setEnt1) {
-                        StringTree subCurr = new StringTree(info.getConfigID().getGroupId()
-                                + "/"
-                                + info.getConfigID().getArtifactId()
-                                + "_"
-                                + gb.getNameProperty("name")
-                                + "/"
-                                + info.getConfigID().getVersion()
-                                + "/"
-                                + info.getConfigID().getType());
-                        nodeRAR.addChild(subCurr);
-                        addDependencies(subCurr, configManager.getConfiguration(gb.getArtifact()));
-                    }
-
-                    for (Configuration config: conf.getChildren()) {
-                        StringTree subCurr = new StringTree(config.getAbstractName().toString());
-                        nodeWeb.addChild(subCurr);
-                        addDependencies(subCurr, config);
-                    }
-
-                    for (Artifact name : conf.getOwnedConfigurations()) {
-                        StringTree subCurr = new StringTree(name.toString());
-                        nodeCLI.addChild(subCurr);
-                        addDependencies(subCurr, configManager.getConfiguration(name));
-                    }
-
-                }
-
-            }
-
-        }
-
-        StringTree treeRepo = new StringTree("Repository");
-        arryList.add(treeRepo);
-
-        ListableRepository[] repos = PortletManager.getCurrentServer(request)
-                .getRepositories();
-        for (int i = 0; i < repos.length; i++) {
-            ListableRepository repo = repos[i];
-            final SortedSet artifacts = repo.list();
-            for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
-                String fileName = iterator.next().toString();
-                treeRepo.addChild(fileName);
-            }
-
-        }
-
-        return arryList;
-
-    }
-
 }



Mime
View raw message