Clover coverage report - ActiveIO - 1.0 Coverage timestamp: Fri Apr 22 2005 14:27:22 PDT FRAMES NO FRAMES |
file stats: | LOC: | 109 |  | Methods: | 10
| NCLOC: | 68 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
AIOSynchChannelServer.java | 0% | 0% | 0% | 0% |

1 |  |
     /**
2 |  |
      *
3 |  |
      * Copyright 2004 Hiram Chirino
4 |  |
      *
5 |  |
      * Licensed under the Apache License, Version 2.0 (the "License");
6 |  |
      * you may not use this file except in compliance with the License.
7 |  |
      * You may obtain a copy of the License at
8 |  |
      *
9 |  |
      * http://www.apache.org/licenses/LICENSE-2.0
10 |  |
      *
11 |  |
      * Unless required by applicable law or agreed to in writing, software
12 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
13 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  |
      * See the License for the specific language governing permissions and
15 |  |
      * limitations under the License.
16 |  |
      *
17 |  |
      **/
18 |  |
19 |  |
     package org.activeio.net;
20 |  |
21 |  |
     import java.io.IOException;
22 |  |
     import java.net.SocketException;
23 |  |
     import java.net.SocketTimeoutException;
24 |  |
     import java.net.URI;
25 |  |
26 |  |
     import org.activeio.AsynchChannel;
27 |  |
     import org.activeio.Channel;
28 |  |
     import org.activeio.SynchChannelServer;
29 |  |
     import org.activeio.filter.WriteBufferedAsynchChannel;
30 |  |
     import org.activeio.packet.ByteBufferPacket;
31 |  |
32 |  |
     import com.ibm.io.async.AsyncServerSocketChannel;
33 |  |
34 |  |
     /**
35 |  |
      * @version $Revision$
36 |  |
      */
37 |  |
     public class AIOSynchChannelServer implements SynchChannelServer {
38 |  |
39 |  |
         private final AsyncServerSocketChannel serverSocket;
40 |  |
         private final URI bindURI;
41 |  |
         private final URI connectURI;
42 |  |
         private int curentSoTimeout;
43 |  |
44 | 0 |
         public AIOSynchChannelServer(AsyncServerSocketChannel serverSocket, URI bindURI, URI connectURI) throws IOException {
45 | 0 |
             this.serverSocket=serverSocket;
46 | 0 |
             this.bindURI=bindURI;
47 | 0 |
             this.connectURI=connectURI;
48 | 0 |
             this.curentSoTimeout = serverSocket.socket().getSoTimeout();
49 |  |
         }
50 |  |
51 | 0 |
         public URI getBindURI() {
52 | 0 |
             return bindURI;
53 |  |
         }
54 |  |
55 | 0 |
         public URI getConnectURI() {
56 | 0 |
             return this.connectURI;
57 |  |
         }
58 |  |
59 | 0 |
         public void dispose() {
60 | 0 |
             try {
61 | 0 |
                 serverSocket.close();
62 |  |
             } catch (IOException e) {
63 |  |
             }
64 |  |
         }
65 |  |
66 | 0 |
         synchronized public void start() throws IOException {
67 |  |
         }
68 |  |
69 | 0 |
         synchronized public void stop(long timeout) {
70 |  |
         }
71 |  |
72 | 0 |
         public Channel accept(long timeout) throws IOException {
73 | 0 |
             try {
74 |  |
75 | 0 |
                 if (timeout == SynchChannelServer.WAIT_FOREVER_TIMEOUT)
76 | 0 |
                     setSoTimeout(0);
77 | 0 |
                 else if (timeout == SynchChannelServer.NO_WAIT_TIMEOUT)
78 | 0 |
                     setSoTimeout(1);
79 |  |
                 else
80 | 0 |
                     setSoTimeout((int) timeout);
81 |  |
82 | 0 |
                 AsynchChannel channel = new AIOAsynchChannel(serverSocket.accept());
83 | 0 |
                 channel = new WriteBufferedAsynchChannel(channel, ByteBufferPacket.createDefaultBuffer(true), false);
84 | 0 |
                 return channel;
85 |  |
86 |  |
             } catch (SocketTimeoutException ignore) {
87 |  |
             }
88 | 0 |
             return null;
89 |  |
         }
90 |  |
91 | 0 |
         private void setSoTimeout(int i) throws SocketException {
92 | 0 |
             if (curentSoTimeout != i) {
93 | 0 |
                 serverSocket.socket().setSoTimeout(i);
94 | 0 |
                 curentSoTimeout = i;
95 |  |
             }
96 |  |
         }
97 |  |
98 | 0 |
         public Object narrow(Class target) {
99 | 0 |
             if( target.isAssignableFrom(getClass()) ) {
100 | 0 |
                 return this;
101 |  |
             }
102 | 0 |
             return null;
103 |  |
         }
104 |  |
105 | 0 |
         public String toString() {
106 | 0 |
             return "AIO Server: "+getConnectURI();
107 |  |
         }
108 |  |
109 |  |
     }