-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathService_a.java
More file actions
74 lines (62 loc) · 1.7 KB
/
Service_a.java
File metadata and controls
74 lines (62 loc) · 1.7 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ningluo
*/
public class Service_a implements Runnable {
ServerSocket WelcomeSocket;
//Thread t;
public static String WWW_ROOT;
properties prop;
public Service_a(ServerSocket s, properties p, String root) {
WelcomeSocket = s;
prop = p;
WWW_ROOT = root;
}
@Override
public void run() {
while (true) {
Socket connectionSocket = null;
synchronized (WelcomeSocket) {
try {
connectionSocket = WelcomeSocket.accept();
} catch (IOException ex) {
// Logger.getLogger(Worker.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception ex) {
// Logger.getLogger(Worker.class.getName()).log(Level.SEVERE, null, ex);
}
}
// System.out.println("\nReceive request from " + connectionSocket);
WebRequestHandler wrh = null;
try {
wrh = new WebRequestHandler(connectionSocket, prop.getNameMap());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
wrh.processRequest();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
connectionSocket.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} // end run