1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.cluster; |
18 |
|
|
19 |
|
import java.io.IOException; |
20 |
|
import java.io.ObjectInputStream; |
21 |
|
import java.io.ObjectOutputStream; |
22 |
|
import java.io.Serializable; |
23 |
|
import java.text.DateFormat; |
24 |
|
import java.util.Date; |
25 |
|
|
26 |
|
import org.apache.pluto.om.common.ObjectID; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
public class NodeInformationImpl implements NodeInformation, Serializable |
35 |
|
{ |
36 |
|
static final long serialVersionUID = -598265530537353219L; |
37 |
|
|
38 |
|
private Long id; |
39 |
|
private String contextName; |
40 |
0 |
private Date lastDeployDate = null; |
41 |
|
private static final int CompressVersion = 1; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
public NodeInformationImpl() |
48 |
0 |
{} |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
private void writeObject(ObjectOutputStream out) throws IOException |
55 |
|
{ |
56 |
0 |
out.writeByte(CompressVersion); |
57 |
0 |
out.writeLong(id.longValue()); |
58 |
0 |
out.writeUTF(contextName); |
59 |
0 |
if (lastDeployDate == null) |
60 |
0 |
out.writeByte(0); |
61 |
|
else |
62 |
|
{ |
63 |
0 |
out.writeByte(1); |
64 |
0 |
out.writeLong(lastDeployDate.getTime()); |
65 |
|
} |
66 |
0 |
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
private void readObject(ObjectInputStream in) throws IOException, |
73 |
|
ClassNotFoundException |
74 |
|
{ |
75 |
0 |
int version = in.readByte(); |
76 |
|
|
77 |
|
|
78 |
0 |
id = new Long(in.readLong()); |
79 |
0 |
contextName = in.readUTF(); |
80 |
0 |
int dateSet = in.readByte(); |
81 |
|
|
82 |
0 |
if (dateSet == 1) |
83 |
0 |
lastDeployDate = new Date(in.readLong()); |
84 |
|
else |
85 |
0 |
lastDeployDate = null; |
86 |
0 |
} |
87 |
|
|
88 |
|
public boolean equals(Object object) |
89 |
|
{ |
90 |
0 |
if (object == this) |
91 |
0 |
return true; |
92 |
0 |
if (!(object instanceof NodeInformation)) |
93 |
0 |
return false; |
94 |
0 |
return equals((NodeInformation) object); |
95 |
|
} |
96 |
|
|
97 |
|
public int compareTo(Object object) |
98 |
|
{ |
99 |
0 |
if (object == null) |
100 |
0 |
return 1; |
101 |
0 |
if (object == this) |
102 |
0 |
return 0; |
103 |
0 |
if (!(object instanceof NodeInformation)) |
104 |
0 |
return 1; |
105 |
0 |
return compareTo((NodeInformation) object); |
106 |
|
} |
107 |
|
|
108 |
|
public final boolean equals(NodeInformation object) |
109 |
|
{ |
110 |
0 |
if (object == null) |
111 |
0 |
return false; |
112 |
0 |
return object.getContextName().equalsIgnoreCase(contextName); |
113 |
|
} |
114 |
|
|
115 |
|
public final int compareTo(NodeInformation object) |
116 |
|
{ |
117 |
0 |
return getContextName().compareToIgnoreCase(contextName); |
118 |
|
} |
119 |
|
|
120 |
|
public String toString() |
121 |
|
{ |
122 |
0 |
StringBuffer buffer = new StringBuffer(); |
123 |
0 |
buffer.append("id= " + this.id.longValue()); |
124 |
0 |
buffer.append("; contextName= " + this.getContextName()); |
125 |
0 |
buffer.append("; lastDeployDate= " + this.getContextName()); |
126 |
0 |
if (this.lastDeployDate != null) |
127 |
|
{ |
128 |
0 |
DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT); |
129 |
|
try |
130 |
|
{ |
131 |
0 |
buffer.append(format.format(this.lastDeployDate)); |
132 |
0 |
} catch (Exception e) |
133 |
|
{ |
134 |
0 |
buffer.append("<invalidDate>"); |
135 |
0 |
} |
136 |
0 |
} else |
137 |
0 |
buffer.append("<empty>"); |
138 |
|
|
139 |
0 |
return buffer.toString(); |
140 |
|
} |
141 |
|
|
142 |
|
public String getContextName() |
143 |
|
{ |
144 |
0 |
return contextName; |
145 |
|
} |
146 |
|
|
147 |
|
public void setContextName(String contextName) |
148 |
|
{ |
149 |
0 |
this.contextName = contextName; |
150 |
0 |
} |
151 |
|
|
152 |
|
public Long getId() |
153 |
|
{ |
154 |
0 |
return id; |
155 |
|
} |
156 |
|
|
157 |
|
public void setId(ObjectID id) |
158 |
|
{ |
159 |
0 |
this.id = new Long(id.toString()); |
160 |
0 |
} |
161 |
|
|
162 |
|
public void setId(Long id) |
163 |
|
{ |
164 |
0 |
this.id = id; |
165 |
0 |
} |
166 |
|
|
167 |
|
public void setId(long id) |
168 |
|
{ |
169 |
0 |
this.id = new Long(id); |
170 |
0 |
} |
171 |
|
|
172 |
|
public Date getLastDeployDate() |
173 |
|
{ |
174 |
0 |
return lastDeployDate; |
175 |
|
} |
176 |
|
|
177 |
|
public void setLastDeployDate(Date lastDeployDate) |
178 |
|
{ |
179 |
0 |
this.lastDeployDate = lastDeployDate; |
180 |
0 |
} |
181 |
|
|
182 |
|
} |