-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
31 lines (24 loc) · 1.08 KB
/
App.java
File metadata and controls
31 lines (24 loc) · 1.08 KB
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
package httpserver;
import httpserver.file.FileOperator;
import httpserver.file.PathExaminer;
import java.io.IOException;
import java.nio.file.Path;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class App {
public static void main(String[] args) throws IOException {
int port = Integer.parseInt(args[1]);
String fileDirectory = args[3];
PathExaminer pathExaminer = new PathExaminer();
Path root = pathExaminer.getPath(fileDirectory);
Path logPath = pathExaminer.concatenate(root,"logs");
AppConfig appConfig = new AppConfig(root, new Logger(logPath, new FileOperator(), System.err));
ServerFactory serverFactory = new ServerFactory(new ServerSocketFactory(), appConfig);
SocketHandlerFactory socketHandlerFactory = new SocketHandlerFactory();
ExecutorService threadPool = Executors.newFixedThreadPool(16);
Server server = serverFactory.makeServer(port);
while (true) {
server.acceptConnection(threadPool, socketHandlerFactory);
}
}
}