KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.management.ObjectName JavaDoc;
25
26 import org.jboss.console.manager.interfaces.ManageableResource;
27 import org.jboss.console.manager.interfaces.ResourceTreeNode;
28 import org.jboss.console.manager.interfaces.TreeNode;
29 import org.jboss.console.manager.interfaces.impl.MBeanResource;
30 import org.jboss.console.plugins.helpers.AbstractPluginWrapper;
31 import org.jboss.management.j2ee.WebModuleMBean;
32 import org.jboss.mx.util.MBeanProxyExt;
33 /**
34  * As the number of MBeans is very big, we use a real Java class which is far
35  * faster than beanshell
36  *
37  * @see <related>
38  *
39  * @author <a HREF="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
40  * @version $Revision: 43303 $
41  *
42  * <p><b>Revisions:</b>
43  *
44  * <p><b>2 janv. 2003 Sacha Labourey:</b>
45  * <ul>
46  * <li> First implementation </li>
47  * </ul>
48  */

49 public class WebModuleLister
50    extends AbstractPluginWrapper
51 {
52    private static final long serialVersionUID = -8019251323455453105L;
53
54    protected final static String JavaDoc JMX_JSR77_DOMAIN = "jboss.management.local";
55    
56    public WebModuleLister () { super(); }
57       
58    ResourceTreeNode[] createBeans (ObjectName JavaDoc parent) throws Exception JavaDoc
59    {
60        WebModuleMBean wmProxy = (WebModuleMBean)
61                MBeanProxyExt.create(WebModuleMBean.class, parent, getMBeanServer());
62
63        String JavaDoc[] servletsObjectName = wmProxy.getservlets();
64
65       ResourceTreeNode[] servlets = new ResourceTreeNode[servletsObjectName.length];
66       for (int i=0; i< servletsObjectName.length; i++)
67       {
68          ObjectName JavaDoc objectName = new ObjectName JavaDoc(servletsObjectName[i]);
69           String JavaDoc name = objectName.getKeyProperty("name");
70
71           servlets[i] = createResourceNode(
72                   name, // name
73
"'" + name + "' Servlet", // description
74
"images/serviceset.gif", // Icon URL
75
"Servlet.jsp?ObjectName=" + encode(objectName.toString()), // Default URL
76
null,
77                null, // sub nodes
78
null, // Sub-Resources
79
objectName.toString(),
80                org.jboss.management.j2ee.Servlet.class.getName()
81             );
82          
83       }
84           
85       return servlets;
86    }
87
88    protected TreeNode getTreeForResource(String JavaDoc profile, ManageableResource resource)
89    {
90       try
91       {
92          ObjectName JavaDoc objName = ((MBeanResource)resource).getObjectName();
93
94          return createTreeNode
95             (
96                objName.getKeyProperty("name"), // name
97
"", // description
98
"images/spirale.gif", // Icon URL
99
"WebModule.jsp?ObjectName=" + encode(objName.toString()), // Default URL
100
null,
101                null, // sub nodes
102
createBeans (objName) // Sub-Resources
103
).setMasterNode(true);
104          
105       }
106       catch (Exception JavaDoc e)
107       {
108          e.printStackTrace ();
109          System.out.println (checker);
110          return null;
111          
112       }
113    }
114
115 }
116
Popular Tags