KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > groups > RouteGroupMessagesToSink


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

4 package com.tc.net.groups;
5
6 import com.tc.async.api.EventContext;
7 import com.tc.async.api.Sink;
8 import com.tc.util.Assert;
9
10 public class RouteGroupMessagesToSink implements GroupMessageListener {
11
12   private final String JavaDoc name;
13   private final Sink sink;
14
15   public RouteGroupMessagesToSink(String JavaDoc name, Sink sink) {
16     this.name = name;
17     this.sink = sink;
18   }
19
20   public void messageReceived(NodeID fromNode, GroupMessage msg) {
21     Assert.assertTrue(this.toString(), msg instanceof EventContext);
22     sink.add((EventContext) msg);
23   }
24   
25   public String JavaDoc toString() {
26     return "MessageRouter [ " + name + " ] - > " + sink;
27   }
28
29 }
30
Popular Tags