1 26 27 package org.objectweb.openccm.Deployment; 28 29 import org.omg.CosNaming.NameComponent ; 30 31 32 public class AssemblyFactoryManagerServer 33 extends org.objectweb.openccm.corba.ApplicationServer 34 { 35 36 42 private String factoryName; 43 44 private String factoryIORFilePath; 45 46 private NameComponent []ncomp ; 47 48 private org.objectweb.openccm.OpenCCM_DCI.DCIManager DCI ; 49 50 51 52 53 59 private void 60 computeArgs(String args[]) 61 { 62 for(int i=0;i<args.length;i++){ 63 if(args[i].startsWith("FACTORYNAME=")) 64 this.factoryName=args[i].substring(12); 65 } 66 factoryIORFilePath=System.getProperty("WorkDir")+"/"+factoryName+".IOR"; 67 } 68 69 75 78 public 79 AssemblyFactoryManagerServer() 80 { 81 org.objectweb.ccm.descriptor.EntityResolver.setCCMResolver(); 83 } 84 85 91 96 public static void 97 main(String args[]) 98 { 99 AssemblyFactoryManagerServer server = new AssemblyFactoryManagerServer(); 100 102 int status = server.start(args); 103 System.exit(status); 104 } 105 106 112 119 public int 120 before_run(String [] args) 121 { 122 123 try{ 124 125 computeArgs(args); 126 127 org.objectweb.openccm.Components.Runtime.init(org.objectweb.openccm.corba.TheORB.getORB()); 129 DCI= 131 org.objectweb.openccm. 132 OpenCCM_DCI.DCIManagerHelper. 133 narrow(org.objectweb.openccm.corba 134 .TheORB.resolve_initial_reference("DCIManager")); 135 136 org.objectweb.openccm.OpenCCM_DCI.AssemblyFactoryManagerHome AFMH= 138 org.objectweb.openccm.OpenCCM_DCI.AssemblyFactoryManagerHomeHelper. 139 narrow((new DeploymentComponentFactory()). 140 install_home 141 ("org.objectweb.openccm.OpenCCM_DCI.cif.AssemblyFactoryManagerHomeImpl.create_home")); 142 143 org.objectweb.openccm.OpenCCM_DCI.AssemblyFactoryManager AFM= 145 AFMH.create(); 146 org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerHome AMH= 148 org.objectweb.openccm.OpenCCM_DCI. 149 AssemblyManagerHomeHelper.narrow 150 ((new DeploymentComponentFactory()) 151 .install_home("org.objectweb.openccm.OpenCCM_DCI.cif.AssemblyManagerHomeImpl.create_home")); 152 153 AFM.connect_assembly_manager_home(AMH); 155 DCI.connect_assembly_factory(AFM.provide_assembly_factory()); 157 AFM.connect_home_registration(DCI.provide_home_registration()); 159 AFM.connect_home_finder(DCI.provide_home_finder()); 161 AFM.connect_dci_information(DCI.provide_dci_information()); 163 AFM.configuration_complete(); 165 166 167 org.omg.CosNaming.NamingContextExt nce= 170 org.omg.CosNaming 171 .NamingContextExtHelper 172 .narrow(org.objectweb.openccm.corba.TheNameService 173 .getNamingContext().getNamingContext()); 174 175 String registrationName= 176 System.getProperty("Assembly_factory_ns_dir") 177 +factoryName; 178 179 ncomp=org.objectweb.ccm 180 .descriptor.componentassembly.ccm 181 .deployer.registrar.RegisterwithnamingDeployer 182 .rebind(nce,registrationName,AFM); 183 188 190 org.objectweb.openccm.corba.TheORB.save_IOR(AFM, factoryIORFilePath); 192 193 194 return 0; 195 } 196 catch(Exception e){ 197 e.printStackTrace(); 198 System.out.println(e.getMessage()); 199 200 } 201 return 0; 202 203 } 204 205 208 public void 209 after_run() 210 { 211 try{ 212 if(DCI!=null) 213 DCI.disconnect_assembly_factory(); 214 215 if(ncomp!=null){ 216 org.omg.CosNaming.NamingContextExt nce= 217 org.omg.CosNaming 218 .NamingContextExtHelper 219 .narrow(org.objectweb.openccm.corba.TheNameService 220 .getNamingContext().getNamingContext()); 221 222 nce.unbind(ncomp); 223 224 System.err.println("The "+factoryName+" AssemblyFactory is unreferenced"); 225 } 226 } 227 catch(Exception e) 228 { 229 System.err.println("Cannot unbind The "+factoryName+"AssemblyFactory"); 230 } 231 } 232 233 } 234 | Popular Tags |