-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEchoProtocolHandler.java
More file actions
35 lines (28 loc) · 957 Bytes
/
EchoProtocolHandler.java
File metadata and controls
35 lines (28 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
34
35
package org.javaee7.chapter01;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.WebConnection;
/**
*
* @author Juneau
*/
public class EchoProtocolHandler implements HttpUpgradeHandler {
@Override
public void init(WebConnection wc) {
try {
System.out.println("Upgrading the protocol...");
ServletInputStream input = wc.getInputStream();
ServletOutputStream output = wc.getOutputStream();
ReadListener readListener = new ReadListenerImpl(input,output);
input.setReadListener(readListener);
} catch (Exception e){
System.out.println("Exception has occurred " + e);
}
}
@Override
public void destroy() {
throw new UnsupportedOperationException("Not supported yet.");
}
}