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 *
026 * The Original Software is NetBeans. The Initial Developer of the Original
027 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028 * Microsystems, Inc. All Rights Reserved.
029 *
030 * If you wish your version of this file to be governed by only the CDDL
031 * or only the GPL Version 2, indicate your decision by adding
032 * "[Contributor] elects to include this software in this distribution
033 * under the [CDDL or GPL Version 2] license." If you do not indicate a
034 * single choice of license, a recipient has the option to distribute
035 * your version of this file under either the CDDL, the GPL Version 2 or
036 * to extend the choice of license to its licensees as provided above.
037 * However, if you add GPL Version 2 code and therefore, elected the GPL
038 * Version 2 license, then the option applies only if the new code is
039 * made subject to such option by the copyright holder.
040 */
041
042 package org.netbeans.modules.j2ee.deployment.plugins.spi;
043
044 import javax.enterprise.deploy.spi.Target;
045 import javax.enterprise.deploy.spi.status.ProgressObject;
046 import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
047 import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
048
049 /**
050 * Server lifecycle services from the IDE. J2eeserver will use these
051 * services to automatically start or stop admin server and managed (virtual)
052 * target servers (in debug mode) during deployment or debugging execution.
053 *
054 * @see OptionalDeploymentManagerFactory
055 * @author George FinKlang
056 * @author nn136682
057 * @version 1.0
058 */
059 public abstract class StartServer {
060
061 /**
062 * Returns true if the admin server is also the given target server (share the same vm).
063 * Start/stopping/debug apply to both servers. When the given target server is null,
064 * service should return true when admin server is also some target.
065 * @param target the target server in question; could be null.
066 * @return true when admin is also target server
067 */
068 public abstract boolean isAlsoTargetServer(Target target);
069
070 /**
071 * Returns true if the admin server can be started through this spi.
072 */
073 public abstract boolean supportsStartDeploymentManager();
074
075 /**
076 * Returns if the plugin can start/stop single target servers.
077 * This should be overwritten as needed.
078 * @param target the target server in question, could be null in which
079 * case the answer should probably be false.
080 * @return true if this plugin can currently handle state management for
081 * the specific target.
082 * @since 1.6
083 */
084 public boolean supportsStartTarget(Target target) {
085 return false;
086 }
087
088 /**
089 * Can be the specified target server started in the debug mode? If the
090 * target is also an admin server can be the admin server started in the
091 * debug mode?
092 *
093 * @param target the target server in question, null implies the case where
094 * target is also an admin server.
095 *
096 * @return true if the target server can be started in the debug mode, false
097 * otherwise. The default return value is false.
098 *
099 * @since 1.7
100 */
101 public boolean supportsStartDebugging(Target target) {
102 return false;
103 }
104
105 /**
106 * Can be the specified target server started in profile mode? If the
107 * target is also an admin server can be the admin server started in
108 * profile mode?
109 *
110 * @param target the target server in question, null implies the case where
111 * target is also an admin server.
112 *
113 * @return true if the target server can be started in profile mode, false
114 * otherwise. The default return value is false.
115 *
116 * @since 1.9
117 */
118 public boolean supportsStartProfiling(Target target) {
119 return false;
120 }
121
122 /**
123 * Starts the admin server. Note that this means that the DeploymentManager
124 * was originally created disconnected. After calling this, the DeploymentManager
125 * will be connected, so any old cached DeploymentManager will be discarded.
126 * All diagnostics should be communicated through ProgressObject without exceptions thrown.
127 *
128 * @return ProgressObject object used to monitor start server progress
129 */
130 public abstract ProgressObject startDeploymentManager();
131
132 /**
133 * Stops the admin server. The DeploymentManager object will be disconnected.
134 * All diagnostic should be communicated through ServerProgres with no
135 * exceptions thrown.
136 * @return ServerProgress object used to monitor start server progress
137 */
138 public abstract ProgressObject stopDeploymentManager();
139
140 /** Optional method. This implementation does nothing.
141 *
142 * Stops the admin server. The DeploymentManager object will be disconnected.
143 * The call should terminate immediately and not wait for the server to stop.
144 * <div class="nonnormative">
145 * This will be used at IDE shutdown so that the server shutdown does not block the IDE.
146 * </div>
147 */
148 public void stopDeploymentManagerSilently() {
149 //do nothing
150 }
151
152 /** See {@link stopDeploymentManagerSilently}
153 * @return override and return true if stopDeploymentManagerSilently is implemented
154 */
155 public boolean canStopDeploymentManagerSilently() {
156 return false;
157 }
158
159 /**
160 * Returns true if the admin server should be started before server deployment configuration.
161 */
162 public abstract boolean needsStartForConfigure();
163
164 /**
165 * Returns true if the admin server should be started before asking for
166 * target list.
167 */
168 public abstract boolean needsStartForTargetList();
169
170 /**
171 * Returns true if the admin server should be started before admininistrative configuration.
172 */
173 public abstract boolean needsStartForAdminConfig();
174
175 /**
176 * Returns true if this admin server is running.
177 */
178 public abstract boolean isRunning();
179
180 /**
181 * Returns the running state of a specific target. This should be
182 * overwritten by plugins which support multiple target servers via
183 * one admin server.
184 * @param target the target server in question; null value implies
185 * the query is against the admin server.
186 * @return true if the server is question is running.
187 * @since 1.6
188 */
189 public boolean isRunning(Target target) {
190 if (target == null || isAlsoTargetServer(target)) {
191 return isRunning();
192 }
193
194 return false;
195 }
196
197 /**
198 * Returns true if the given target is in debug mode.
199 */
200 public abstract boolean isDebuggable(Target target);
201
202 /**
203 * Starts the target server asynchronously and reports the status
204 * through the returned <code>ProgressObject</code>. This should be
205 * overwritten by plugins which support the state management of
206 * different target servers.
207 * @param target a non-null target server to be started
208 * @return a ProgressObject which is used to communicate the
209 * progess/state of this action. Should not be null when supportsStartTarget
210 * returns true on same target.
211 * @since 1.6
212 */
213 public ProgressObject startTarget(Target target) {
214 return null;
215 }
216
217 /**
218 * Stops the target server asynchronously and reports the status
219 * through the returned <code>ProgressObject</code>. This should be
220 * overwritten by plugins which support the state management of
221 * different target servers.
222 * @param target a non-null target server to be stopped
223 * @return a ProgressObject which is used to communicate the
224 * progess/state of this action. Should not be null when supportsStartTarget
225 * return true on the same target.
226 * @since 1.6
227 */
228 public ProgressObject stopTarget(Target target) {
229 return null;
230 }
231
232 /**
233 * Start or restart the target in debug mode.
234 * If target is also domain admin, the amdin is restarted in debug mode.
235 * All diagnostic should be communicated through ServerProgres with no exceptions thrown.
236 * @param target the target server
237 * @return ServerProgress object to monitor progress on start operation
238 */
239 public abstract ProgressObject startDebugging(Target target);
240
241 /**
242 * Start the target in profile mode, null target implies the admin server.
243 *
244 * @param target the target server in question, null target implies
245 * the admin server.
246 * @param settings profiler server settings.
247 *
248 * @return ServerProgress object to monitor progress on start operation.
249 *
250 * @since 1.9
251 */
252 public ProgressObject startProfiling(Target target,
253 ProfilerServerSettings settings) {
254 throw new UnsupportedOperationException(
255 "Starting in profile mode is not supported by this server."); // NIO18N
256 }
257
258 /**
259 * Returns the host/port necessary for connecting to the server's debug information.
260 */
261 public abstract ServerDebugInfo getDebugInfo(Target target);
262
263 /**
264 * Returns true if target server needs a restart for last configuration changes to
265 * take effect. Implementation should override when communication about this
266 * server state is needed.
267 *
268 * @param target target server; null implies the case where target is also admin server.
269 */
270 public boolean needsRestart(Target target) {
271 return false;
272 }
273 }
|