01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.server;
05:
06: import com.tc.async.api.AbstractEventHandler;
07: import com.tc.async.api.EventContext;
08: import com.tc.bytes.TCByteBuffer;
09: import com.tc.logging.TCLogger;
10: import com.tc.logging.TCLogging;
11: import com.tc.net.protocol.HttpConnectionContext;
12:
13: import java.net.Socket;
14:
15: public class HttpConnectionHandler extends AbstractEventHandler {
16:
17: private static final TCLogger logger = TCLogging
18: .getLogger(HttpConnectionContext.class);
19:
20: private final TerracottaConnector terracottaConnector;
21:
22: public HttpConnectionHandler(TerracottaConnector terracottaConnector) {
23: this .terracottaConnector = terracottaConnector;
24: //
25: }
26:
27: public void handleEvent(EventContext context) {
28: HttpConnectionContext connContext = (HttpConnectionContext) context;
29:
30: Socket s = connContext.getSocket();
31: TCByteBuffer buffer = connContext.getBuffer();
32: byte[] data = new byte[buffer.limit()];
33: buffer.get(data);
34: try {
35: terracottaConnector.handleSocketFromDSO(s, data);
36: } catch (Exception e) {
37: logger.error(e);
38: }
39: }
40:
41: }
|