SCANodeFactory factory = SCANodeFactory.newInstance();
SCANode node = factory.createSCANode(new File("src/main/resources/implementation/policies/Calculator.composite").toURL().toString(),
new SCAContribution("TestContribution", new File("src/main/resources/implementation/policies/").toURL().toString()));
node.start();
CalculatorService calculatorService =
((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent");
// Calculate
System.out.println("Calling CalculatorServiceComponent configured with 'logging' " +
"policy for subtract and divide operations...");
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));
calculatorService =
((SCAClient)node).getService(CalculatorService.class, "AnotherCalculatorServiceComponent");
// Calculate
System.out.println("Calling CalculatorServiceComponent configured with 'logging' " +
"for all operations in the implementation...");
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();
System.out.println("Bye");
}