01: /*
02: * Copyright (c) 2002 by Matt Welsh and The Regents of the University of
03: * California. All rights reserved.
04: *
05: * Permission to use, copy, modify, and distribute this software and its
06: * documentation for any purpose, without fee, and without written agreement is
07: * hereby granted, provided that the above copyright notice and the following
08: * two paragraphs appear in all copies of this software.
09: *
10: * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
11: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
12: * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
13: * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14: *
15: * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
16: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17: * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
18: * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
19: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
20: *
21: * Author: Matt Welsh <mdw@cs.berkeley.edu>
22: *
23: */
24:
25: package seda.sandStorm.lib.aSocket.nio;
26:
27: import java.io.*;
28: import java.nio.*;
29: import java.nio.channels.*;
30: import seda.sandStorm.api.*;
31: import seda.sandStorm.lib.aSocket.*;
32: import java.net.*;
33:
34: /**
35: * The NIO implementation of aSocketImplFactory.
36: *
37: * @author Matt Welsh
38: */
39: public class NIOFactory extends aSocketImplFactory {
40: private static final boolean DEBUG = false;
41:
42: protected SelectSourceIF newSelectSource() {
43: return new NIOSelectSource();
44: }
45:
46: protected seda.sandStorm.lib.aSocket.SelectQueueElement newSelectQueueElement(
47: Object item) {
48: return new seda.sandStorm.lib.aSocket.nio.NIOSelectorQueueElement(
49: (SelectionKey) item);
50: }
51:
52: protected seda.sandStorm.lib.aSocket.SockState newSockState(
53: ATcpConnection conn, Socket nbsock, int writeClogThreshold)
54: throws IOException {
55: return new seda.sandStorm.lib.aSocket.nio.SockState(conn,
56: nbsock, writeClogThreshold);
57: }
58:
59: protected seda.sandStorm.lib.aSocket.ConnectSockState newConnectSockState(
60: ATcpConnectRequest req, SelectSourceIF selsource)
61: throws IOException {
62: return new seda.sandStorm.lib.aSocket.nio.ConnectSockState(req,
63: selsource);
64: }
65:
66: protected seda.sandStorm.lib.aSocket.ListenSockState newListenSockState(
67: ATcpListenRequest req, SelectSourceIF selsource)
68: throws IOException {
69: return new seda.sandStorm.lib.aSocket.nio.ListenSockState(req,
70: selsource);
71: }
72:
73: protected seda.sandStorm.lib.aSocket.DatagramSockState newDatagramSockState(
74: AUdpSocket sock, InetAddress addr, int port)
75: throws IOException {
76: return new seda.sandStorm.lib.aSocket.nio.DatagramSockState(
77: sock, addr, port);
78: }
79:
80: }
|