1 26 package org.objectweb.openccm.explorer.DCI; 27 28 import org.ist.coach.DCI.AssemblyManager; 29 import org.ist.coach.DCI.DCIDeployment; 30 import org.ist.coach.DCI.DCIInformation; 31 import org.ist.coach.DCI.DCIManager; 32 import org.ist.coach.DCI.NodeManager; 33 import org.ist.coach.DCI.UnknownAssembly; 34 import org.objectweb.openccm.explorer.CORBA.TypageCORBA; 35 import org.objectweb.util.explorer.api.Context; 36 import org.objectweb.util.explorer.api.Entry; 37 import org.objectweb.util.explorer.core.common.api.ContextContainer; 38 import org.objectweb.util.explorer.core.naming.lib.DefaultEntry; 39 import org.omg.Components.Deployment.Assembly; 40 41 54 public class DCIManagerContext 55 implements Context 56 { 57 58 64 70 76 protected String getName(org.omg.CORBA.Object o) { 77 TypageCORBA tc = new TypageCORBA(o, org.objectweb.openccm.corba.TheORB.getORB()); 78 return tc.getTypeID(); 79 } 80 81 84 protected String getName(String assemblyUUID){ 85 String returnedValue = "Assembly "; 86 if(assemblyUUID!=null && assemblyUUID.indexOf(":")!=-1) 87 returnedValue = assemblyUUID.substring(0,assemblyUUID.indexOf(":")) + " Assembly"; 88 return returnedValue; 89 } 90 91 94 protected String getName(AssemblyManager assemblyManager){ 95 String returnedValue = "Assembly "; 96 String assemblyId = assemblyManager.ass_id(); 97 if(assemblyId.indexOf(":")!=-1) 98 returnedValue = assemblyId.substring(0,assemblyId.indexOf(":")); 99 return returnedValue; 100 } 101 102 protected boolean isStarted(AssemblyManager assemblyManager){ 103 Assembly assembly = assemblyManager.provide_assembly(); 104 return assembly.get_state().equals(org.omg.Components.Deployment.AssemblyState.INSERVICE); 105 } 106 107 113 116 public Entry[] getEntries(Object object) { 117 DCIManager DCIManager = (DCIManager) object; 118 java.util.List v = new java.util.Vector (); 119 120 DCIInformation DCIInfo = DCIManager.provide_dci_information(); 121 122 ContextContainer nodeContainer = new NodeContextContainer(); 123 NodeManager[] nodeManagerList = DCIInfo.get_node_managers(); 124 for(int i=0 ; i<nodeManagerList.length ; i++) 125 nodeContainer.addEntry(nodeManagerList[i].node_name(), nodeManagerList[i]); 126 v.add(new DefaultEntry("Nodes", nodeContainer)); 127 128 DCIDeployment DCIDeploy = DCIManager.provide_dci_deployment(); 129 130 ContextContainer installedAssembliesContainer = new InstalledAssembliesContextContainer(DCIDeploy); 132 ContextContainer runningAssembliesContainer = new RunningAssembliesContextContainer(); 133 String [] assemblyUUIDs = DCIDeploy.get_assemblies(); 134 for (int i = 0; i < assemblyUUIDs.length; i++) { 135 String assemblyName = getName(assemblyUUIDs[i]) + " (" + (i+1) + ")"; 136 installedAssembliesContainer.addEntry(assemblyName,new AssemblyUUIDWrapper(assemblyUUIDs[i],DCIDeploy)); 137 try{ 138 String [] instanceUUID = DCIDeploy.get_assembly_instances(assemblyUUIDs[i]); 139 for (int j = 0; j < instanceUUID.length; j++) { 140 AssemblyManager assemblyManager = DCIDeploy.get_assembly_manager(instanceUUID[j]); 141 AssemblyManagerWrapperWithDCIDeployment am = new AssemblyManagerWrapperWithDCIDeployment(); 142 am.setAssemblyManager(assemblyManager); 143 am.setDCIDeployment(DCIDeploy); 144 am.setUUID(instanceUUID[j]); 145 if(isStarted(assemblyManager)) 146 runningAssembliesContainer.addEntry(getName(assemblyManager) + " (" + (j+1) + ")",am); 147 } 148 } catch (UnknownAssembly e) { 149 e.printStackTrace(); 150 } 151 } 152 v.add(new DefaultEntry("Installed Assemblies", installedAssembliesContainer)); 153 v.add(new DefaultEntry("Running Assemblies", runningAssembliesContainer)); 154 155 v.add(new DefaultEntry("Homes", DCIManager.provide_home_finder())); 156 157 return (Entry[]) v.toArray(new Entry[0]); 159 } 160 161 } | Popular Tags |