System.setProperty("java.security.auth.login.config", CalculatorClient.class.getClassLoader()
.getResource("implementation/policies/CalculatorJass.config").toString());
}
NodeFactory factory = NodeFactory.newInstance();
Node node = factory.createNode(new File("src/main/resources/implementation/policies/ImplementationPolicies.composite").toURI().toURL().toString(),
new Contribution("TestContribution", new File("src/main/resources/implementation/policies/").toURI().toURL().toString()));
node.start();
CalculatorService calculatorService =
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 =
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");
}