Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/rmi/activation/ActivationDesc.java
38918 views
1
/*
2
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package java.rmi.activation;
27
28
import java.io.Serializable;
29
import java.rmi.MarshalledObject;
30
31
/**
32
* An activation descriptor contains the information necessary to
33
* activate an object: <ul>
34
* <li> the object's group identifier,
35
* <li> the object's fully-qualified class name,
36
* <li> the object's code location (the location of the class), a codebase URL
37
* path,
38
* <li> the object's restart "mode", and,
39
* <li> a "marshalled" object that can contain object specific
40
* initialization data. </ul>
41
*
42
* <p>A descriptor registered with the activation system can be used to
43
* recreate/activate the object specified by the descriptor. The
44
* <code>MarshalledObject</code> in the object's descriptor is passed
45
* as the second argument to the remote object's constructor for
46
* object to use during reinitialization/activation.
47
*
48
* @author Ann Wollrath
49
* @since 1.2
50
* @see java.rmi.activation.Activatable
51
*/
52
public final class ActivationDesc implements Serializable {
53
54
/**
55
* @serial the group's identifier
56
*/
57
private ActivationGroupID groupID;
58
59
/**
60
* @serial the object's class name
61
*/
62
private String className;
63
64
/**
65
* @serial the object's code location
66
*/
67
private String location;
68
69
/**
70
* @serial the object's initialization data
71
*/
72
private MarshalledObject<?> data;
73
74
/**
75
* @serial indicates whether the object should be restarted
76
*/
77
private boolean restart;
78
79
/** indicate compatibility with the Java 2 SDK v1.2 version of class */
80
private static final long serialVersionUID = 7455834104417690957L;
81
82
/**
83
* Constructs an object descriptor for an object whose class name
84
* is <code>className</code>, that can be loaded from the
85
* code <code>location</code> and whose initialization
86
* information is <code>data</code>. If this form of the constructor
87
* is used, the <code>groupID</code> defaults to the current id for
88
* <code>ActivationGroup</code> for this VM. All objects with the
89
* same <code>ActivationGroupID</code> are activated in the same VM.
90
*
91
* <p>Note that objects specified by a descriptor created with this
92
* constructor will only be activated on demand (by default, the restart
93
* mode is <code>false</code>). If an activatable object requires restart
94
* services, use one of the <code>ActivationDesc</code> constructors that
95
* takes a boolean parameter, <code>restart</code>.
96
*
97
* <p> This constructor will throw <code>ActivationException</code> if
98
* there is no current activation group for this VM. To create an
99
* <code>ActivationGroup</code> use the
100
* <code>ActivationGroup.createGroup</code> method.
101
*
102
* @param className the object's fully package qualified class name
103
* @param location the object's code location (from where the class is
104
* loaded)
105
* @param data the object's initialization (activation) data contained
106
* in marshalled form.
107
* @exception ActivationException if the current group is nonexistent
108
* @exception UnsupportedOperationException if and only if activation is
109
* not supported by this implementation
110
* @since 1.2
111
*/
112
public ActivationDesc(String className,
113
String location,
114
MarshalledObject<?> data)
115
throws ActivationException
116
{
117
this(ActivationGroup.internalCurrentGroupID(),
118
className, location, data, false);
119
}
120
121
/**
122
* Constructs an object descriptor for an object whose class name
123
* is <code>className</code>, that can be loaded from the
124
* code <code>location</code> and whose initialization
125
* information is <code>data</code>. If this form of the constructor
126
* is used, the <code>groupID</code> defaults to the current id for
127
* <code>ActivationGroup</code> for this VM. All objects with the
128
* same <code>ActivationGroupID</code> are activated in the same VM.
129
*
130
* <p>This constructor will throw <code>ActivationException</code> if
131
* there is no current activation group for this VM. To create an
132
* <code>ActivationGroup</code> use the
133
* <code>ActivationGroup.createGroup</code> method.
134
*
135
* @param className the object's fully package qualified class name
136
* @param location the object's code location (from where the class is
137
* loaded)
138
* @param data the object's initialization (activation) data contained
139
* in marshalled form.
140
* @param restart if true, the object is restarted (reactivated) when
141
* either the activator is restarted or the object's activation group
142
* is restarted after an unexpected crash; if false, the object is only
143
* activated on demand. Specifying <code>restart</code> to be
144
* <code>true</code> does not force an initial immediate activation of
145
* a newly registered object; initial activation is lazy.
146
* @exception ActivationException if the current group is nonexistent
147
* @exception UnsupportedOperationException if and only if activation is
148
* not supported by this implementation
149
* @since 1.2
150
*/
151
public ActivationDesc(String className,
152
String location,
153
MarshalledObject<?> data,
154
boolean restart)
155
throws ActivationException
156
{
157
this(ActivationGroup.internalCurrentGroupID(),
158
className, location, data, restart);
159
}
160
161
/**
162
* Constructs an object descriptor for an object whose class name
163
* is <code>className</code> that can be loaded from the
164
* code <code>location</code> and whose initialization
165
* information is <code>data</code>. All objects with the same
166
* <code>groupID</code> are activated in the same Java VM.
167
*
168
* <p>Note that objects specified by a descriptor created with this
169
* constructor will only be activated on demand (by default, the restart
170
* mode is <code>false</code>). If an activatable object requires restart
171
* services, use one of the <code>ActivationDesc</code> constructors that
172
* takes a boolean parameter, <code>restart</code>.
173
*
174
* @param groupID the group's identifier (obtained from registering
175
* <code>ActivationSystem.registerGroup</code> method). The group
176
* indicates the VM in which the object should be activated.
177
* @param className the object's fully package-qualified class name
178
* @param location the object's code location (from where the class is
179
* loaded)
180
* @param data the object's initialization (activation) data contained
181
* in marshalled form.
182
* @exception IllegalArgumentException if <code>groupID</code> is null
183
* @exception UnsupportedOperationException if and only if activation is
184
* not supported by this implementation
185
* @since 1.2
186
*/
187
public ActivationDesc(ActivationGroupID groupID,
188
String className,
189
String location,
190
MarshalledObject<?> data)
191
{
192
this(groupID, className, location, data, false);
193
}
194
195
/**
196
* Constructs an object descriptor for an object whose class name
197
* is <code>className</code> that can be loaded from the
198
* code <code>location</code> and whose initialization
199
* information is <code>data</code>. All objects with the same
200
* <code>groupID</code> are activated in the same Java VM.
201
*
202
* @param groupID the group's identifier (obtained from registering
203
* <code>ActivationSystem.registerGroup</code> method). The group
204
* indicates the VM in which the object should be activated.
205
* @param className the object's fully package-qualified class name
206
* @param location the object's code location (from where the class is
207
* loaded)
208
* @param data the object's initialization (activation) data contained
209
* in marshalled form.
210
* @param restart if true, the object is restarted (reactivated) when
211
* either the activator is restarted or the object's activation group
212
* is restarted after an unexpected crash; if false, the object is only
213
* activated on demand. Specifying <code>restart</code> to be
214
* <code>true</code> does not force an initial immediate activation of
215
* a newly registered object; initial activation is lazy.
216
* @exception IllegalArgumentException if <code>groupID</code> is null
217
* @exception UnsupportedOperationException if and only if activation is
218
* not supported by this implementation
219
* @since 1.2
220
*/
221
public ActivationDesc(ActivationGroupID groupID,
222
String className,
223
String location,
224
MarshalledObject<?> data,
225
boolean restart)
226
{
227
if (groupID == null)
228
throw new IllegalArgumentException("groupID can't be null");
229
this.groupID = groupID;
230
this.className = className;
231
this.location = location;
232
this.data = data;
233
this.restart = restart;
234
}
235
236
/**
237
* Returns the group identifier for the object specified by this
238
* descriptor. A group provides a way to aggregate objects into a
239
* single Java virtual machine. RMI creates/activates objects with
240
* the same <code>groupID</code> in the same virtual machine.
241
*
242
* @return the group identifier
243
* @since 1.2
244
*/
245
public ActivationGroupID getGroupID() {
246
return groupID;
247
}
248
249
/**
250
* Returns the class name for the object specified by this
251
* descriptor.
252
* @return the class name
253
* @since 1.2
254
*/
255
public String getClassName() {
256
return className;
257
}
258
259
/**
260
* Returns the code location for the object specified by
261
* this descriptor.
262
* @return the code location
263
* @since 1.2
264
*/
265
public String getLocation() {
266
return location;
267
}
268
269
/**
270
* Returns a "marshalled object" containing intialization/activation
271
* data for the object specified by this descriptor.
272
* @return the object specific "initialization" data
273
* @since 1.2
274
*/
275
public MarshalledObject<?> getData() {
276
return data;
277
}
278
279
/**
280
* Returns the "restart" mode of the object associated with
281
* this activation descriptor.
282
*
283
* @return true if the activatable object associated with this
284
* activation descriptor is restarted via the activation
285
* daemon when either the daemon comes up or the object's group
286
* is restarted after an unexpected crash; otherwise it returns false,
287
* meaning that the object is only activated on demand via a
288
* method call. Note that if the restart mode is <code>true</code>, the
289
* activator does not force an initial immediate activation of
290
* a newly registered object; initial activation is lazy.
291
* @since 1.2
292
*/
293
public boolean getRestartMode() {
294
return restart;
295
}
296
297
/**
298
* Compares two activation descriptors for content equality.
299
*
300
* @param obj the Object to compare with
301
* @return true if these Objects are equal; false otherwise.
302
* @see java.util.Hashtable
303
* @since 1.2
304
*/
305
public boolean equals(Object obj) {
306
307
if (obj instanceof ActivationDesc) {
308
ActivationDesc desc = (ActivationDesc) obj;
309
return
310
((groupID == null ? desc.groupID == null :
311
groupID.equals(desc.groupID)) &&
312
(className == null ? desc.className == null :
313
className.equals(desc.className)) &&
314
(location == null ? desc.location == null:
315
location.equals(desc.location)) &&
316
(data == null ? desc.data == null :
317
data.equals(desc.data)) &&
318
(restart == desc.restart));
319
320
} else {
321
return false;
322
}
323
}
324
325
/**
326
* Return the same hashCode for similar <code>ActivationDesc</code>s.
327
* @return an integer
328
* @see java.util.Hashtable
329
*/
330
public int hashCode() {
331
return ((location == null
332
? 0
333
: location.hashCode() << 24) ^
334
(groupID == null
335
? 0
336
: groupID.hashCode() << 16) ^
337
(className == null
338
? 0
339
: className.hashCode() << 9) ^
340
(data == null
341
? 0
342
: data.hashCode() << 1) ^
343
(restart
344
? 1
345
: 0));
346
}
347
}
348
349