1 19 package org.netbeans.modules.j2ee.sun.ide.runtime.nodes; 20 21 import java.util.List ; 22 import java.util.Arrays ; 23 import javax.management.ObjectName ; 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 40 public class EJBModuleNode extends AppserverMgmtApplicationsNode { 41 42 private static String NODE_TYPE = NodeTypes.EJB_MODULE; 43 44 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 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 name) { 63 super(Children.LEAF, null, NODE_TYPE, true); 64 setDisplayName(name); 65 } 66 67 70 static Children getChildNodes(EJBModuleController controller) { 71 return createEJBModuleNodeChildren(controller); 72 } 73 74 75 78 static Children createEJBModuleNodeChildren(EJBModuleController controller) { 79 80 Children children = new Children.Array(); 81 java.util.Vector nodes = new java.util.Vector (); 82 83 if(controller.getJ2EEObject() != null){ 84 String [] 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 String [] 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 String [] 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 String [] 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 [] subComponents = ControllerUtil.getSubComponentsFromConfig(controller.getName(), controller.getMBeanServerConnection()); 121 for(int i=0; i<subComponents.length; i++){ 122 ObjectName oname = subComponents[i]; 123 String type = Util.getJ2EEType(oname); 124 String 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 getPropertiesToIgnore() { 143 return Arrays.asList(NodeTypes.EJB_MODULE_NODE); 144 } 145 } 146 | Popular Tags |