-
Notifications
You must be signed in to change notification settings - Fork 0
/
StartProxy.java
54 lines (49 loc) · 1.26 KB
/
StartProxy.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
44
45
46
47
48
49
50
51
52
53
54
import java.io.Reader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class StartProxy
{
private ProxyThread proxyServer;
Cache cache = new Cache();
/*
* Lança a class ProxyThread que permite se executar em varias thread
*/
public StartProxy()
{
System.out.println("Start do proxy");
proxyServer = new ProxyThread(8080, cache);
}
/*
* Caso o tulizador escreva a palavra EXIT o proxy é parado
*/
public void stop()
{
if (proxyServer.isAlive())
proxyServer.interrupt();
}
/*
* Class com o main para iniciar o proxy
*/
public static void main(String[] args)
{
StartProxy proxy = new StartProxy();
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String exit;
boolean done = false;
try {
while (!done){
exit = input.readLine();
if (exit.toUpperCase().equals("EXIT"))
done = true;
}
}
catch (Exception e) {
System.out.println("Erreur MAIN : " + e);
System.exit(1);
}
finally {
proxy.stop();
}
System.exit(0);
}
}