root/Weektaken2/Weektaak3/ESB/src/hanze/ga/wt3/http/HTTPQ2AppChannel.java

354365
3
import hanze.ga.wt3.channels.Q2App;
3
import hanze.ga.wt3.channels.Q2App;
4
import hanze.ga.wt3.helper.Security;
4
import hanze.ga.wt3.helper.Security;
5
5
6
import java.io.IOException;
7
import java.net.ServerSocket;
8
6
public class HTTPQ2AppChannel extends Q2App {
9
public class HTTPQ2AppChannel extends Q2App {
7
10
8
	private Security httpSecurity;
11
	private Security httpSecurity;
12
	private ServerSocket serverSocket;
9
13
10
	public Security getHttpSecurity() {
14
	public Security getHttpSecurity() {
11
		return httpSecurity;
15
		return httpSecurity;
12
	}
16
	}
13
17
18
	private void openConnection() {
19
		try {
20
			System.out.println("[HTTPQ2AppChannel] Start listening on port "
21
					+ this.getChannelPort() + " for Queue: " + this.getSourceQueue().getqName());
22
23
			serverSocket = new ServerSocket(this.getChannelPort());
24
			while (true) {
25
				new Thread(new HTTPGetConnection(serverSocket.accept(), this)).start();
26
			}
27
		} catch (IOException e) {
28
			e.printStackTrace();
29
		}
30
	}
31
14
	@Override
32
	@Override
15
	public void run() {
33
	public void run() {
16
34
		this.openConnection();
17
	}
35
	}
18
36
19
	public void setHttpSecurity(Security httpSecurity) {
37
	public void setHttpSecurity(Security httpSecurity) {