1 19 package org.netbeans.modules.j2ee.sun.util; 20 21 import java.util.Iterator ; 22 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtContainerNode; 23 24 25 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtController; 26 import org.netbeans.modules.j2ee.sun.bridge.apis.NodeExtension; 27 import org.netbeans.modules.j2ee.sun.ide.controllers.ControllerUtil; 28 import org.netbeans.modules.j2ee.sun.ide.controllers.J2EEApplicationMgmtController; 29 import org.netbeans.modules.j2ee.sun.ide.controllers.EJBModuleController; 30 import org.netbeans.modules.j2ee.sun.ide.controllers.ConnectorModuleController; 31 import org.netbeans.modules.j2ee.sun.ide.controllers.WebModuleController; 32 import org.netbeans.modules.j2ee.sun.ide.controllers.AppClientModuleController; 33 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.AdminObjectResourceNode; 34 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.AppClientModuleNode; 35 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.ConnectionFactoryNode; 36 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.ConnectionPoolNode; 37 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.ConnectorConnectionPoolNode; 38 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.ConnectorModuleNode; 39 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.ConnectorResourceNode; 40 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.CustomResourceNode; 41 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.DestinationResourceNode; 42 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.EJBModuleNode; 43 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.EnterpriseApplicationNode; 44 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.ExternalResourceNode; 45 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.JDBCResourceNode; 46 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.JVMNode; 47 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.JavaMailResourceNode; 48 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.PersistenceManagerResourceNode; 49 import org.netbeans.modules.j2ee.sun.ide.runtime.nodes.WebModuleNode; 50 import org.openide.nodes.AbstractNode; 51 import org.openide.nodes.Children; 52 import org.openide.nodes.Node; 54 import org.openide.util.NbBundle; 55 56 60 public class ContainerChildFactory { 61 62 private AppserverMgmtController controller; 63 64 72 public ContainerChildFactory(AppserverMgmtController controller) { 73 this.controller = controller; 74 } 75 76 public static final class WaitNode extends AbstractNode { 77 public WaitNode() { 78 super(Children.LEAF); 79 setIconBase("org/netbeans/modules/java/navigation/resources/wait"); setDisplayName(NbBundle.getMessage(ContainerChildFactory.class, "MSG_BadCredentials")); setName(getClass().getName()); 82 } 83 } 84 90 91 public Object [] getChildrenObject(String type) { 92 if ((controller==null)||(controller.getAppserverConnectionSource()==null)){ 93 return new Node[] {new WaitNode()}; 94 } 95 96 Object [] children = new Object [] {}; 97 if(NodeTypes.DOMAIN.equals(type)) { 98 children = createDomainRootChildren(); 99 } else if(NodeTypes.JDBC_RESOURCES.equals(type)) { 100 children = createJDBCResourcesChildren(); 101 } else if(NodeTypes.CONNECTION_POOLS.equals(type)) { 102 children = createConnectionPoolChildren(); 103 } else if(NodeTypes.CONNECTION_FACTORIES.equals(type)) { 104 children = createJMSConnectionFactoriesChildren(); 105 } else if(NodeTypes.DESTINATION_RESOURCES.equals(type)) { 106 children = createJMSDestinationResourcesChildren(); 107 } else if(NodeTypes.PERSISTENCE_MANAGER_RESOURCES.equals(type)) { 108 children = createPersistenceManagerResourcesChildren(); 109 } else if(NodeTypes.CONNECTOR_RESOURCES.equals(type)) { 110 children = createConnectorResourcesChildren(); 111 } else if(NodeTypes.CONNECTOR_CONNECTION_POOLS.equals(type)) { 112 children = createConnectorConnectionPoolChildren(); 113 } else if(NodeTypes.ADMIN_OBJECT_RESOURCES.equals(type)) { 114 children = createAdminObjectResourcesChildren(); 115 } else if(NodeTypes.MAIL_RESOURCES.equals(type)) { 116 children = createJavaMailResourcesChildren(); 117 } else if(NodeTypes.WEB_APPLICATIONS.equals(type)) { 118 children = createWebApplicationsChildren(); 119 } else if(NodeTypes.ENTERPRISE_APPLICATIONS.equals(type)) { 120 children = createEnterpriseApplicationsChildren(); 121 } else if(NodeTypes.EJB_MODULES.equals(type)) { 122 children = createEJBModulesChildren(); 123 } else if(NodeTypes.CONNECTOR_MODULES.equals(type)) { 124 children = createConnectorModulesChildren(); 125 } else if(NodeTypes.APP_CLIENT_MODULES.equals(type)) { 126 children = createAppClientModulesChildren(); 127 } else if(NodeTypes.CUSTOM_RESOURCES.equals(type)) { 128 children = createCustomResourcesChildren(); 129 } else if(NodeTypes.EXTERNAL_RESOURCES.equals(type)) { 130 children = createExternalResourcesChildren(); 131 } else { 132 children = createContainerChildren(type); 133 } 134 135 return children; 136 } 137 140 Node[] createContainerChildren(String nodeType) { 141 String [] childTypes = NodeTypes.getChildTypes(nodeType); 142 if(childTypes != null) { 143 Node[] nodes = new Node[childTypes.length]; 144 for(int i = 0; i < childTypes.length; i++) { 145 nodes[i] = 146 new AppserverMgmtContainerNode(controller, childTypes[i]); 147 } 148 return nodes; 149 } else { 150 return new Node[] {}; 151 } 152 } 153 154 157 Node[] createDomainRootChildren() { 158 Node ext = getExtensionNode(); 159 Node resourceHolder = getResourcesNode(); 160 if (ext==null) 161 return new Node[] { 162 new AppserverMgmtContainerNode(controller, NodeTypes.APPLICATIONS), 163 resourceHolder, 164 new JVMNode(controller) 165 }; 166 else 167 return new Node[] { 168 new AppserverMgmtContainerNode(controller, NodeTypes.APPLICATIONS), 169 resourceHolder, 170 171 new JVMNode(controller), ext 172 }; 174 } 175 176 Node getExtensionNode() { 177 Iterator ps = javax.imageio.spi.ServiceRegistry.lookupProviders(NodeExtension.class , this.getClass().getClassLoader()); 178 while (ps.hasNext()) { 179 NodeExtension cc = (NodeExtension)ps.next(); 180 if (cc==null){ 181 return null; 182 } 183 Node ce = cc.getAppserverExtensionNode(controller); 184 if (ce != null){ 185 return ce; 186 } 187 } 188 return null; 189 } 190 191 Node getResourcesNode(){ 192 Node resourceHolder = new AppserverMgmtContainerNode(controller, NodeTypes.RESOURCES90); 193 if(! ControllerUtil.isGlassFish(this.controller.getDeploymentManager())) 194 resourceHolder = new AppserverMgmtContainerNode(controller, NodeTypes.RESOURCES); 195 196 return resourceHolder; 197 } 198 201 Node[] createJDBCResourcesChildren() { 202 String [] names = controller.getJDBCResources(); 203 Node[] nodes = new Node[names.length]; 204 for(int i = 0; i < names.length; i++) { 205 nodes[i] = new JDBCResourceNode(controller, names[i]); 206 207 } 208 return (names.length > 0) ? nodes : new Node[] {}; 209 } 210 211 212 215 Node[] createConnectionPoolChildren() { 216 String [] names = controller.getJDBCConnectionPools(); 217 Node[] nodes = new Node[names.length]; 218 for(int i = 0; i < names.length; i++) { 219 nodes[i] = new ConnectionPoolNode(controller, names[i]); 220 } 221 return (names.length > 0) ? nodes : new Node[] {}; 222 } 223 224 225 228 Node[] createJMSConnectionFactoriesChildren() { 229 String [] names = controller.getJMSConnectionFactories(); 230 if(names != null) { 231 Node[] nodes = new Node[names.length]; 232 for(int i = 0; i < names.length; i++) { 233 nodes[i] = new ConnectionFactoryNode(controller, names[i]); 234 } 235 return (names.length > 0) ? nodes : new Node[] {}; 236 } 237 return new Node[] {}; 238 } 239 240 241 244 Node[] createJMSDestinationResourcesChildren() { 245 String [] names = controller.getDestinationResources(); 246 if(names != null) { 247 Node[] nodes = new Node[names.length]; 248 for(int i = 0; i < names.length; i++) { 249 nodes[i] = new DestinationResourceNode(controller, names[i]); 250 } 251 return (names.length > 0) ? nodes : new Node[] {}; 252 } 253 return new Node[] {}; 254 } 255 256 259 Node[] createConnectorResourcesChildren() { 260 String [] names = controller.getConnectorResources(); 261 Node[] nodes = new Node[names.length]; 262 for(int i = 0; i < names.length; i++) { 263 nodes[i] = new ConnectorResourceNode(controller, names[i]); 264 } 265 return (names.length > 0) ? nodes : new Node[] {}; 266 } 267 268 271 Node[] createConnectorConnectionPoolChildren() { 272 String [] names = controller.getConnectorConnectionPools(); 273 Node[] nodes = new Node[names.length]; 274 for(int i = 0; i < names.length; i++) { 275 nodes[i] = new ConnectorConnectionPoolNode(controller, names[i]); 276 } 277 return (names.length > 0) ? nodes : new Node[] {}; 278 } 279 280 283 Node[] createAdminObjectResourcesChildren() { 284 String [] names = controller.getAdminObjectResources(); 285 if(names != null) { 286 Node[] nodes = new Node[names.length]; 287 for(int i = 0; i < names.length; i++) { 288 nodes[i] = new AdminObjectResourceNode(controller, names[i]); 289 } 290 return (names.length > 0) ? nodes : new Node[] {}; 291 } 292 return new Node[] {}; 293 } 294 295 298 Node[] createJavaMailResourcesChildren() { 299 String [] names = controller.getJavaMailResources(); 300 Node[] nodes = new Node[names.length]; 301 for(int i = 0; i < names.length; i++) { 302 nodes[i] = new JavaMailResourceNode(controller, names[i]); 303 } 304 return (names.length > 0) ? nodes : new Node[] {}; 305 } 306 307 310 Node[] createPersistenceManagerResourcesChildren() { 311 String [] names = controller.getPersistenceManagerFactoryResources(); 312 Node[] nodes = new Node[names.length]; 313 for(int i = 0; i < names.length; i++) { 314 nodes[i] = new PersistenceManagerResourceNode(controller, names[i]); 315 } 316 return (names.length > 0) ? nodes : new Node[] {}; 317 } 318 319 322 Node[] createCustomResourcesChildren() { 323 String [] names = controller.getCustomResources(); 324 Node[] nodes = new Node[names.length]; 325 for(int i = 0; i < names.length; i++) { 326 nodes[i] = new CustomResourceNode(controller, names[i]); 327 } 328 return (nodes.length > 0) ? nodes : new Node[] {}; 329 } 330 331 334 Node[] createExternalResourcesChildren() { 335 String [] names = controller.getExternalResources(); 336 Node[] nodes = new Node[names.length]; 337 for(int i = 0; i < names.length; i++) { 338 nodes[i] = new ExternalResourceNode(controller, names[i]); 339 } 340 return (nodes.length > 0) ? nodes : new Node[] {}; 341 } 342 343 344 347 Node[] createWebApplicationsChildren() { 348 WebModuleController [] controllers = 349 controller.getJ2EEServerMgmtController().getWebModules(); 350 Node[] nodes = new Node[controllers.length]; 351 for(int i = 0; i < controllers.length; i++) { 352 nodes[i] = new WebModuleNode(controllers[i]); 353 } 354 return (controllers.length > 0) ? nodes : new Node[] {}; 355 } 356 357 358 361 Node[] createEnterpriseApplicationsChildren() { 362 J2EEApplicationMgmtController [] controllers = 363 controller.getJ2EEServerMgmtController().getApplications(); 364 Node[] nodes = new Node[controllers.length]; 365 for(int i = 0; i < controllers.length; i++) { 366 nodes[i] = new EnterpriseApplicationNode(controllers[i]); 367 } 368 return (controllers.length > 0) ? nodes : new Node[] {}; 369 } 370 371 372 377 Node[] createEJBModulesChildren() { 378 EJBModuleController [] controllers = 379 controller.getJ2EEServerMgmtController().getEJBModules(); 380 Node[] nodes = new Node[controllers.length]; 381 for(int i = 0; i < controllers.length; i++) { 382 nodes[i] = new EJBModuleNode(controllers[i]); 383 } 384 return (controllers.length > 0) ? nodes : new Node[] {}; 385 } 386 387 388 393 Node[] createConnectorModulesChildren() { 394 ConnectorModuleController [] controllers = 395 controller.getJ2EEServerMgmtController().getConnectorModules(); 396 Node[] nodes = new Node[controllers.length]; 397 for(int i = 0; i < controllers.length; i++) { 398 nodes[i] = new ConnectorModuleNode(controllers[i]); 399 } 400 return (controllers.length > 0) ? nodes : new Node[] {}; 401 } 402 403 404 409 Node[] createAppClientModulesChildren() { 410 AppClientModuleController [] controllers = 411 controller.getJ2EEServerMgmtController().getAppClientModules(); 412 Node[] nodes = new Node[controllers.length]; 413 for(int i = 0; i < controllers.length; i++) { 414 nodes[i] = new AppClientModuleNode(controllers[i]); 415 } 416 return (controllers.length > 0) ? nodes : new Node[] {}; 417 } 418 419 420 } 421 | Popular Tags |