KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > protocol > PlainNetworkStackHarnessFactory


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.net.protocol;
5
6 import com.tc.net.protocol.tcm.MessageChannelInternal;
7 import com.tc.net.protocol.tcm.ServerMessageChannelFactory;
8 import com.tc.net.protocol.transport.MessageTransport;
9 import com.tc.net.protocol.transport.MessageTransportFactory;
10 import com.tc.net.protocol.transport.MessageTransportListener;
11
12 /**
13  * Plain (no guarenteed messages) network stack harness factory
14  */

15 public class PlainNetworkStackHarnessFactory implements NetworkStackHarnessFactory {
16
17   public NetworkStackHarness createServerHarness(ServerMessageChannelFactory channelFactory,
18                                                  MessageTransport transport,
19                                                  MessageTransportListener[] transportListeners) {
20     return new PlainNetworkStackHarness(channelFactory, transport);
21   }
22
23   public NetworkStackHarness clientClientHarness(MessageTransportFactory transportFactory,
24                                                  MessageChannelInternal channel,
25                                                  MessageTransportListener[] transportListeners) {
26     return new PlainNetworkStackHarness(transportFactory, channel);
27   }
28
29   private static class PlainNetworkStackHarness extends AbstractNetworkStackHarness {
30
31     PlainNetworkStackHarness(ServerMessageChannelFactory channelFactory, MessageTransport transport) {
32       super(channelFactory, transport);
33     }
34
35     PlainNetworkStackHarness(MessageTransportFactory transportFactory, MessageChannelInternal channel) {
36       super(transportFactory, channel);
37     }
38
39     protected void connectStack() {
40       channel.setSendLayer(transport);
41       transport.setReceiveLayer(channel);
42       transport.addTransportListener(channel);
43     }
44
45     protected void createIntermediateLayers() {
46       // No intermediate layers to create.
47
}
48   }
49 }
Popular Tags