KickJava   Java API By Example, From Geeks To Geeks.

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


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
21 import java.util.List JavaDoc;
22 import java.util.Arrays JavaDoc;
23 import javax.management.ObjectName JavaDoc;
24 import org.netbeans.modules.j2ee.sun.ide.controllers.ControllerUtil;
25 import org.netbeans.modules.j2ee.sun.util.NodeTypes;
26 import com.sun.appserv.management.base.Util;
27 import com.sun.appserv.management.j2ee.EntityBean;
28 import com.sun.appserv.management.j2ee.MessageDrivenBean;
29 import com.sun.appserv.management.j2ee.StatefulSessionBean;
30 import com.sun.appserv.management.j2ee.StatelessSessionBean;
31 import org.netbeans.modules.j2ee.sun.ide.controllers.EJBModuleController;
32 import org.openide.nodes.Children;
33 import org.openide.nodes.Node;
34
35
36
37
38 /**
39  */

40 public class EJBModuleNode extends AppserverMgmtApplicationsNode {
41         
42     private static String JavaDoc NODE_TYPE = NodeTypes.EJB_MODULE;
43       
44     /**
45      *
46      */

47     public EJBModuleNode(final EJBModuleController controller,
48             final boolean isEmbedded) {
49         super(getChildNodes(controller), controller, NODE_TYPE, isEmbedded);
50         setDisplayName(controller.getName());
51     }
52     
53     
54     /**
55      *
56      */

57     public EJBModuleNode(final EJBModuleController controller) {
58         super(getChildNodes(controller), controller, NODE_TYPE, false);
59         setDisplayName(controller.getName());
60     }
61     
62     public EJBModuleNode(final String JavaDoc name) {
63         super(Children.LEAF, null, NODE_TYPE, true);
64         setDisplayName(name);
65     }
66     
67     /**
68      *
69      */

70     static Children getChildNodes(EJBModuleController controller) {
71         return createEJBModuleNodeChildren(controller);
72     }
73     
74     
75     /**
76      *
77      */

78     static Children createEJBModuleNodeChildren(EJBModuleController controller) {
79         
80         Children children = new Children.Array();
81         java.util.Vector JavaDoc nodes = new java.util.Vector JavaDoc();
82
83         if(controller.getJ2EEObject() != null){
84             //create all embedded stateless ejbs
85
String JavaDoc [] statelessNames = controller.getStatelessSessionBeans();
86             if(statelessNames != null && statelessNames.length > 0) {
87                 for(int i = 0; i < statelessNames.length; i++) {
88                     nodes.add(new StatelessEjbNode(
89                             controller, statelessNames[i]));
90                 }
91             }
92             
93             //create all embedded stateful ejbs
94
String JavaDoc [] statefulNames = controller.getStatefulSessionBeans();
95             if(statefulNames != null && statefulNames.length > 0) {
96                 for(int i = 0; i < statefulNames.length; i++) {
97                     nodes.add(new StatefulEjbNode(
98                             controller, statefulNames[i]));
99                 }
100             }
101             
102             //create all embedded message driven ejbs
103
String JavaDoc [] messageDrivenNames = controller.getMessageDrivenBeans();
104             if(messageDrivenNames != null && messageDrivenNames.length > 0) {
105                 for(int i = 0; i < messageDrivenNames.length; i++) {
106                     nodes.add(new MessageDrivenEjbNode(
107                             controller, messageDrivenNames[i]));
108                 }
109             }
110             
111             //create all embedded entity ejbs
112
String JavaDoc [] entityBeans = controller.getEntityBeans();
113             if(entityBeans != null && entityBeans.length > 0) {
114                 for(int i = 0; i < entityBeans.length; i++) {
115                     nodes.add(new EntityEjbNode(
116                             controller, entityBeans[i]));
117                 }
118             }
119         }else{
120             ObjectName JavaDoc[] subComponents = ControllerUtil.getSubComponentsFromConfig(controller.getName(), controller.getMBeanServerConnection());
121             for(int i=0; i<subComponents.length; i++){
122                 ObjectName JavaDoc oname = subComponents[i];
123                 String JavaDoc type = Util.getJ2EEType(oname);
124                 String JavaDoc name = Util.getName(oname);
125                 if(EntityBean.J2EE_TYPE.equals(type)){
126                     nodes.add(new EntityEjbNode(name));
127                 }else if(MessageDrivenBean.J2EE_TYPE.equals(type)){
128                     nodes.add(new MessageDrivenEjbNode(name));
129                 }else if (StatefulSessionBean.J2EE_TYPE.equals(type)){
130                     nodes.add(new StatefulEjbNode(name));
131                 }else if(StatelessSessionBean.J2EE_TYPE.equals(type)){
132                     nodes.add(new StatelessEjbNode(name));
133                 }
134             };
135         }
136         
137         Node[] arrayToAdd = new Node[nodes.size()];
138         children.add((Node[])nodes.toArray(arrayToAdd));
139         return children;
140     }
141     
142     protected List JavaDoc getPropertiesToIgnore() {
143         return Arrays.asList(NodeTypes.EJB_MODULE_NODE);
144     }
145 }
146
Popular Tags