Merge from mainline.
[official-gcc.git] / libjava / classpath / java / rmi / activation / ActivationDesc.java
blobb8616562fa56802cd14600b5dc132baf5300a24f
1 /* ActivationDesc.java -- record with info to activate an object
2 Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package java.rmi.activation;
40 import java.io.Serializable;
41 import java.rmi.MarshalledObject;
43 /**
44 * Contains the information, necessary to activate the object. This information
45 * includes:
46 * <ul>
47 * <li>the object class name</li>
48 * <li>the object group identifier</li>
49 * <li>the code location (codebase URL) that can be used to load the class
50 * remotely</li>
51 * <li>the object restart mode</li>
52 * <li>the object specific intialization information</li>
53 * </ul>
55 * @author Audrius Meskauskas (audriusa@bioinformatics.org) (from stub)
57 public final class ActivationDesc
58 implements Serializable
60 /**
61 * Use SVUID for interoperability.
63 static final long serialVersionUID = 7455834104417690957L;
65 /**
66 * The group id.
68 private ActivationGroupID groupid;
70 /**
71 * The class name.
73 private String classname;
75 /**
76 * The code location URL.
78 private String location;
80 /**
81 * The object specific intitalization data.
83 private MarshalledObject data;
85 /**
86 * The start mode.
88 private boolean restart;
90 /**
91 * Create the new activation description, assuming the object group is the
92 * {@link ActivationGroup#currentGroupID()}.
94 * @param className the object fully qualified class name
95 * @param location the code base URL
96 * @param data the object initialization data, contained in a marshalled form
98 public ActivationDesc(String className, String location, MarshalledObject data)
99 throws ActivationException
101 this(ActivationGroup.currentGroupID(), className, location, data, false);
105 * Create the new activation description, assuming the object group is the
106 * {@link ActivationGroup#currentGroupID()}.
108 * @param className the object fully qualified class name
109 * @param location the code base URL
110 * @param data the object initialization data, contained in a marshalled form
111 * @param restart specifies reactivation mode after crash. If true, the object
112 * is activated when activator is restarted or the activation group
113 * is restarted. If false, the object is only activated on demand.
114 * This flag does has no effect during the normal operation (the
115 * object is normally activated on demand).
117 public ActivationDesc(String className, String location,
118 MarshalledObject data, boolean restart)
119 throws ActivationException
121 this(ActivationGroup.currentGroupID(), className, location, data, restart);
125 * Create the new activation description. Under crash, the object will only
126 * be reactivated on demand.
128 * @param groupID the object group id.
129 * @param className the object fully qualified class name
130 * @param location the code base URL
131 * @param data the object initialization data, contained in a marshalled form
133 public ActivationDesc(ActivationGroupID groupID, String className,
134 String location, MarshalledObject data)
136 this(groupID, className, location, data, false);
140 * Create the new activation description, providing full information.
142 * @param groupID the object group id.
143 * @param className the object fully qualified class name
144 * @param location the code base URL
145 * @param data the object initialization data, contained in a marshalled form
146 * @param restart specifies reactivation mode after crash. If true, the object
147 * is activated when activator is restarted or the activation group
148 * is restarted. If false, the object is only activated on demand.
149 * This flag does has no effect during the normal operation (the
150 * object is normally activated on demand).
152 public ActivationDesc(ActivationGroupID groupID, String className,
153 String location, MarshalledObject data, boolean restart)
155 this.groupid = groupID;
156 this.classname = className;
157 this.location = location;
158 this.data = data;
159 this.restart = restart;
162 public ActivationGroupID getGroupID()
164 return groupid;
168 * Get the class name of the object being activated
170 * @return the fully qualified class name of the object being activated
172 public String getClassName()
174 return classname;
178 * Get the code location URL ("codebase") of the object being activated.
180 * @return the codebase of the object being activated.
182 public String getLocation()
184 return location;
187 public MarshalledObject getData()
189 return data;
193 * Get the object reactivation strategy after crash.
195 * @return true ir the object is activated when activator is restarted or the
196 * activation group is restarted. False if the object is only
197 * activated on demand. This flag does has no effect during the normal
198 * operation (the object is normally activated on demand).
200 public boolean getRestartMode()
202 return restart;
206 * Compare this object with another activation description for equality.
208 * @return true if all fields have the equal values, false otherwise.
210 public boolean equals(Object obj)
212 if (obj instanceof ActivationDesc)
214 ActivationDesc that = (ActivationDesc) obj;
215 return eq(groupid, that.groupid) &&
216 eq(classname, that.classname) &&
217 eq(location, that.location) &&
218 eq(data, that.data)
219 && restart == that.restart;
221 else
222 return false;
226 * Get the hash code of this object (overridden to make the returned value
227 * consistent with .equals(..).
229 public int hashCode()
231 return hash(groupid) ^ hash(classname) ^
232 hash(location) ^ hash(data);
236 * Get the hashcode of x or 0 if x == null.
238 static final int hash(Object x)
240 return x == null ? 0 : x.hashCode();
244 * Compare by .equals if both a and b are not null, compare directly if at
245 * least one of them is null.
247 static final boolean eq(Object a, Object b)
249 if (a == null || b == null)
250 return a == b;
251 else
252 return a.equals(b);