KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > console > plugins > UCLLister


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.console.plugins;
23
24 import org.jboss.console.manager.interfaces.ManageableResource;
25 import org.jboss.console.manager.interfaces.ResourceTreeNode;
26 import org.jboss.console.manager.interfaces.TreeNode;
27 import org.jboss.console.plugins.helpers.AbstractPluginWrapper;
28
29 import javax.management.ObjectInstance JavaDoc;
30
31 /**
32  * As the number of UCL can be very big, we use a real Java class which is far
33  * faster than beanshell
34  *
35  * @see <related>
36  *
37  * @author <a HREF="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
38  * @version $Revision: 37459 $
39  *
40  * <p><b>Revisions:</b>
41  *
42  * <p><b>2 janv. 2003 Sacha Labourey:</b>
43  * <ul>
44  * <li> First implementation </li>
45  * </ul>
46  */

47 public class UCLLister
48    extends AbstractPluginWrapper
49 {
50
51    public UCLLister () { super(); }
52    
53    ResourceTreeNode createUCLSubResource (ObjectInstance JavaDoc instance) throws Exception JavaDoc
54    {
55       String JavaDoc uclName = instance.getObjectName().getKeyProperty ("UCL");
56             
57       return createResourceNode (
58             "UCL " + uclName, // name
59
"UCL with id " + uclName, // description
60
"images/service.gif", // Icon URL
61
"/jmx-console/HtmlAdaptor?action=inspectMBean&name=" + encode(instance.getObjectName().toString()), // Default URL
62
null,
63             null,
64             null,
65             instance.getObjectName().toString(),
66             instance.getClassName () );
67    }
68    
69    ResourceTreeNode[] createUCLSubResources () throws Exception JavaDoc
70    {
71       ObjectInstance JavaDoc[] insts =
72          getMBeansForClass("jmx.loading:*",
73             "org.jboss.mx.loading.UnifiedClassLoader3");
74       
75       ResourceTreeNode[] result = new ResourceTreeNode[insts.length];
76       for (int i=0; i<result.length; i++)
77       {
78          result[i] = createUCLSubResource (insts[i]);
79       }
80       
81       return result;
82    }
83    
84    protected TreeNode getTreeForResource(String JavaDoc profile, ManageableResource resource)
85    {
86       try
87       {
88          return createTreeNode (
89                "Unified ClassLoaders", // name
90
"Display all JBoss UCLs", // description
91
"images/recycle.gif", // Icon URL
92
null, // Default URL
93
null,
94                null, // sub nodes
95
createUCLSubResources () // Sub-Resources
96
);
97       }
98       catch (Exception JavaDoc e)
99       {
100          e.printStackTrace ();
101          return null;
102       }
103    }
104
105   
106 }
107
Popular Tags