1 package com.ontotext.ordi.wsmo4rdf.remote.server;
2
3 import javax.xml.ws.Endpoint;
4
5 import com.ontotext.ordi.wsmo4rdf.remote.ORDIServiceType;
6
7 import static com.ontotext.ordi.wsmo4rdf.remote.Constants.DEFAULT_SERVICE_HOST;
8 import static com.ontotext.ordi.wsmo4rdf.remote.Constants.DEFAULT_SERVICE_PORT;
9
10 public class Server implements Runnable {
11 private final String SERVICE_HOST;
12 private final int SERVICE_PORT;
13
14 public RemoteFactory factImplementor;
15 public WsmoSourceService srcImplementor;
16 public WsmoConnectionService conImplementor;
17
18 public Server(final String host, final int port) {
19 this.SERVICE_HOST = host;
20 this.SERVICE_PORT = port;
21 }
22
23 public Server() {
24 this.SERVICE_HOST = DEFAULT_SERVICE_HOST;
25 this.SERVICE_PORT = DEFAULT_SERVICE_PORT;
26 }
27
28 public void run() {
29 String servicesHostUrl = "http://" + SERVICE_HOST + ":" + SERVICE_PORT
30 + "/";
31
32 System.out.println("Starting Server");
33 this.factImplementor = new RemoteFactoryImpl();
34 String wssvcAddress = servicesHostUrl
35 + ORDIServiceType.FACTORY.getServiceName();
36
37 this.srcImplementor = new WsmoSourceServiceImpl();
38 String wsourceAddress = servicesHostUrl
39 + ORDIServiceType.SOURCE.getServiceName();
40
41 this.conImplementor = new WsmoConnectionServiceImpl();
42 String wconAddress = servicesHostUrl
43 + ORDIServiceType.CONNECTION.getServiceName();
44
45 System.out.println("-> RemoteFactory");
46 Endpoint.publish(wssvcAddress, factImplementor);
47 System.out.println("-> WsmoSourceService");
48 Endpoint.publish(wsourceAddress, srcImplementor);
49 System.out.println("-> WsmoConnectionService");
50 Endpoint.publish(wconAddress, conImplementor);
51
52 System.out.println("Server ready...");
53
54 }
55
56 public static void main(String[] args) {
57 Configuration.newInstance();
58 String host = DEFAULT_SERVICE_HOST;
59 int port = DEFAULT_SERVICE_PORT;
60 if (args != null && args.length > 0) {
61 try {
62 host = args[0];
63 port = Integer.parseInt(args[1]);
64 } catch (NumberFormatException nfe) {
65 System.err.println("usage: server <host> <port>");
66 System.exit(1);
67 }
68 new Server(host,port).run();
69 } else {
70 new Server().run();
71 }
72 }
73
74 }