-
Notifications
You must be signed in to change notification settings - Fork 7
/
ProfilesRestServer.java
43 lines (28 loc) · 1.21 KB
/
ProfilesRestServer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package microgram.impl.srv.rest;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.jersey.jdkhttp.JdkHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;
import discovery.Discovery;
import utils.IP;
public class ProfilesRestServer {
private static Logger Log = Logger.getLogger(ProfilesRestServer.class.getName());
static {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s");
}
public static final int PORT = 7777;
public static final String SERVICE = "Microgram-Profiles";
public static String SERVER_BASE_URI = "http://%s:%s/rest";
public static void main(String[] args) throws Exception {
Log.setLevel( Level.FINER );
String ip = IP.hostAddress();
String serverURI = String.format(SERVER_BASE_URI, ip, PORT);
ResourceConfig config = new ResourceConfig();
// config.register(new _TODO_RestProfilesResources(serverURI)); TODO
JdkHttpServerFactory.createHttpServer( URI.create(serverURI.replace(ip, "0.0.0.0")), config);
Log.info(String.format("%s Server ready @ %s\n", SERVICE, serverURI));
Discovery.announce(SERVICE, serverURI);
}
}