KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > runtime > nodes > EnterpriseApplicationNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.sun.ide.runtime.nodes;
20 import com.sun.appserv.management.j2ee.AppClientModule;
21 import com.sun.appserv.management.j2ee.EJBModule;
22 import com.sun.appserv.management.j2ee.WebModule;
23 import java.util.List JavaDoc;
24 import java.util.Arrays JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26 import org.netbeans.modules.j2ee.sun.ide.controllers.AppClientModuleController;
27 import org.netbeans.modules.j2ee.sun.ide.controllers.ConnectorModuleController;
28 import org.netbeans.modules.j2ee.sun.ide.controllers.ControllerUtil;
29 import org.netbeans.modules.j2ee.sun.ide.controllers.EJBModuleController;
30
31 import org.netbeans.modules.j2ee.sun.ide.controllers.J2EEApplicationMgmtController;
32 import org.netbeans.modules.j2ee.sun.ide.controllers.WebModuleController;
33 import org.netbeans.modules.j2ee.sun.util.NodeTypes;
34 import org.openide.nodes.Children;
35 import org.openide.nodes.Node;
36 import com.sun.appserv.management.base.Util;
37 import com.sun.appserv.management.j2ee.ResourceAdapterModule;
38
39 /**
40  */

41 public class EnterpriseApplicationNode extends AppserverMgmtApplicationsNode {
42         
43     private static String JavaDoc NODE_TYPE = NodeTypes.ENTERPRISE_APPLICATION;
44     
45     
46     public EnterpriseApplicationNode(J2EEApplicationMgmtController controller) {
47         super(getChildNodes(controller), controller, NODE_TYPE, false);//not embedded
48
setDisplayName(controller.getName());
49     }
50
51     
52     /**
53      * Returns all the children for this application.
54      *
55      * @param appName The name of the application.
56      * @param controller The controller class to get the data for embedded
57      * components from AMX.
58      * @return The Children for this application node.
59      */

60     static Children getChildNodes(J2EEApplicationMgmtController controller) {
61         return createEnterpriseApplicationChildren(controller);
62     }
63     
64    
65     
66     /**
67      * Returns all the children for this application which could be all or
68      * one of either embedded web, ejb, resource, or app client modules.
69      *
70      * @param appName The name of the application.
71      * @param controller The controller class to get the data for embedded
72      * components from AMX.
73      * @return The Children for this particular application.
74      */

75     static Children createEnterpriseApplicationChildren(
76             J2EEApplicationMgmtController controller) {
77         
78         Children children = new Children.Array();
79         java.util.Vector JavaDoc nodes = new java.util.Vector JavaDoc();
80         
81         if(controller.getJ2EEObject() != null){
82             //create all embedded ejb module nodes
83
WebModuleController [] webControllers = controller.getWebModules();
84             for(int i = 0; i < webControllers.length; i++) {
85                 nodes.add(new WebModuleNode(webControllers[i], true));
86             }
87             
88             
89             //create all embedded ejb module nodes
90
EJBModuleController [] ejbControllers = controller.getEJBModules();
91             for(int i = 0; i < ejbControllers.length; i++) {
92                 nodes.add(new EJBModuleNode(ejbControllers[i], true));
93             }
94             
95             
96             //create all embedded appclient module nodes
97
AppClientModuleController [] appClientControllers =
98                     controller.getAppClientModules();
99             for(int i = 0; i < appClientControllers.length; i++) {
100                 nodes.add(new AppClientModuleNode(appClientControllers[i], true));
101             }
102             
103             
104             //create all embedded appclient module nodes
105
ConnectorModuleController [] connectorControllers =
106                     controller.getConnectorModules();
107             for(int i = 0; i < connectorControllers.length; i++) {
108                 nodes.add(new ConnectorModuleNode(connectorControllers[i], true));
109             }
110         }else{
111             ObjectName JavaDoc[] subComponents = ControllerUtil.getSubComponentsFromConfig(controller.getName(), controller.getMBeanServerConnection());
112             for(int i=0; i<subComponents.length; i++){
113                 ObjectName JavaDoc oname = subComponents[i];
114                 String JavaDoc type = Util.getJ2EEType(oname);
115                 String JavaDoc name = Util.getName(oname);
116                 if(WebModule.J2EE_TYPE.equals(type)){
117                     nodes.add(new WebModuleNode(name));
118                 }else if(EJBModule.J2EE_TYPE.equals(type)){
119                     nodes.add(new EJBModuleNode(name));
120                 }else if (AppClientModule.J2EE_TYPE.equals(type)){
121                     nodes.add(new AppClientModuleNode(name));
122                 }else if(ResourceAdapterModule.J2EE_TYPE.equals(type)){
123                     nodes.add(new ConnectorModuleNode(name));
124                 }
125             }
126         }
127         
128         
129         Node[] arrayToAdd = new Node[nodes.size()];
130         children.add((Node[])nodes.toArray(arrayToAdd));
131         return children;
132     }
133     
134     protected List JavaDoc getPropertiesToIgnore() {
135         return Arrays.asList(NodeTypes.ENTERPRISE_APPLICATION_NODE);
136     }
137     
138 }
139
Popular Tags