KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > server > HttpConnectionHandler


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.server;
5
6 import com.tc.async.api.AbstractEventHandler;
7 import com.tc.async.api.EventContext;
8 import com.tc.bytes.TCByteBuffer;
9 import com.tc.logging.TCLogger;
10 import com.tc.logging.TCLogging;
11 import com.tc.net.protocol.HttpConnectionContext;
12
13 import java.net.Socket JavaDoc;
14
15 public class HttpConnectionHandler extends AbstractEventHandler {
16
17   private static final TCLogger logger = TCLogging.getLogger(HttpConnectionContext.class);
18
19   private final TerracottaConnector terracottaConnector;
20
21   public HttpConnectionHandler(TerracottaConnector terracottaConnector) {
22     this.terracottaConnector = terracottaConnector;
23     //
24
}
25
26   public void handleEvent(EventContext context) {
27     HttpConnectionContext connContext = (HttpConnectionContext) context;
28
29     Socket JavaDoc s = connContext.getSocket();
30     TCByteBuffer buffer = connContext.getBuffer();
31     byte[] data = new byte[buffer.limit()];
32     buffer.get(data);
33     try {
34       terracottaConnector.handleSocketFromDSO(s, data);
35     } catch (Exception JavaDoc e) {
36       logger.error(e);
37     }
38   }
39
40 }
41
Popular Tags