1 26 27 package org.objectweb.openccm.Deployment; 28 29 import org.omg.CosNaming.NameComponent ; 30 31 32 public class DCIManagerServer extends org.objectweb.openccm.corba.ApplicationServer 33 { 34 35 41 private String dciName; 42 43 private String dciIORFilePath; 44 45 private NameComponent [] ncomp; 46 47 private NameComponent [] ncompHF; 48 49 private NameComponent [] ncompHR; 50 51 52 private org.objectweb.openccm.OpenCCM_DCI.DCIManager DCI ; 53 59 62 public 63 DCIManagerServer() 64 { 65 org.objectweb.ccm.descriptor.EntityResolver.setCCMResolver(); 67 } 68 69 75 private void 76 computeArgs(String args[]) 77 { 78 for(int i=0;i<args.length;i++){ 79 if(args[i].startsWith("DCINAME=")) 80 this.dciName=args[i].substring(8); 81 else if(args[i].startsWith("IORPATH=")) 82 this.dciIORFilePath=args[i].substring(8); 83 } 84 } 85 86 92 97 public static void 98 main(String args[]) 99 { 100 DCIManagerServer server = new DCIManagerServer(); 101 103 int status = server.start(args); 104 System.exit(status); 105 } 106 107 113 120 public int 121 before_run(String [] args) 122 { 123 computeArgs(args); 125 126 try{ 127 org.objectweb.openccm.Components.Runtime.init(org.objectweb.openccm.corba.TheORB.getORB()); 129 130 131 org.objectweb.openccm.OpenCCM_DCI.DCIManagerHome DCIHome= 133 org.objectweb.openccm.OpenCCM_DCI.DCIManagerHomeHelper. 134 narrow((new DeploymentComponentFactory()). 135 install_home("org.objectweb.openccm.OpenCCM_DCI.cif.DCIManagerHomeImpl.create_home")); 136 137 DCI= DCIHome.create(); 139 DCI.dci_name(dciName); 141 142 org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerModelHome AMMH= 144 org.objectweb.openccm.OpenCCM_DCI. 145 AssemblyManagerModelHomeHelper. 146 narrow((new DeploymentComponentFactory()). 147 install_home("org.objectweb.openccm.OpenCCM_DCI.cif.AssemblyManagerModelHomeImpl.create_home")); 148 DCI.connect_assembly_manager_model_home(AMMH); 150 151 org.omg.CosNaming.NamingContextExt nce= 152 org.omg.CosNaming 153 .NamingContextExtHelper 154 .narrow(org.objectweb.openccm.corba.TheNameService 155 .getNamingContext().getNamingContext()); 156 DCI.connect_naming_service(nce); 157 158 DCI.configuration_complete(); 159 160 161 162 164 String registrationName= 165 System.getProperty("DCI_ns_dir") 166 +dciName; 167 168 ncomp=org.objectweb.ccm 169 .descriptor.componentassembly.ccm 170 .deployer.registrar.RegisterwithnamingDeployer 171 .rebind(nce,registrationName,DCI); 172 ncompHF=org.objectweb.ccm 175 .descriptor.componentassembly.ccm 176 .deployer.registrar.RegisterwithnamingDeployer 177 .rebind(nce,"OpenCCM/Services/HomeFinder",DCI.provide_home_finder()); 178 ncompHR=org.objectweb.ccm 179 .descriptor.componentassembly.ccm 180 .deployer.registrar.RegisterwithnamingDeployer 181 .rebind(nce,"OpenCCM/Services/HomeRegistration",DCI.provide_home_registration()); 182 183 org.objectweb.openccm.corba.TheORB.save_IOR(DCI,dciIORFilePath); 185 186 return 0; 187 } 188 catch(Exception e){ 189 e.printStackTrace(); 190 System.out.println(e.getMessage()); 191 } 192 return 0; 193 194 } 195 196 199 public void 200 after_run() 201 { 202 try{ 203 if(ncomp!=null){ 204 org.omg.CosNaming.NamingContextExt nce= 205 org.omg.CosNaming 206 .NamingContextExtHelper 207 .narrow(org.objectweb.openccm.corba.TheNameService 208 .getNamingContext().getNamingContext()); 209 210 nce.unbind(ncomp); 211 nce.unbind(ncompHR); 212 nce.unbind(ncompHF); 213 System.err.println("The "+dciName+" DCI is unreferenced"); 214 } 215 } 216 catch(Exception e) 217 { 218 System.err.println("Cannot unbind The "+dciName+" DCI"); 219 } 220 221 222 } 223 224 } 225 | Popular Tags |