KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > deployment > plugins > api > StartServer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20
21 package org.netbeans.modules.j2ee.deployment.plugins.api;
22
23 import javax.enterprise.deploy.spi.Target JavaDoc;
24 import javax.enterprise.deploy.spi.status.ProgressObject JavaDoc;
25 import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
26
27 /**
28  * Server lifecycle services from the IDE. J2eeserver will use these
29  * services to automatically start or stop admin server and managed (virtual)
30  * target servers (in debug mode) during deployment or debugging execution.
31  *
32  * @see OptionalDeploymentManagerFactory
33  * @author George FinKlang
34  * @author nn136682
35  * @version 1.0
36  */

37 public abstract class StartServer {
38     
39     /**
40      * Returns true if the admin server is also the given target server (share the same vm).
41      * Start/stopping/debug apply to both servers. When the given target server is null,
42      * service should return true when admin server is also some target.
43      * @param target the target server in question; could be null.
44      * @return true when admin is also target server
45      */

46     public abstract boolean isAlsoTargetServer(Target JavaDoc target);
47     
48     /**
49      * Returns true if the admin server can be started through this spi.
50      */

51     public abstract boolean supportsStartDeploymentManager();
52     
53     /**
54      * Returns if the plugin can start/stop single target servers.
55      * This should be overwritten as needed.
56      * @param target the target server in question, could be null in which
57      * case the answer should probably be false.
58      * @return true if this plugin can currently handle state management for
59      * the specific target.
60      * @since 1.6
61      */

62     public boolean supportsStartTarget(Target JavaDoc target) {
63         return false;
64     }
65     
66     /**
67      * Can be the specified target server started in the debug mode? If the
68      * target is also an admin server can be the admin server started in the
69      * debug mode?
70      *
71      * @param target the target server in question, null implies the case where
72      * target is also an admin server.
73      *
74      * @return true if the target server can be started in the debug mode, false
75      * otherwise. The default return value is false.
76      *
77      * @since 1.7
78      */

79     public boolean supportsStartDebugging(Target JavaDoc target) {
80        return false;
81     }
82     
83     /**
84      * Can be the specified target server started in profile mode? If the
85      * target is also an admin server can be the admin server started in
86      * profile mode?
87      *
88      * @param target the target server in question, null implies the case where
89      * target is also an admin server.
90      *
91      * @return true if the target server can be started in profile mode, false
92      * otherwise. The default return value is false.
93      *
94      * @since 1.9
95      */

96     public boolean supportsStartProfiling(Target JavaDoc target) {
97         return false;
98     }
99     
100     /**
101      * Starts the admin server. Note that this means that the DeploymentManager
102      * was originally created disconnected. After calling this, the DeploymentManager
103      * will be connected, so any old cached DeploymentManager will be discarded.
104      * All diagnostics should be communicated through ProgressObject without exceptions thrown.
105      *
106      * @return ProgressObject object used to monitor start server progress
107      */

108     public abstract ProgressObject JavaDoc startDeploymentManager();
109     
110     /**
111      * Stops the admin server. The DeploymentManager object will be disconnected.
112      * All diagnostic should be communicated through ServerProgres with no
113      * exceptions thrown.
114      * @return ServerProgress object used to monitor start server progress
115      */

116     public abstract ProgressObject JavaDoc stopDeploymentManager();
117     
118     /** Optional method. This implementation does nothing.
119      *
120      * Stops the admin server. The DeploymentManager object will be disconnected.
121      * The call should terminate immediately and not wait for the server to stop.
122      * <div class="nonnormative">
123      * This will be used at IDE shutdown so that the server shutdown does not block the IDE.
124      * </div>
125      */

126     public void stopDeploymentManagerSilently() {
127         //do nothing
128
}
129     
130     /** See {@link stopDeploymentManagerSilently}
131      * @return override and return true if stopDeploymentManagerSilently is implemented
132      */

133     public boolean canStopDeploymentManagerSilently () {
134        return false;
135     }
136     
137     /**
138      * Returns true if the admin server should be started before server deployment configuration.
139      */

140     public abstract boolean needsStartForConfigure();
141     
142     /**
143      * Returns true if the admin server should be started before asking for
144      * target list.
145      */

146     public abstract boolean needsStartForTargetList();
147     
148     /**
149      * Returns true if the admin server should be started before admininistrative configuration.
150      */

151     public abstract boolean needsStartForAdminConfig();
152     
153     /**
154      * Returns true if this admin server is running.
155      */

156     public abstract boolean isRunning();
157     
158     /**
159      * Returns the running state of a specific target. This should be
160      * overwritten by plugins which support multiple target servers via
161      * one admin server.
162      * @param target the target server in question; null value implies
163      * the query is against the admin server.
164      * @return true if the server is question is running.
165      * @since 1.6
166      */

167     public boolean isRunning(Target JavaDoc target) {
168         if (target == null || isAlsoTargetServer(target)) {
169             return isRunning();
170         }
171         
172         return false;
173     }
174     
175     /**
176      * Returns true if the given target is in debug mode.
177      */

178     public abstract boolean isDebuggable(Target JavaDoc target);
179     
180     /**
181      * Starts the target server asynchronously and reports the status
182      * through the returned <code>ProgressObject</code>. This should be
183      * overwritten by plugins which support the state management of
184      * different target servers.
185      * @param target a non-null target server to be started
186      * @return a ProgressObject which is used to communicate the
187      * progess/state of this action. Should not be null when supportsStartTarget
188      * returns true on same target.
189      * @since 1.6
190      */

191     public ProgressObject JavaDoc startTarget(Target JavaDoc target) {
192         return null;
193     }
194     
195     /**
196      * Stops the target server asynchronously and reports the status
197      * through the returned <code>ProgressObject</code>. This should be
198      * overwritten by plugins which support the state management of
199      * different target servers.
200      * @param target a non-null target server to be stopped
201      * @return a ProgressObject which is used to communicate the
202      * progess/state of this action. Should not be null when supportsStartTarget
203      * return true on the same target.
204      * @since 1.6
205      */

206     public ProgressObject JavaDoc stopTarget(Target JavaDoc target) {
207         return null;
208     }
209
210     /**
211      * Start or restart the target in debug mode.
212      * If target is also domain admin, the amdin is restarted in debug mode.
213      * All diagnostic should be communicated through ServerProgres with no exceptions thrown.
214      * @param target the target server
215      * @return ServerProgress object to monitor progress on start operation
216      */

217     public abstract ProgressObject JavaDoc startDebugging(Target JavaDoc target);
218     
219     /**
220      * Start the target in profile mode, null target implies the admin server.
221      *
222      * @param target the target server in question, null target implies
223      * the admin server.
224      * @param settings profiler server settings.
225      *
226      * @return ServerProgress object to monitor progress on start operation.
227      *
228      * @since 1.9
229      */

230     public ProgressObject JavaDoc startProfiling(Target JavaDoc target, ProfilerServerSettings settings) {
231         throw new UnsupportedOperationException JavaDoc("Starting in profile mode is not supported by this server."); // NIO18N
232
}
233     
234     /**
235      * Returns the host/port necessary for connecting to the server's debug information.
236      */

237     public abstract ServerDebugInfo getDebugInfo(Target JavaDoc target);
238     
239     /**
240      * Returns true if target server needs a restart for last configuration changes to
241      * take effect. Implementation should override when communication about this
242      * server state is needed.
243      *
244      * @param target target server; null implies the case where target is also admin server.
245      */

246     public boolean needsRestart(Target JavaDoc target) {
247          return false;
248     }
249 }
250
Popular Tags