001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: * The Original Software is NetBeans. The Initial Developer of the Original
026: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027: * Microsystems, Inc. All Rights Reserved.
028: *
029: * If you wish your version of this file to be governed by only the CDDL
030: * or only the GPL Version 2, indicate your decision by adding
031: * "[Contributor] elects to include this software in this distribution
032: * under the [CDDL or GPL Version 2] license." If you do not indicate a
033: * single choice of license, a recipient has the option to distribute
034: * your version of this file under either the CDDL, the GPL Version 2 or
035: * to extend the choice of license to its licensees as provided above.
036: * However, if you add GPL Version 2 code and therefore, elected the GPL
037: * Version 2 license, then the option applies only if the new code is
038: * made subject to such option by the copyright holder.
039: */
040:
041: package org.netbeans.lib.profiler.wireprotocol;
042:
043: import org.netbeans.lib.profiler.global.CommonConstants;
044: import java.io.IOException;
045: import java.io.ObjectInputStream;
046: import java.io.ObjectOutputStream;
047:
048: /**
049: * This response is generated by the back end and contains the VM properties such as various class paths.
050: *
051: * @author Tomas Hurka
052: * @author Misha Dmitriev
053: * @author Ian Formanek
054: */
055: public class VMPropertiesResponse extends Response {
056: //~ Instance fields ----------------------------------------------------------------------------------------------------------
057:
058: private String bootClassPath;
059: private String javaClassPath;
060: private String javaCommand;
061: private String javaExtDirs;
062: private String jdkVersionString;
063: private String jvmArguments;
064: private String targetMachineOSName;
065: private String workingDir;
066: private int agentId;
067: private int agentVersion;
068: private long maxHeapSize;
069: private long startupTimeInCounts;
070: private long startupTimeMillis;
071:
072: //~ Constructors -------------------------------------------------------------------------------------------------------------
073:
074: public VMPropertiesResponse(String jdkVerString,
075: String javaClassPath, String javaExtDirs,
076: String bootClassPath, String workingDir,
077: String jvmArguments, String javaCommand,
078: String targetMachineOSName, long maxHeapSize,
079: long startupTimeMillis, long startupTimeInCounts,
080: int agentId) {
081: super (true, VM_PROPERTIES);
082: this .jdkVersionString = jdkVerString;
083: this .javaClassPath = javaClassPath;
084: this .javaExtDirs = javaExtDirs;
085: this .bootClassPath = bootClassPath;
086: this .workingDir = workingDir;
087: this .jvmArguments = (jvmArguments != null) ? jvmArguments : ""; // NOI18N
088: this .javaCommand = (javaCommand != null) ? javaCommand : ""; // NOI18N
089: this .targetMachineOSName = targetMachineOSName;
090: this .maxHeapSize = maxHeapSize;
091: this .startupTimeMillis = startupTimeMillis;
092: this .startupTimeInCounts = startupTimeInCounts & 0xFFFFFFFFFFFFFFL; // we use only 7 bytes for hi res timer
093: this .agentId = agentId;
094: this .agentVersion = CommonConstants.CURRENT_AGENT_VERSION;
095: }
096:
097: // Custom serialization support
098: VMPropertiesResponse() {
099: super (true, VM_PROPERTIES);
100: }
101:
102: //~ Methods ------------------------------------------------------------------------------------------------------------------
103:
104: public int getAgentId() {
105: return agentId;
106: }
107:
108: public int getAgentVersion() {
109: return agentVersion;
110: }
111:
112: public String getBootClassPath() {
113: return bootClassPath;
114: }
115:
116: public String getJDKVersionString() {
117: return jdkVersionString;
118: }
119:
120: public String getJVMArguments() {
121: return jvmArguments;
122: }
123:
124: public String getJavaClassPath() {
125: return javaClassPath;
126: }
127:
128: public String getJavaCommand() {
129: return javaCommand;
130: }
131:
132: public String getJavaExtDirs() {
133: return javaExtDirs;
134: }
135:
136: public long getMaxHeapSize() {
137: return maxHeapSize;
138: }
139:
140: public long getStartupTimeInCounts() {
141: return startupTimeInCounts;
142: }
143:
144: public long getStartupTimeMillis() {
145: return startupTimeMillis;
146: }
147:
148: public String getTargetMachineOSName() {
149: return targetMachineOSName;
150: }
151:
152: public String getWorkingDir() {
153: return workingDir;
154: }
155:
156: // For debugging
157: public String toString() {
158: return "VMPropertiesResponse:" // NOI18N
159: + "\n jdkVersionString: " + jdkVersionString // NOI18N
160: + "\n javaClassPath: " + javaClassPath // NOI18N
161: + "\n javaExtDirs: " + javaExtDirs // NOI18N
162: + "\n bootClassPath: " + bootClassPath // NOI18N
163: + "\n workingDir: " + workingDir // NOI18N
164: + "\n jvmArguments: " + jvmArguments // NOI18N
165: + "\n javaCommand: " + javaCommand // NOI18N
166: + "\n targetMachineOSName: " + targetMachineOSName // NOI18N
167: + "\n maxHeapSize: " + maxHeapSize // NOI18N
168: + "\n startupTimeMillis: " + startupTimeMillis // NOI18N
169: + "\n startupTimeInCounts: " + startupTimeInCounts // NOI18N
170: + "\n agentId: " + agentId // NOI18N
171: + "\n agentVersion: " + agentVersion // NOI18N
172: + "\n" + super .toString(); // NOI18N
173: }
174:
175: void readObject(ObjectInputStream in) throws IOException {
176: agentVersion = in.readInt();
177: jdkVersionString = in.readUTF();
178: javaClassPath = in.readUTF();
179: javaExtDirs = in.readUTF();
180: bootClassPath = in.readUTF();
181: workingDir = in.readUTF();
182: jvmArguments = in.readUTF();
183: javaCommand = in.readUTF();
184: targetMachineOSName = in.readUTF();
185: maxHeapSize = in.readLong();
186: startupTimeMillis = in.readLong();
187: startupTimeInCounts = in.readLong();
188: agentId = in.readInt();
189: }
190:
191: void writeObject(ObjectOutputStream out) throws IOException {
192: out.writeInt(agentVersion);
193: out.writeUTF(jdkVersionString);
194: out.writeUTF(javaClassPath);
195: out.writeUTF(javaExtDirs);
196: out.writeUTF(bootClassPath);
197: out.writeUTF(workingDir);
198: out.writeUTF(jvmArguments);
199: out.writeUTF(javaCommand);
200: out.writeUTF(targetMachineOSName);
201: out.writeLong(maxHeapSize);
202: out.writeLong(startupTimeMillis);
203: out.writeLong(startupTimeInCounts);
204: out.writeInt(agentId);
205: }
206: }
|