Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/rmi/activation/ActivationDesc.java
38918 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.rmi.activation;2627import java.io.Serializable;28import java.rmi.MarshalledObject;2930/**31* An activation descriptor contains the information necessary to32* activate an object: <ul>33* <li> the object's group identifier,34* <li> the object's fully-qualified class name,35* <li> the object's code location (the location of the class), a codebase URL36* path,37* <li> the object's restart "mode", and,38* <li> a "marshalled" object that can contain object specific39* initialization data. </ul>40*41* <p>A descriptor registered with the activation system can be used to42* recreate/activate the object specified by the descriptor. The43* <code>MarshalledObject</code> in the object's descriptor is passed44* as the second argument to the remote object's constructor for45* object to use during reinitialization/activation.46*47* @author Ann Wollrath48* @since 1.249* @see java.rmi.activation.Activatable50*/51public final class ActivationDesc implements Serializable {5253/**54* @serial the group's identifier55*/56private ActivationGroupID groupID;5758/**59* @serial the object's class name60*/61private String className;6263/**64* @serial the object's code location65*/66private String location;6768/**69* @serial the object's initialization data70*/71private MarshalledObject<?> data;7273/**74* @serial indicates whether the object should be restarted75*/76private boolean restart;7778/** indicate compatibility with the Java 2 SDK v1.2 version of class */79private static final long serialVersionUID = 7455834104417690957L;8081/**82* Constructs an object descriptor for an object whose class name83* is <code>className</code>, that can be loaded from the84* code <code>location</code> and whose initialization85* information is <code>data</code>. If this form of the constructor86* is used, the <code>groupID</code> defaults to the current id for87* <code>ActivationGroup</code> for this VM. All objects with the88* same <code>ActivationGroupID</code> are activated in the same VM.89*90* <p>Note that objects specified by a descriptor created with this91* constructor will only be activated on demand (by default, the restart92* mode is <code>false</code>). If an activatable object requires restart93* services, use one of the <code>ActivationDesc</code> constructors that94* takes a boolean parameter, <code>restart</code>.95*96* <p> This constructor will throw <code>ActivationException</code> if97* there is no current activation group for this VM. To create an98* <code>ActivationGroup</code> use the99* <code>ActivationGroup.createGroup</code> method.100*101* @param className the object's fully package qualified class name102* @param location the object's code location (from where the class is103* loaded)104* @param data the object's initialization (activation) data contained105* in marshalled form.106* @exception ActivationException if the current group is nonexistent107* @exception UnsupportedOperationException if and only if activation is108* not supported by this implementation109* @since 1.2110*/111public ActivationDesc(String className,112String location,113MarshalledObject<?> data)114throws ActivationException115{116this(ActivationGroup.internalCurrentGroupID(),117className, location, data, false);118}119120/**121* Constructs an object descriptor for an object whose class name122* is <code>className</code>, that can be loaded from the123* code <code>location</code> and whose initialization124* information is <code>data</code>. If this form of the constructor125* is used, the <code>groupID</code> defaults to the current id for126* <code>ActivationGroup</code> for this VM. All objects with the127* same <code>ActivationGroupID</code> are activated in the same VM.128*129* <p>This constructor will throw <code>ActivationException</code> if130* there is no current activation group for this VM. To create an131* <code>ActivationGroup</code> use the132* <code>ActivationGroup.createGroup</code> method.133*134* @param className the object's fully package qualified class name135* @param location the object's code location (from where the class is136* loaded)137* @param data the object's initialization (activation) data contained138* in marshalled form.139* @param restart if true, the object is restarted (reactivated) when140* either the activator is restarted or the object's activation group141* is restarted after an unexpected crash; if false, the object is only142* activated on demand. Specifying <code>restart</code> to be143* <code>true</code> does not force an initial immediate activation of144* a newly registered object; initial activation is lazy.145* @exception ActivationException if the current group is nonexistent146* @exception UnsupportedOperationException if and only if activation is147* not supported by this implementation148* @since 1.2149*/150public ActivationDesc(String className,151String location,152MarshalledObject<?> data,153boolean restart)154throws ActivationException155{156this(ActivationGroup.internalCurrentGroupID(),157className, location, data, restart);158}159160/**161* Constructs an object descriptor for an object whose class name162* is <code>className</code> that can be loaded from the163* code <code>location</code> and whose initialization164* information is <code>data</code>. All objects with the same165* <code>groupID</code> are activated in the same Java VM.166*167* <p>Note that objects specified by a descriptor created with this168* constructor will only be activated on demand (by default, the restart169* mode is <code>false</code>). If an activatable object requires restart170* services, use one of the <code>ActivationDesc</code> constructors that171* takes a boolean parameter, <code>restart</code>.172*173* @param groupID the group's identifier (obtained from registering174* <code>ActivationSystem.registerGroup</code> method). The group175* indicates the VM in which the object should be activated.176* @param className the object's fully package-qualified class name177* @param location the object's code location (from where the class is178* loaded)179* @param data the object's initialization (activation) data contained180* in marshalled form.181* @exception IllegalArgumentException if <code>groupID</code> is null182* @exception UnsupportedOperationException if and only if activation is183* not supported by this implementation184* @since 1.2185*/186public ActivationDesc(ActivationGroupID groupID,187String className,188String location,189MarshalledObject<?> data)190{191this(groupID, className, location, data, false);192}193194/**195* Constructs an object descriptor for an object whose class name196* is <code>className</code> that can be loaded from the197* code <code>location</code> and whose initialization198* information is <code>data</code>. All objects with the same199* <code>groupID</code> are activated in the same Java VM.200*201* @param groupID the group's identifier (obtained from registering202* <code>ActivationSystem.registerGroup</code> method). The group203* indicates the VM in which the object should be activated.204* @param className the object's fully package-qualified class name205* @param location the object's code location (from where the class is206* loaded)207* @param data the object's initialization (activation) data contained208* in marshalled form.209* @param restart if true, the object is restarted (reactivated) when210* either the activator is restarted or the object's activation group211* is restarted after an unexpected crash; if false, the object is only212* activated on demand. Specifying <code>restart</code> to be213* <code>true</code> does not force an initial immediate activation of214* a newly registered object; initial activation is lazy.215* @exception IllegalArgumentException if <code>groupID</code> is null216* @exception UnsupportedOperationException if and only if activation is217* not supported by this implementation218* @since 1.2219*/220public ActivationDesc(ActivationGroupID groupID,221String className,222String location,223MarshalledObject<?> data,224boolean restart)225{226if (groupID == null)227throw new IllegalArgumentException("groupID can't be null");228this.groupID = groupID;229this.className = className;230this.location = location;231this.data = data;232this.restart = restart;233}234235/**236* Returns the group identifier for the object specified by this237* descriptor. A group provides a way to aggregate objects into a238* single Java virtual machine. RMI creates/activates objects with239* the same <code>groupID</code> in the same virtual machine.240*241* @return the group identifier242* @since 1.2243*/244public ActivationGroupID getGroupID() {245return groupID;246}247248/**249* Returns the class name for the object specified by this250* descriptor.251* @return the class name252* @since 1.2253*/254public String getClassName() {255return className;256}257258/**259* Returns the code location for the object specified by260* this descriptor.261* @return the code location262* @since 1.2263*/264public String getLocation() {265return location;266}267268/**269* Returns a "marshalled object" containing intialization/activation270* data for the object specified by this descriptor.271* @return the object specific "initialization" data272* @since 1.2273*/274public MarshalledObject<?> getData() {275return data;276}277278/**279* Returns the "restart" mode of the object associated with280* this activation descriptor.281*282* @return true if the activatable object associated with this283* activation descriptor is restarted via the activation284* daemon when either the daemon comes up or the object's group285* is restarted after an unexpected crash; otherwise it returns false,286* meaning that the object is only activated on demand via a287* method call. Note that if the restart mode is <code>true</code>, the288* activator does not force an initial immediate activation of289* a newly registered object; initial activation is lazy.290* @since 1.2291*/292public boolean getRestartMode() {293return restart;294}295296/**297* Compares two activation descriptors for content equality.298*299* @param obj the Object to compare with300* @return true if these Objects are equal; false otherwise.301* @see java.util.Hashtable302* @since 1.2303*/304public boolean equals(Object obj) {305306if (obj instanceof ActivationDesc) {307ActivationDesc desc = (ActivationDesc) obj;308return309((groupID == null ? desc.groupID == null :310groupID.equals(desc.groupID)) &&311(className == null ? desc.className == null :312className.equals(desc.className)) &&313(location == null ? desc.location == null:314location.equals(desc.location)) &&315(data == null ? desc.data == null :316data.equals(desc.data)) &&317(restart == desc.restart));318319} else {320return false;321}322}323324/**325* Return the same hashCode for similar <code>ActivationDesc</code>s.326* @return an integer327* @see java.util.Hashtable328*/329public int hashCode() {330return ((location == null331? 0332: location.hashCode() << 24) ^333(groupID == null334? 0335: groupID.hashCode() << 16) ^336(className == null337? 0338: className.hashCode() << 9) ^339(data == null340? 0341: data.hashCode() << 1) ^342(restart343? 1344: 0));345}346}347348349