001: /*
002: * %W% %E%
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.jump.command;
028:
029: import com.sun.jump.message.JUMPMessage;
030: import com.sun.jump.message.JUMPMessageReader;
031: import com.sun.jump.message.JUMPOutgoingMessage;
032:
033: /**
034: * <code>JUMPExecutiveLifecycleRequest</code> defines all the lifecycle
035: * related requests that originate from the <Code>JUMPExecutive</code>
036: */
037: public class JUMPExecutiveLifecycleRequest extends JUMPRequest {
038: private byte[] appBytes = null;
039:
040: public byte[] getAppBytes() {
041: return appBytes;
042: }
043:
044: /**
045: * Initialize the target isolate
046: * <ol>
047: * <li>args[0] - {@link com.sun.jump.common.JUMPAppModel}</li>
048: * </ol>
049: * Synchronous request.
050: * <p>Expects a {@link com.sun.jump.command.JUMPResponse#ID_SUCCESS} or
051: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}</p>
052: */
053: public static final String ID_INIT_ISOLATE = "InitIsolate";
054:
055: /**
056: * Destroys the target isolate.
057: * <ol>
058: * <li>args[0] - <code>true</code> means <b>best effort</b> and
059: * <code>false</code> means <b>unconditional</b>
060: * </ol>
061: * {@link com.sun.jump.command.JUMPResponse#ID_SUCCESS} or
062: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}
063: */
064: public static final String ID_DESTROY_ISOLATE = "DestroyIsolate";
065:
066: /**
067: * Start the Application to run on the target Isolate. It returns an
068: * unique id within the target isolate that represents the application
069: * running.
070: * <ol>
071: * <li>args[0] - {@link com.sun.jump.common.JUMPApplication}</li>
072: * </ol>
073: * Synchronous request. expects a
074: * {@link com.sun.jump.command.JUMPResponse#ID_DATA} with contents
075: * of the return value as
076: * <ol>
077: * <li>args[0] - Application Id</li>
078: * </ol>
079: * or
080: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}
081: */
082: public static final String ID_START_APP = "StartApp";
083:
084: /**
085: * Pause the Application running on target Isolate
086: * <ol>
087: * <li>args[0] - App Id</li>
088: * </ol>
089: * Synchronous request.
090: * <p>Expects a {@link com.sun.jump.command.JUMPResponse#ID_SUCCESS} or
091: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}</p>
092: */
093: public static final String ID_PAUSE_APP = "PauseApp";
094:
095: /**
096: * Resume the Application paused on target Isolate
097: * <ol>
098: * <li>args[0] - App Id</li>
099: * </ol>
100: * Synchronous request.
101: * <p>Expects a {@link com.sun.jump.command.JUMPResponse#ID_SUCCESS} or
102: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}</p>
103: */
104: public static final String ID_RESUME_APP = "ResumeApp";
105:
106: /**
107: * Get the Windows for the application.
108: * <ol>
109: * <li>args[0] - App Id</li>
110: *
111: * </ol>
112: * Synchronous request. expects a
113: * {@link com.sun.jump.command.JUMPResponse#ID_DATA} with contents
114: * of the return value as
115: * <ol>
116: * <li>args[0] - Number of windows that the application has (N) </li>
117: * <li>args[1] - window id</li>
118: * <li>...</li>
119: * <li>args[N] - windows id</li>
120: * </ol>
121: * or
122: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}
123: */
124: public static final String ID_GET_APP_WINDOWS = "GetAppWindows";
125:
126: /**
127: * Destroys the Application.
128: * <ol>
129: * <li>args[0] - App Id</li>
130: * <li>args[1] - <code>true</code> means <b>best effort</b> and
131: * <code>false</code> means <b>unconditional</b>
132: * </ol>
133: * Synchronous request. expects a
134: * {@link com.sun.jump.command.JUMPResponse#ID_SUCCESS} or
135: * {@link com.sun.jump.command.JUMPResponse#ID_FAILURE}
136: */
137: public static final String ID_DESTROY_APP = "DestroyApp";
138:
139: public static final String MESSAGE_TYPE = "mvm/client";
140:
141: //
142: // To be filled in when de-serializing
143: //
144: protected JUMPExecutiveLifecycleRequest() {
145: super (MESSAGE_TYPE, null, null);
146: }
147:
148: /**
149: * Create a new lifecycle request on an app
150: * @param id The id of the lifecycle request
151: * @param args arguments
152: */
153: public JUMPExecutiveLifecycleRequest(String id, String[] args) {
154: super (MESSAGE_TYPE, id, args);
155: }
156:
157: /**
158: * Create a new lifecycle request on an app
159: * @param id The id of the lifecycle request
160: * @param appBytes the serialized form of an application
161: * @param args arguments
162: */
163: public JUMPExecutiveLifecycleRequest(String id, byte[] appBytes,
164: String[] args) {
165: super (MESSAGE_TYPE, id, args);
166: this .appBytes = appBytes;
167: }
168:
169: public static JUMPCommand fromMessage(JUMPMessage message) {
170: return JUMPCommand.fromMessage(message,
171: JUMPExecutiveLifecycleRequest.class);
172: }
173:
174: /**
175: * For subclasses to use to initialize any fields
176: * using <code>JUMPMessage.get*</code> methods.
177: */
178: protected void deserializeFrom(JUMPMessageReader message) {
179: // First deserialize any shared fields
180: super .deserializeFrom(message);
181: // And now lifecycle request specific fields
182: this .appBytes = message.getByteArray();
183: }
184:
185: /**
186: * For subclasses to use to put data in a message
187: * using <code>JUMPOutgoingMessage.add*</code> methods.
188: */
189: protected void serializeInto(JUMPOutgoingMessage message) {
190: // First deserialize any shared fields
191: super .serializeInto(message);
192: // And now lifecycle request specific fields
193: message.addByteArray(this.appBytes);
194: }
195:
196: }
|