01: package net.sf.crispy.extension.hivemind;
02:
03: import net.sf.crispy.impl.xmlrpc.MiniXmlRpcServer;
04: import net.sf.crispy.util.Util;
05:
06: import org.apache.hivemind.Registry;
07: import org.apache.hivemind.impl.RegistryBuilder;
08:
09: import test.crispy.example.service.Calculator;
10: import test.crispy.example.service.CalculatorImpl;
11: import test.crispy.example.service.Echo;
12: import test.crispy.example.service.EchoImpl;
13:
14: public class Run {
15:
16: public static void main(String[] args) {
17: Util.initJdkLogger();
18:
19: MiniXmlRpcServer server = new MiniXmlRpcServer();
20: // MiniRmiServer server = new MiniRmiServer();
21: try {
22: server.addService(Echo.class.getName(), EchoImpl.class
23: .getName());
24: server.addService(Calculator.class.getName(),
25: CalculatorImpl.class.getName());
26: server.start();
27:
28: Registry registry = RegistryBuilder
29: .constructDefaultRegistry();
30: Calculator calculator = (Calculator) registry
31: .getService(Calculator.class);
32: System.out.println("2 + 3 = " + calculator.add(2, 3));
33:
34: Echo echo = (Echo) registry.getService(Echo.class);
35: System.out.println("Echo: " + echo.echo("Hello Crispy!"));
36:
37: } catch (Exception e) {
38: e.printStackTrace();
39: } finally {
40: server.stop();
41: }
42: }
43:
44: }
|