src/java.rmi/share/classes/java/rmi/activation/ActivationGroupDesc.java
author rriggs
Wed, 02 Oct 2019 13:57:03 -0400
changeset 58446 5c83830390ba
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231663: Incorrect GPL header in some RMI/SQL package-info.java files Reviewed-by: bpb, iris, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     2
 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.rmi.activation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.rmi.MarshalledObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * An activation group descriptor contains the information necessary to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * create/recreate an activation group in which to activate objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Such a descriptor contains: <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <li> the group's class name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <li> the group's code location (the location of the group's class), and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <li> a "marshalled" object that can contain group specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * initialization data. </ul> <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * The group's class must be a concrete subclass of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <code>ActivationGroup</code>. A subclass of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <code>ActivationGroup</code> is created/recreated via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <code>ActivationGroup.createGroup</code> static method that invokes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * a special constructor that takes two arguments: <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <li> the group's <code>ActivationGroupID</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <li> the group's initialization data (in a
23720
7d5147c21927 8039172: Tidy warnings cleanup for java.net, java.math, java.time, java.rmi
yan
parents: 5506
diff changeset
    52
 * <code>java.rmi.MarshalledObject</code>)</ul>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @author      Ann Wollrath
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @since       1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @see         ActivationGroup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @see         ActivationGroupID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public final class ActivationGroupDesc implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @serial The group's fully package qualified class name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private String className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @serial The location from where to load the group's class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private String location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @serial The group's initialization data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private MarshalledObject<?> data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @serial The controlling options for executing the VM in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * another process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private CommandEnvironment env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @serial A properties map which will override those set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * by default in the subprocess environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private Properties props;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /** indicate compatibility with the Java 2 SDK v1.2 version of class */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static final long serialVersionUID = -4936225423168276595L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Constructs a group descriptor that uses the system defaults for group
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * implementation and code location.  Properties specify Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * environment overrides (which will override system properties in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * the group implementation's VM).  The command
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * environment can control the exact command/options used in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * starting the child VM, or can be <code>null</code> to accept
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * rmid's default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * <p>This constructor will create an <code>ActivationGroupDesc</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * with a <code>null</code> group class name, which indicates the system's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * default <code>ActivationGroup</code> implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @param overrides the set of properties to set when the group is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * recreated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param cmd the controlling options for executing the VM in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * another process (or <code>null</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public ActivationGroupDesc(Properties overrides,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                               CommandEnvironment cmd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        this(null, null, null, overrides, cmd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Specifies an alternate group implementation and execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * environment to be used for the group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @param className the group's package qualified class name or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <code>null</code>. A <code>null</code> group class name indicates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * the system's default <code>ActivationGroup</code> implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param location the location from where to load the group's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @param data the group's initialization data contained in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * marshalled form (could contain properties, for example)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param overrides a properties map which will override those set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * by default in the subprocess environment (will be translated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * into <code>-D</code> options), or <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param cmd the controlling options for executing the VM in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * another process (or <code>null</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public ActivationGroupDesc(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                               String location,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                               MarshalledObject<?> data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                               Properties overrides,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                               CommandEnvironment cmd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        this.props = overrides;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        this.env = cmd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        this.data = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        this.location = location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        this.className = className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Returns the group's class name (possibly <code>null</code>).  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <code>null</code> group class name indicates the system's default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * <code>ActivationGroup</code> implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @return the group's class name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public String getClassName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Returns the group's code location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @return the group's code location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public String getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        return location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Returns the group's initialization data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @return the group's initialization data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public MarshalledObject<?> getData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Returns the group's property-override list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @return the property-override list, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public Properties getPropertyOverrides() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        return (props != null) ? (Properties) props.clone() : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Returns the group's command-environment control object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @return the command-environment object, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public CommandEnvironment getCommandEnvironment() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        return this.env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Startup options for ActivationGroup implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * This class allows overriding default system properties and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * specifying implementation-defined options for ActivationGroups.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    public static class CommandEnvironment implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        private static final long serialVersionUID = 6165754737887770191L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
         * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        private String command;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
         * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        private String[] options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
         * Create a CommandEnvironment with all the necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
         * information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
         * @param cmdpath the name of the java executable, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
         * the full path, or <code>null</code>, meaning "use rmid's default".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
         * The named program <em>must</em> be able to accept multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
         * <code>-Dpropname=value</code> options (as documented for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
         * "java" tool)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
         * @param argv extra options which will be used in creating the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
         * ActivationGroup.  Null has the same effect as an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
         * list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
         * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        public CommandEnvironment(String cmdpath,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                                  String[] argv)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            this.command = cmdpath;     // might be null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            // Hold a safe copy of argv in this.options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            if (argv == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                this.options = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                this.options = new String[argv.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                System.arraycopy(argv, 0, this.options, 0, argv.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
         * Fetch the configured path-qualified java command name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
         * @return the configured name, or <code>null</code> if configured to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
         * accept the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        public String getCommandPath() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            return (this.command);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
         * Fetch the configured java command options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
         * @return An array of the command options which will be passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
         * to the new child command by rmid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
         * Note that rmid may add other options before or after these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
         * options, or both.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
         * Never returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
         * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        public String[] getCommandOptions() {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   266
            return options.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
         * Compares two command environments for content equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
         * @param       obj     the Object to compare with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
         * @return      true if these Objects are equal; false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
         * @see         java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            if (obj instanceof CommandEnvironment) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                CommandEnvironment env = (CommandEnvironment) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                    ((command == null ? env.command == null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                      command.equals(env.command)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                     Arrays.equals(options, env.options));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
         * Return identical values for similar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
         * <code>CommandEnvironment</code>s.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
         * @return an integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
         * @see java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        public int hashCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            // hash command and ignore possibly expensive options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            return (command == null ? 0 : command.hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
         * <code>readObject</code> for custom serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
         * <p>This method reads this object's serialized form for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
         * class as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
         * <p>This method first invokes <code>defaultReadObject</code> on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
         * the specified object input stream, and if <code>options</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
         * is <code>null</code>, then <code>options</code> is set to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
         * zero-length array of <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            throws IOException, ClassNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            if (options == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                options = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * Compares two activation group descriptors for content equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @param   obj     the Object to compare with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @return  true if these Objects are equal; false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @see             java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        if (obj instanceof ActivationGroupDesc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            ActivationGroupDesc desc = (ActivationGroupDesc) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                ((className == null ? desc.className == null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                  className.equals(desc.className)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                 (location == null ? desc.location == null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                  location.equals(desc.location)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                 (data == null ? desc.data == null : data.equals(desc.data)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                 (env == null ? desc.env == null : env.equals(desc.env)) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                 (props == null ? desc.props == null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                  props.equals(desc.props)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Produce identical numbers for similar <code>ActivationGroupDesc</code>s.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @return an integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @see java.util.Hashtable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        // hash location, className, data, and env
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        // but omit props (may be expensive)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        return ((location == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                    ? 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                    : location.hashCode() << 24) ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                (env == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                    ? 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                    : env.hashCode() << 16) ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                (className == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                    ? 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                    : className.hashCode() << 8) ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                (data == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                    ? 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                    : data.hashCode()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
}