|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package jtr.remote.test; |
|
8 |
| |
|
9 |
| import java.io.Serializable; |
|
10 |
| |
|
11 |
| import static jtr.test.SystemProperties.*; |
|
12 |
| import jtr.config.remote.Node; |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| public class NodeInfo extends Node implements Serializable { |
|
22 |
| |
|
23 |
4
| public static NodeInfo newLocalNodeInfo() {
|
|
24 |
4
| return new NodeInfo("localhost",NO_PORT,null);
|
|
25 |
| } |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
5
| public NodeInfo(String host, int port, String serviceName) {
|
|
34 |
5
| setHost(host);
|
|
35 |
5
| setPort(port);
|
|
36 |
5
| if(serviceName!=null)
|
|
37 |
1
| this.serviceName = serviceName;
|
|
38 |
| else |
|
39 |
4
| this.serviceName = NO_SERVICE;
|
|
40 |
| } |
|
41 |
| |
|
42 |
3
| public NodeInfo(String serviceName) {
|
|
43 |
3
| String host = System.getProperty(RMI_REGISTRY_HOST, DEF_RMI_REGISTRY_HOST);
|
|
44 |
3
| int port = new Integer(System.getProperty(RMI_REGISTRY_PORT, DEF_RMI_REGISTRY_PORT.toString()));
|
|
45 |
3
| setHost(host);
|
|
46 |
3
| setPort(port);
|
|
47 |
3
| if(serviceName!=null)
|
|
48 |
3
| this.serviceName = serviceName;
|
|
49 |
| else |
|
50 |
0
| this.serviceName = NO_SERVICE;
|
|
51 |
| } |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
0
| public String getServiceName() {
|
|
58 |
0
| return serviceName;
|
|
59 |
| } |
|
60 |
| |
|
61 |
45070
| public String toString() {
|
|
62 |
45070
| return toURL();
|
|
63 |
| } |
|
64 |
| |
|
65 |
46795
| public String toURL() {
|
|
66 |
46795
| if(!serviceName.equals(NO_SERVICE))
|
|
67 |
24238
| if(getPort()!=NO_PORT)
|
|
68 |
24238
| return "rmi://"+getHost()+":"+getPort()+"/"+serviceName;
|
|
69 |
| else |
|
70 |
0
| return "rmi://"+getHost()+"/"+serviceName;
|
|
71 |
| else |
|
72 |
22557
| if(getPort()!=NO_PORT)
|
|
73 |
0
| return "rmi://"+getHost()+":"+getPort();
|
|
74 |
| else |
|
75 |
22557
| return "rmi://"+getHost();
|
|
76 |
| } |
|
77 |
| |
|
78 |
44702
| public int hashCode() {
|
|
79 |
44702
| return toString().hashCode();
|
|
80 |
| } |
|
81 |
| |
|
82 |
4
| public boolean equals(Object obj) {
|
|
83 |
4
| if(!(obj instanceof NodeInfo))
|
|
84 |
0
| return false;
|
|
85 |
4
| return this.toString().equals(((NodeInfo)obj).toString());
|
|
86 |
| } |
|
87 |
| |
|
88 |
| private String serviceName; |
|
89 |
| private static final String NO_SERVICE = ""; |
|
90 |
| private static final int NO_PORT = -1; |
|
91 |
| } |