KickJava   Java API By Example, From Geeks To Geeks.

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


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.J2EEApplicationMBean;
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 J2EEAppLister
50    extends AbstractPluginWrapper
51 {
52    private static final long serialVersionUID = 4168885656223716764L;
53    
54    protected final static String JavaDoc JMX_JSR77_DOMAIN = "jboss.management.local";
55    
56    public J2EEAppLister () { super(); }
57       
58    ResourceTreeNode[] createModules (String JavaDoc[] modules) throws Exception JavaDoc
59    {
60       ResourceTreeNode[] deployed = new ResourceTreeNode[modules.length];
61       for (int i = 0; i < modules.length; i++)
62       {
63          //J2EEApplication earProxy = (J2EEApplication)
64
// MBeanProxy.create(J2EEApplication.class, objName, getMBeanServer());
65

66
67          ObjectName JavaDoc objectName = new ObjectName JavaDoc(modules[i]);
68          deployed[i] = createResourceNode (
69             objectName.getKeyProperty ("name"), // name
70
"", // description
71
"images/EspressoMaker.gif", // Icon URL
72
null, // "J2EEApp.jsp?ObjectName=" + encode (objName.toString ()), // Default URL
73
null,
74             null, // sub nodes
75
null, //createEARSubModules (objName), // Sub-Resources
76
modules[i].toString (),
77             this.mbeanServer.getMBeanInfo (objectName).getClassName ()
78          ).setVisibility (ResourceTreeNode.INVISIBLE_IF_SUBNODE_EXISTS);
79
80       }
81
82       return deployed;
83    }
84
85    protected TreeNode getTreeForResource(String JavaDoc profile, ManageableResource resource)
86    {
87       try
88       {
89          ObjectName JavaDoc objName = ((MBeanResource)resource).getObjectName();
90          J2EEApplicationMBean appProxy = (J2EEApplicationMBean)
91             MBeanProxyExt.create (J2EEApplicationMBean.class, objName, getMBeanServer());
92
93          return createTreeNode
94             (
95                objName.getKeyProperty("name"), // name
96
"", // description
97
"images/EspressoMaker.gif", // Icon URL
98
"J2EEApp.jsp?ObjectName=" + encode (objName.toString ()), // Default URL
99
null,
100                null, // sub nodes
101
createModules (appProxy.getmodules()) // Sub-Resources
102
).setMasterNode(true);
103          
104       }
105       catch (Exception JavaDoc e)
106       {
107          e.printStackTrace ();
108          System.out.println (checker);
109          return null;
110          
111       }
112    }
113
114 }
115
Popular Tags