import calculator.CalculatorService;
public class LaunchCalculatorNodeA {
public static void main(String[] args) throws Exception {
SCANode2 node = null;
try {
NodeLauncher nodeLauncher = NodeLauncher.newInstance();
node = nodeLauncher.createNode("http://localhost:9990/node-config/NodeA");
node.start();
// get a reference to the calculator component
SCAClient client = (SCAClient)node;
CalculatorService calculatorService =
client.getService(CalculatorService.class, "CalculatorServiceComponentA");
// Calculate
System.out.println("3 + 2=" + calculatorService.add(3, 2));
System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
System.out.println("3 / 2=" + calculatorService.divide(3, 2));
if (args.length > 1){
for (int i=0; i < 1000; i++){
// Calculate
System.out.println("3 + 2=" + calculatorService.add(3, 2));
System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
System.out.println("3 / 2=" + calculatorService.divide(3, 2));
}
}
node.stop();
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
}