import DeployerApp.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
public class Deployer
{
private class LocalDeployerL
{
public String name = "";
public int NumProcesses = 0;
public LocalDeployer_Interface I;
}
private LocalDeployerL locals[] = new LocalDeployerL[20];
private class ListenForLocals implements Runnable
{
public void run()
{
locals[0] = new LocalDeployerL();
//listen for local deployers
}
}
public static void main(String args[])
{
try{
locals[0] = new LocalDeployerL();
// create and initialize the ORB
ORB orb = ORB.init(args, null);
//look for local deployers to connect to
//(new Thread(new ListenForLocals())).start();
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
// Use NamingContextExt instead of NamingContext. This is
// part of the Interoperable naming Service.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// resolve the Object Reference in Naming
String name = "LocalDeployer";
locals[0].I = LocalDeployer_InterfaceHelper.narrow(ncRef.resolve_str(name));
System.out.println("Obtained a handle on server object: " + locals[0].I);
System.out.println(locals[0].I.Run("notepad"));
System.out.println(locals[0].I.Run("C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"));
System.out.println(locals[0].I.Kill("notepad"));
System.out.println(locals[0].I.Kill("C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"));
locals[0].I.shutdown();
} catch (Exception e) {
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}