KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > handler > ClientHandshakeHandler


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.objectserver.handler;
5
6 import com.tc.async.api.AbstractEventHandler;
7 import com.tc.async.api.ConfigurationContext;
8 import com.tc.async.api.EventContext;
9 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("Closing channel "+ c.getChannelID() + " because of previous errors");
27       c.close();
28     }
29   }
30
31   public void initialize(ConfigurationContext ctxt) {
32     super.initialize(ctxt);
33     ServerConfigurationContext scc = ((ServerConfigurationContext) ctxt);
34     this.handshakeManager = scc.getClientHandshakeManager();
35   }
36
37 }
38
Popular Tags