-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (26 loc) · 957 Bytes
/
Copy pathMain.java
File metadata and controls
34 lines (26 loc) · 957 Bytes
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
import api.ApiClient;
import api.ResponseParser;
import domain.Language;
import http.RequestHandler;
import service.CatFactService;
import storage.CatFactCache;
import threads.UpdaterThread;
import java.net.ServerSocket;
import java.net.Socket;
public class Main {
public static void main(String[] args) throws Exception {
ApiClient apiClient = new ApiClient();
ResponseParser parser = new ResponseParser();
CatFactCache cache = new CatFactCache();
CatFactService service =
new CatFactService(apiClient, parser, cache);
new UpdaterThread(service, Language.EN).start();
new UpdaterThread(service, Language.RU).start();
ServerSocket server = new ServerSocket(8080);
System.out.println("Server started on 8080");
while (true) {
Socket socket = server.accept();
new Thread(new RequestHandler(socket, service)).start();
}
}
}