1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package fulmine.distribution.connection.tcp;
17
18 import static fulmine.util.Utils.COLON;
19 import static fulmine.util.Utils.string;
20 import fulmine.AbstractLifeCycle;
21 import fulmine.Domain;
22 import fulmine.IDomain;
23 import fulmine.ILifeCycle;
24 import fulmine.IType;
25 import fulmine.Type;
26 import fulmine.context.IFrameworkContext;
27 import fulmine.distribution.connection.IConnectionBroker;
28 import fulmine.distribution.connection.IConnectionParameters;
29 import fulmine.util.reference.is;
30
31
32
33
34
35
36
37
38
39
40
41
42 public class TcpConnectionParameters extends AbstractLifeCycle implements
43 IConnectionParameters
44 {
45
46
47
48
49 private final String remoteHostAddress;
50
51
52 private final int remoteHostTcpPort;
53
54
55
56
57
58 private String identity;
59
60
61 private int connectionHashCode;
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 public TcpConnectionParameters(String identity, int connectionHashCode,
77 String address, int port)
78 {
79 this.identity = identity;
80 this.remoteHostAddress = address;
81 this.remoteHostTcpPort = port;
82 this.connectionHashCode = connectionHashCode;
83 }
84
85 public final String getRemoteContextIdentity()
86 {
87 return this.identity;
88 }
89
90
91
92
93
94 protected String getRemoteHostAddress()
95 {
96 return this.remoteHostAddress;
97 }
98
99
100
101
102 protected int getRemoteHostTcpPort()
103 {
104 return this.remoteHostTcpPort;
105 }
106
107 protected void setIdentity(String identity)
108 {
109 this.identity = identity;
110 }
111
112 public final String getIdentity()
113 {
114 return this.identity;
115 }
116
117 public IType getType()
118 {
119 return Type.SYSTEM;
120 }
121
122 public IDomain getDomain()
123 {
124 return Domain.FRAMEWORK;
125 }
126
127 public String getAddress()
128 {
129 return getIdentity() + COLON + getType() + COLON + getDomain();
130 }
131
132 protected void setRemoteContextHashCode(int hashCode)
133 {
134 this.connectionHashCode = hashCode;
135 }
136
137 public int getRemoteContextHashCode()
138 {
139 return this.connectionHashCode;
140 }
141
142 public boolean isEqual(IConnectionParameters connectionParameters)
143 {
144 return equals(connectionParameters);
145 }
146
147 @Override
148 protected void doDestroy()
149 {
150 }
151
152 @Override
153 protected void doStart()
154 {
155 }
156
157 @Override
158 public String toString()
159 {
160 return string(this, getIdentity() + ", Socket="
161 + getRemoteHostAddress() + COLON + getRemoteHostTcpPort()
162 + ", connectionHashCode=" + getRemoteContextHashCode());
163 }
164
165 @Override
166 public int hashCode()
167 {
168 return this.connectionHashCode;
169 }
170
171 @Override
172 public boolean equals(Object obj)
173 {
174 if (is.same(this, obj))
175 {
176 return true;
177 }
178 if (!(obj instanceof TcpConnectionParameters))
179 {
180 return false;
181 }
182 final TcpConnectionParameters other = (TcpConnectionParameters) obj;
183 return is.eq(this.connectionHashCode, other.connectionHashCode)
184 && is.eq(this.remoteHostAddress, other.remoteHostAddress)
185 && is.eq(this.identity, other.identity)
186 && is.eq(this.remoteHostTcpPort, other.remoteHostTcpPort);
187 }
188 }