|
|||||||||||||||||||
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 | |||||||||||||||
JxtaSocketSynchChannelFactory.java | - | 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 |
package org.activeio.net;
|
|
19 |
|
|
20 |
import java.io.IOException;
|
|
21 |
import java.net.InetAddress;
|
|
22 |
import java.net.ServerSocket;
|
|
23 |
import java.net.Socket;
|
|
24 |
import java.net.UnknownHostException;
|
|
25 |
|
|
26 |
import javax.net.ServerSocketFactory;
|
|
27 |
import javax.net.SocketFactory;
|
|
28 |
|
|
29 |
import org.p2psockets.P2PServerSocket;
|
|
30 |
import org.p2psockets.P2PSocket;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* A SslSynchChannelFactory creates {@see org.activeio.net.TcpSynchChannel}
|
|
34 |
* and {@see org.activeio.net.TcpSynchChannelServer} objects that use SSL.
|
|
35 |
*
|
|
36 |
* @version $Revision$
|
|
37 |
*/
|
|
38 |
public class JxtaSocketSynchChannelFactory extends SocketSynchChannelFactory { |
|
39 |
|
|
40 |
static public final class JxtaServerSocketFactory extends ServerSocketFactory { |
|
41 |
|
|
42 |
private static JxtaServerSocketFactory defaultJxtaServerSocketFactory = new JxtaServerSocketFactory(); |
|
43 | 0 |
public static ServerSocketFactory getDefault() { |
44 | 0 |
return defaultJxtaServerSocketFactory;
|
45 |
} |
|
46 |
|
|
47 | 0 |
private JxtaServerSocketFactory() {}
|
48 |
|
|
49 | 0 |
public ServerSocket createServerSocket(int localPort) throws IOException { |
50 | 0 |
return new P2PServerSocket(localPort); |
51 |
} |
|
52 |
|
|
53 | 0 |
public ServerSocket createServerSocket(int localPort, int backlog) throws IOException { |
54 | 0 |
return new P2PServerSocket(localPort, backlog); |
55 |
} |
|
56 |
|
|
57 | 0 |
public ServerSocket createServerSocket(int localPort, int backlog, InetAddress localHost) throws IOException { |
58 | 0 |
return new P2PServerSocket(localPort, backlog, localHost); |
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
static public final class JxtaSocketFactory extends SocketFactory { |
|
63 |
|
|
64 |
private static JxtaSocketFactory defaultJxtaSocketFactory = new JxtaSocketFactory(); |
|
65 | 0 |
public static SocketFactory getDefault() { |
66 | 0 |
return defaultJxtaSocketFactory;
|
67 |
} |
|
68 | 0 |
private JxtaSocketFactory() {}
|
69 |
|
|
70 | 0 |
public Socket createSocket(String remoteHost, int remotePort) throws IOException, UnknownHostException { |
71 | 0 |
return new P2PSocket(remoteHost, remotePort); |
72 |
} |
|
73 |
|
|
74 | 0 |
public Socket createSocket(String remoteHost, int remotePort, InetAddress localHost, int localPort) throws IOException, UnknownHostException { |
75 | 0 |
return new P2PSocket(remoteHost, remotePort, localHost, localPort); |
76 |
} |
|
77 |
|
|
78 | 0 |
public Socket createSocket(InetAddress remoteHost, int remotePort) throws IOException { |
79 | 0 |
return new P2PSocket(remoteHost, remotePort); |
80 |
} |
|
81 |
|
|
82 | 0 |
public Socket createSocket(InetAddress remoteHost, int remotePort, InetAddress localHost, int localPort) throws IOException { |
83 | 0 |
return new P2PSocket(remoteHost, remotePort, localHost, localPort); |
84 |
} |
|
85 |
} |
|
86 |
|
|
87 | 0 |
public JxtaSocketSynchChannelFactory() {
|
88 | 0 |
super(JxtaSocketFactory.getDefault(), JxtaServerSocketFactory.getDefault());
|
89 |
} |
|
90 |
} |
|
91 |
|
|