Methods Summary |
---|
public int | getNumIterations()
return numIterations;
|
public ProblemSet | getProblem()
return currProblem.value;
|
public static void | main(java.lang.String[] argv)
try {
// create and initialize the ORB
System.out.println("Initializing ORB...");
ORB orb = ORB.init(argv, null);
// Create a Solver and register it with the ORB
System.out.println("Connecting solver to ORB...");
CORBASolverImpl solver = new CORBASolverImpl();
orb.connect(solver);
// Get the naming service from the ORB
System.out.println("Getting reference to Naming Service...");
org.omg.CORBA.Object ncObj =
orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(ncObj);
// Bind the Solver object to a name
System.out.println("Registering Solver with Naming Service...");
NameComponent comp = new NameComponent("Solver", "");
NameComponent path[] = {comp};
ncRef.rebind(path, solver);
// Wait for client requests
System.out.println("Waiting for clients...");
java.lang.Object dummySync = new java.lang.Object();
synchronized (dummySync) {
dummySync.wait();
}
}
catch (Exception e) {
System.err.println(e);
e.printStackTrace(System.out);
}
|
public void | setNumIterations(int i)
numIterations = i;
|
public void | setProblem(ProblemSetHolder ph)
currProblem = ph;
|
public boolean | solve(ProblemSetHolder sh, int numIters)
ProblemSet s = sh.value;
boolean success = true;
if (s == null) {
System.out.println("No problem to solve.");
return false;
}
System.out.println("Problem value = " + s.getValue());
// Solve problem here...
try {
s.setSolution(Math.sqrt(s.getValue()));
}
catch (ArithmeticException e) {
System.out.println("Badly-formed problem.");
success = false;
}
System.out.println("Problem solution = " + s.getSolution());
return success;
|
public boolean | solveCurrent()
System.out.println("Solving current problem...");
return solve(currProblem, numIterations);
|