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;
26:
27: import java.io.*;
28: import java.net.*;
29:
30: /**
31: * aSocketImplFactory is an internal abstract class used to represent
32: * the interface between the aSocket library and a provider implementation.
33: *
34: * @author Matt Welsh
35: */
36: public abstract class aSocketImplFactory {
37: private static final boolean DEBUG = false;
38:
39: static aSocketImplFactory getFactory()
40: throws ClassNotFoundException, InstantiationException,
41: IllegalAccessException {
42: aSocketImplFactory factory;
43:
44: if (aSocketMgr.USE_NIO) {
45: factory = (aSocketImplFactory) Class.forName(
46: "seda.sandStorm.lib.aSocket.nio.NIOFactory")
47: .newInstance();
48: } else {
49: factory = (aSocketImplFactory) Class.forName(
50: "seda.sandStorm.lib.aSocket.nbio.NBIOFactory")
51: .newInstance();
52: }
53: return factory;
54: }
55:
56: protected abstract SelectSourceIF newSelectSource();
57:
58: protected abstract SelectQueueElement newSelectQueueElement(
59: Object item);
60:
61: protected abstract SockState newSockState(ATcpConnection conn,
62: Socket nbsock, int writeClogThreshold) throws IOException;
63:
64: protected abstract ConnectSockState newConnectSockState(
65: ATcpConnectRequest req, SelectSourceIF selsource)
66: throws IOException;
67:
68: protected abstract ListenSockState newListenSockState(
69: ATcpListenRequest req, SelectSourceIF selsource)
70: throws IOException;
71:
72: protected abstract DatagramSockState newDatagramSockState(
73: AUdpSocket sock, InetAddress addr, int port)
74: throws IOException;
75:
76: }
|