1 package org.apache.commons.jcs.utils.discovery;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.Serializable;
23 import java.util.ArrayList;
24
25
26
27
28
29
30
31 public class DiscoveredService
32 implements Serializable
33 {
34
35 private static final long serialVersionUID = -7810164772089509751L;
36
37
38 private ArrayList<String> cacheNames;
39
40
41 private String serviceAddress;
42
43
44 private int servicePort;
45
46
47 private long lastHearFromTime = 0;
48
49
50
51
52 public void setCacheNames( ArrayList<String> cacheNames )
53 {
54 this.cacheNames = cacheNames;
55 }
56
57
58
59
60 public ArrayList<String> getCacheNames()
61 {
62 return cacheNames;
63 }
64
65
66
67
68 public void setServiceAddress( String serviceAddress )
69 {
70 this.serviceAddress = serviceAddress;
71 }
72
73
74
75
76 public String getServiceAddress()
77 {
78 return serviceAddress;
79 }
80
81
82
83
84 public void setServicePort( int servicePort )
85 {
86 this.servicePort = servicePort;
87 }
88
89
90
91
92 public int getServicePort()
93 {
94 return servicePort;
95 }
96
97
98
99
100 public void setLastHearFromTime( long lastHearFromTime )
101 {
102 this.lastHearFromTime = lastHearFromTime;
103 }
104
105
106
107
108 public long getLastHearFromTime()
109 {
110 return lastHearFromTime;
111 }
112
113
114 @Override
115 public int hashCode()
116 {
117 final int prime = 31;
118 int result = 1;
119 result = prime * result
120 + ((serviceAddress == null) ? 0 : serviceAddress.hashCode());
121 result = prime * result + servicePort;
122 return result;
123 }
124
125
126
127
128
129
130
131
132
133
134
135 @Override
136 public boolean equals(Object otherArg)
137 {
138 if (this == otherArg)
139 {
140 return true;
141 }
142 if (otherArg == null)
143 {
144 return false;
145 }
146 if (!(otherArg instanceof DiscoveredService))
147 {
148 return false;
149 }
150 DiscoveredService other = (DiscoveredService) otherArg;
151 if (serviceAddress == null)
152 {
153 if (other.serviceAddress != null)
154 {
155 return false;
156 }
157 } else if (!serviceAddress.equals(other.serviceAddress))
158 {
159 return false;
160 }
161 if (servicePort != other.servicePort)
162 {
163 return false;
164 }
165
166 return true;
167 }
168
169
170
171
172 @Override
173 public String toString()
174 {
175 StringBuilder buf = new StringBuilder();
176 buf.append( "\n DiscoveredService" );
177 buf.append( "\n CacheNames = [" + getCacheNames() + "]" );
178 buf.append( "\n ServiceAddress = [" + getServiceAddress() + "]" );
179 buf.append( "\n ServicePort = [" + getServicePort() + "]" );
180 buf.append( "\n LastHearFromTime = [" + getLastHearFromTime() + "]" );
181 return buf.toString();
182 }
183 }