|
|||||||||||||||||||
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 | |||||||||||||||
VMPipeAsynchChannelServer.java | 50% | 76.5% | 80% | 72.7% |
|
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.URI;
|
|
23 |
|
|
24 |
import org.activeio.AcceptListener;
|
|
25 |
import org.activeio.AsynchChannel;
|
|
26 |
import org.activeio.AsynchChannelServer;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* @version $Revision$
|
|
30 |
*/
|
|
31 |
final public class VMPipeAsynchChannelServer implements AsynchChannelServer { |
|
32 |
|
|
33 |
private final URI bindURI;
|
|
34 |
private final URI connectURI;
|
|
35 |
private AcceptListener acceptListener;
|
|
36 |
private boolean disposed; |
|
37 |
|
|
38 | 16 |
public VMPipeAsynchChannelServer(URI bindURI) {
|
39 | 16 |
this.bindURI = this.connectURI = bindURI; |
40 |
} |
|
41 |
|
|
42 | 12 |
public URI getBindURI() {
|
43 | 12 |
return bindURI;
|
44 |
} |
|
45 |
|
|
46 | 28 |
public URI getConnectURI() {
|
47 | 28 |
return this.connectURI; |
48 |
} |
|
49 |
|
|
50 | 16 |
public void dispose() { |
51 | 16 |
if( disposed )
|
52 | 0 |
return;
|
53 |
|
|
54 | 16 |
VMPipeAsynchChannelFactory.unbindServer(bindURI); |
55 | 16 |
disposed=true;
|
56 |
} |
|
57 |
|
|
58 | 16 |
public void start() throws IOException { |
59 | 16 |
if( acceptListener==null ) |
60 | 0 |
throw new IOException("acceptListener has not been set."); |
61 |
} |
|
62 |
|
|
63 | 0 |
public void stop(long timeout) { |
64 |
} |
|
65 |
|
|
66 | 4 |
public Object narrow(Class target) {
|
67 | 4 |
if( target.isAssignableFrom(getClass()) ) {
|
68 | 4 |
return this; |
69 |
} |
|
70 | 0 |
return null; |
71 |
} |
|
72 |
|
|
73 | 0 |
public String toString() {
|
74 | 0 |
return "VM Pipe Server: "+getConnectURI(); |
75 |
} |
|
76 |
|
|
77 | 16 |
public void setAcceptListener(AcceptListener acceptListener) { |
78 | 16 |
this.acceptListener = acceptListener;
|
79 |
} |
|
80 |
|
|
81 | 16 |
public AsynchChannel connect() {
|
82 | 16 |
VMPipeAsynchChannelPipe pipe = new VMPipeAsynchChannelPipe();
|
83 | 16 |
acceptListener.onAccept(pipe.getRightAsynchChannel()); |
84 | 16 |
return pipe.getLeftAsynchChannel();
|
85 |
} |
|
86 |
|
|
87 |
} |
|