FileDocCategorySizeDatePackage
CORBASolverClient.javaAPI DocExample1383Sun Jan 11 17:31:16 GMT 1998dcj.examples

CORBASolverClient

public class CORBASolverClient extends Object
Source code from "Java Distributed Computing", by Jim Farley. Class: CORBASolverClient Example: 3-9 Description: A client that uses our CORBA-based Solver interface to interact with a remote Solver object.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

    try {
      // Create an ORB
      ORB orb = ORB.init(argv, null);

      // Get a reference to the Naming Service
      org.omg.CORBA.Object obj =
        orb.resolve_initial_references("NameService");
      NamingContext nc = NamingContextHelper.narrow(obj);

      // Get a reference to the Solver on the remote host
      NameComponent comp = new NameComponent("Solver", "");
      NameComponent path[] = {comp};
      org.omg.CORBA.Object sobj = nc.resolve(path);
      Solver solver = SolverHelper.narrow(sobj);

      // Make a problem and ask the solver to solve it
      ProblemSet s = new ProblemSetImpl();
      s.setValue(173.39);
      solver.solve(new ProblemSetHolder(s), 1);

      // Print out solution
      System.out.println("Problem = " + s.getValue());
      System.out.println("Solution = " + s.getSolution());
    }
    catch (Exception e) {
      System.out.println(e) ;
      e.printStackTrace(System.out);
    }