1 26 27 package org.objectweb.openccm.Deployment; 28 29 public class ComponentServerMain extends org.objectweb.openccm.corba.ApplicationServer 30 { 31 32 38 41 protected String name_ ="ComponentServer"; 42 43 49 52 public 53 ComponentServerMain() 54 { 55 } 56 57 58 64 69 public static void 70 main(String args[]) 71 { 72 ComponentServerMain server = new ComponentServerMain(); 73 int status = server.start(args); 74 System.exit(status); 75 } 76 77 83 90 public int 91 before_run(String [] args) 92 { 93 try{ 95 org.objectweb.openccm.Components.Runtime.init(); 96 } 98 catch(Exception e){ System.out.println(e.getMessage());} 99 100 try{ 101 org.omg.CosNaming.NameComponent [] ncomp 103 = new org.omg.CosNaming.NameComponent [1]; 104 105 ncomp[0]= new org.omg.CosNaming.NameComponent ("ComponentInstallation"+args[1],""); 106 107 org.omg.CORBA.Object obj = org.objectweb.openccm.corba.TheNameService 108 .getNamingContext() 109 .getNamingContext() 110 .resolve(ncomp); 111 112 org.omg.Components.Deployment.ComponentInstallation server_inst= 113 org.omg.Components.Deployment.ComponentInstallationHelper.narrow(obj); 114 115 TheComponentInstallation.setComponentInstallation(server_inst); 116 117 } 118 catch(Exception e) 119 { 120 System.out.println("Cannot retrieves the componentInstallation "+ 121 "ComponentInstallation"+args[1]+e.getMessage()); 122 123 e.printStackTrace(); 124 } 125 127 org.objectweb.openccm.Components.ConfigValueImpl[] config= 128 new org.objectweb.openccm.Components.ConfigValueImpl[1]; 129 org.omg.CORBA.Any any= org.objectweb.openccm.corba.TheORB.getORB().create_any(); 130 131 any.insert_string(args[0]+args[1]); 133 config[0]= new org.objectweb.openccm.Components.ConfigValueImpl("ServerName",any); 134 135 ComponentServerImpl csi = new ComponentServerImpl(config); 136 137 org.omg.CORBA.Object ref = 139 csi._this_object(org.objectweb.openccm.corba.TheORB.getORB()); 140 141 org.omg.Components.Deployment.ComponentServer serverRef = 142 org.omg.Components.Deployment.ComponentServerHelper.narrow(ref); 143 144 147 org.objectweb.openccm.corba.NamingContext ns = 149 org.objectweb.openccm.corba.TheNameService.getNamingContext(); 150 151 ns.rebind(args[0]+args[1], serverRef); 153 154 155 158 159 System.out.println("The OpenCCM Component Server "+args[0]+" is ready."); 160 System.out.println(org.objectweb.openccm.corba.TheORB.getORB().object_to_string(ref)); 161 return 0; 162 } 163 164 167 public void 168 after_run() 169 { 170 org.objectweb.openccm.corba.NamingContext ns = 172 org.objectweb.openccm.corba.TheNameService.getNamingContext(); 173 174 ns.unbind(name_); 176 } 177 178 } 179 | Popular Tags |