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.objectserver.handler;
05:
06: import com.tc.async.api.AbstractEventHandler;
07: import com.tc.async.api.ConfigurationContext;
08: import com.tc.async.api.EventContext;
09: import com.tc.net.protocol.tcm.MessageChannel;
10: import com.tc.object.msg.ClientHandshakeMessage;
11: import com.tc.objectserver.core.api.ServerConfigurationContext;
12: import com.tc.objectserver.handshakemanager.ClientHandshakeException;
13: import com.tc.objectserver.handshakemanager.ServerClientHandshakeManager;
14:
15: public class ClientHandshakeHandler extends AbstractEventHandler {
16:
17: private ServerClientHandshakeManager handshakeManager;
18:
19: public void handleEvent(EventContext context) {
20: final ClientHandshakeMessage clientMsg = ((ClientHandshakeMessage) context);
21: try {
22: this .handshakeManager.notifyClientConnect(clientMsg);
23: } catch (ClientHandshakeException e) {
24: getLogger().error("Handshake Error : ", e);
25: MessageChannel c = clientMsg.getChannel();
26: getLogger().error(
27: "Closing channel " + c.getChannelID()
28: + " because of previous errors");
29: c.close();
30: }
31: }
32:
33: public void initialize(ConfigurationContext ctxt) {
34: super .initialize(ctxt);
35: ServerConfigurationContext scc = ((ServerConfigurationContext) ctxt);
36: this.handshakeManager = scc.getClientHandshakeManager();
37: }
38:
39: }
|