001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: package java.rmi.activation;
020:
021: import java.io.Serializable;
022: import java.rmi.MarshalledObject;
023: import java.util.Arrays;
024: import java.util.Properties;
025:
026: public final class ActivationGroupDesc implements Serializable {
027: private static final long serialVersionUID = -4936225423168276595L;
028:
029: /**
030: * The group's fully package qualified class name.
031: */
032: private String className;
033:
034: /**
035: * The location from where to load the group's class.
036: */
037: private String location;
038:
039: /**
040: * The group's initialization data.
041: */
042: private MarshalledObject data;
043:
044: /**
045: * The controlling options for executing the VM in another process.
046: */
047: private ActivationGroupDesc.CommandEnvironment env;
048:
049: /**
050: * A properties map which will override those set by default in the
051: * subprocess environment
052: */
053: private Properties props;
054:
055: public ActivationGroupDesc(Properties props,
056: ActivationGroupDesc.CommandEnvironment env) {
057: this (null, null, null, props, env);
058: }
059:
060: public ActivationGroupDesc(String className, String codebase,
061: MarshalledObject data, Properties props,
062: ActivationGroupDesc.CommandEnvironment env) {
063: super ();
064: this .className = className;
065: this .location = codebase;
066: this .data = data;
067: this .props = props;
068: this .env = env;
069: }
070:
071: public String getClassName() {
072: return className;
073: }
074:
075: public String getLocation() {
076: return location;
077: }
078:
079: public MarshalledObject getData() {
080: return data;
081: }
082:
083: public ActivationGroupDesc.CommandEnvironment getCommandEnvironment() {
084: return env;
085: }
086:
087: public Properties getPropertyOverrides() {
088: return props == null ? null : (Properties) props.clone();
089: }
090:
091: @Override
092: public int hashCode() {
093: final int prime = 31;
094: int result = 1;
095: result = prime * result
096: + ((className == null) ? 0 : className.hashCode());
097: result = prime * result
098: + ((data == null) ? 0 : data.hashCode());
099: result = prime * result + ((env == null) ? 0 : env.hashCode());
100: result = prime * result
101: + ((location == null) ? 0 : location.hashCode());
102: result = prime * result
103: + ((props == null) ? 0 : props.hashCode());
104: return result;
105: }
106:
107: @Override
108: public boolean equals(Object obj) {
109: if (this == obj) {
110: return true;
111: }
112: if (obj == null) {
113: return false;
114: }
115: if (!(obj instanceof ActivationGroupDesc)) {
116: return false;
117: }
118: final ActivationGroupDesc that = (ActivationGroupDesc) obj;
119: if (!(className == null ? that.className == null : className
120: .equals(that.className))) {
121: return false;
122: }
123: if (!(data == null ? that.data == null : data.equals(that.data))) {
124: return false;
125: }
126: if (!(env == null ? that.env == null : env.equals(that.env))) {
127: return false;
128: }
129: if (!(location == null ? that.location == null : location
130: .equals(that.location))) {
131: return false;
132: }
133: return (props == null ? that.props == null : props
134: .equals(that.props));
135: }
136:
137: public static class CommandEnvironment implements Serializable {
138: private static final long serialVersionUID = 6165754737887770191L;
139:
140: private String command;
141:
142: private String options[];
143:
144: public CommandEnvironment(String command, String[] options) {
145: super ();
146: this .command = command;
147: if (options == null) {
148: this .options = null;
149: } else {
150: this .options = new String[options.length];
151: System.arraycopy(options, 0, this .options, 0,
152: options.length);
153: }
154: }
155:
156: public String[] getCommandOptions() {
157: if (options == null) {
158: return new String[0];
159: }
160: return options.clone();
161: }
162:
163: public String getCommandPath() {
164: return this .command;
165: }
166:
167: @Override
168: public int hashCode() {
169: final int prime = 31;
170: int result = 1;
171: result = prime * result
172: + ((command == null) ? 0 : command.hashCode());
173: result = prime * result + Arrays.hashCode(options);
174: return result;
175: }
176:
177: @Override
178: public boolean equals(Object obj) {
179: if (this == obj) {
180: return true;
181: }
182: if (obj == null) {
183: return false;
184: }
185: if (!(obj instanceof CommandEnvironment)) {
186: return false;
187: }
188: final CommandEnvironment that = (CommandEnvironment) obj;
189: if (!(command == null ? that.command == null : command
190: .equals(that.command))) {
191: return false;
192: }
193: return Arrays.equals(options, that.options);
194: }
195: }
196: }
|