KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > enterprise > deploy > spi > JBoss30DeploymentManager


1 package org.jboss.enterprise.deploy.spi;
2
3 import java.io.File JavaDoc;
4 import java.io.InputStream JavaDoc;
5 import java.util.Locale JavaDoc;
6 import javax.enterprise.deploy.model.DeployableObject JavaDoc;
7 import javax.enterprise.deploy.shared.DConfigBeanVersionType JavaDoc;
8 import javax.enterprise.deploy.spi.*;
9 import javax.enterprise.deploy.spi.exceptions.*;
10 import javax.enterprise.deploy.spi.status.*;
11
12 /**
13  * The DeploymentManager object provides the core set of functions a J2EE platform must provide for J2EE application deployment. It provides server related
14  * information, such as, a list of deployment targets, and vendor unique runtime configuration information.
15  *
16  * @author laurent
17  * @created 31 mars 2002
18  */

19 public class JBoss30DeploymentManager implements DeploymentManager
20 {
21    /** Description of the Field */
22    protected boolean connected;
23    /** Description of the Field */
24    protected Locale JavaDoc currentLocale;
25    /** Description of the Field */
26    protected Locale JavaDoc[] supportedLocale = new Locale JavaDoc[]{
27          new Locale JavaDoc("en", "UK"),
28          new Locale JavaDoc("fr", "FR")
29          };
30    /** Description of the Field */
31    protected DConfigBeanVersionType JavaDoc versionType = DConfigBeanVersionType.V1_3_1;
32
33
34    /**
35     * Constructor for the DeploymentManagerImpl object
36     *
37     * @param uri Description of Parameter
38     */

39    public JBoss30DeploymentManager(String JavaDoc uri)
40    {
41       // Assumes it is disconnected
42
connected = false;
43    }
44
45
46    /**
47     * Constructor for the DeploymentManagerImpl object
48     *
49     * @param uri Description of Parameter
50     * @param username Description of Parameter
51     * @param password Description of Parameter
52     */

53    public JBoss30DeploymentManager(String JavaDoc uri, String JavaDoc username, String JavaDoc password)
54    {
55       // Assumes it is connected
56
connected = true;
57    }
58
59
60    /**
61     * Retrieve the object that provides server-specific deployment configuration information for the J2EE deployable component.
62     *
63     * @param dObj An object representing a J2EE deployable component.
64     * @return Description of the Returned Value
65     * @throws InvalidModuleException The DeployableObject is an unknown or unsupport component for this configuration tool.
66     */

67    public DeploymentConfiguration createConfiguration(DeployableObject JavaDoc dObj) throws InvalidModuleException
68    {
69       return null;
70    }
71
72
73    /**
74     * The distribute method performs three tasks; it validates the deployment configuration data, generates all container specific classes and interfaces, and
75     * moves the fully baked archive to the designated deployment targets.
76     *
77     * @param targetList A list of server targets the user is specifying this application be deployed to.
78     * @param moduleArchive The file name of the application archive to be disrtibuted.
79     * @param deploymentPlan The XML file containing the runtime configuration information associated with this application archive.
80     * @return ProgressObject an object that tracks and reports the status of the distribution process.
81     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
82     */

83    public ProgressObject distribute(Target[] targetList, File JavaDoc moduleArchive, File JavaDoc deploymentPlan) throws IllegalStateException JavaDoc
84    {
85       if (!connected)
86       {
87          throw new IllegalStateException JavaDoc("Illegal access to distribute");
88       }
89
90       return null;
91    }
92
93
94    /**
95     * The distribute method performs three tasks; it validates the deployment configuration data, generates all container specific classes and interfaces, and
96     * moves the fully baked archive to the designated deployment targets.
97     *
98     * @param targetList A list of server targets the user is specifying this application be deployed to.
99     * @param moduleArchive The input stream containing the application archive to be disrtibuted.
100     * @param deploymentPlan The input stream containing the deployment configuration information associated with this application archive.
101     * @return ProgressObject an object that tracks and reports the status of the distribution process.
102     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
103     */

104
105    public ProgressObject distribute(Target[] targetList, InputStream JavaDoc moduleArchive, InputStream JavaDoc deploymentPlan) throws IllegalStateException JavaDoc
106    {
107       if (!connected)
108       {
109          throw new IllegalStateException JavaDoc("Illegal access to distribute");
110       }
111
112       return null;
113    }
114
115
116    /**
117     * Retrieve the list of all J2EE application modules running or not running on the identified targets.
118     *
119     * @param moduleType A predefined designator for a J2EE module type.
120     * @param targetList A list of deployment Target designators the user wants checked for module not running status.
121     * @return An array of TargetModuleID objects representing all deployed modules running or not or 'null' if there are no deployed
122     * modules.
123     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
124     * @throws TargetException An invalid Target designator encountered.
125     */

126    public TargetModuleID[] getAvailableModules(int moduleType, Target[] targetList) throws TargetException, IllegalStateException JavaDoc
127    {
128       if (!connected)
129       {
130          throw new IllegalStateException JavaDoc("Illegal access to getAvailableModules");
131       }
132
133       // TODO
134
// Use JSR77 connection to get the target module ID
135

136       return null;
137    }
138
139
140    /**
141     * Returns the active locale this implementation of javax.enterprise.deploy.spi subpackages is running.
142     *
143     * @return Locale the active locale of this implementation.
144     */

145    public Locale JavaDoc getCurrentLocale()
146    {
147       return currentLocale;
148    }
149
150
151    /**
152     * Returns the J2EE platform version number for which the configuration beans are provided. The beans must have been compiled with the J2SE version required
153     * by the J2EE platform.
154     *
155     * @return a DConfigBeanVersionType object representing the platform version number for which these beans are provided.
156     */

157    public DConfigBeanVersionType JavaDoc getDConfigBeanVersion()
158    {
159       return versionType;
160    }
161
162
163    /**
164     * Returns the default locale supported by this implementation of javax.enterprise.deploy.spi subpackages.
165     *
166     * @return Locale the default locale for this implementation.
167     */

168    public Locale JavaDoc getDefaultLocale()
169    {
170       return supportedLocale[0];
171    }
172
173
174    /**
175     * Retrieve the list of J2EE application modules distributed to the identified targets and that are currently not running on the associated server or
176     * servers.
177     *
178     * @param moduleType A predefined designator for a J2EE module type.
179     * @param targetList A list of deployment Target designators the user wants checked for module not running status.
180     * @return An array of TargetModuleID objects representing the non-running modules or 'null' if there are none.
181     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
182     * @throws TargetException An invalid Target designator encountered.
183     */

184    public TargetModuleID[] getNonRunningModules(int moduleType, Target[] targetList) throws TargetException, IllegalStateException JavaDoc
185    {
186       if (!connected)
187       {
188          throw new IllegalStateException JavaDoc("Illegal access to getNonRunningModules");
189       }
190
191       // TODO
192
// Use JSR77 connection to get the target module ID
193

194       return null;
195    }
196
197
198    /**
199     * Retrieve the list of J2EE application modules distributed to the identified targets and that are currently running on the associated server or servers.
200     *
201     * @param moduleType A predefined designator for a J2EE module type.
202     * @param targetList A list of deployment Target designators the user wants checked for module run status.
203     * @return An array of TargetModuleID objects representing the running modules or 'null' if there are none.
204     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
205     * @throws TargetException An invalid Target designator encountered.
206     */

207    public TargetModuleID[] getRunningModules(int moduleType, Target[] targetList) throws TargetException, IllegalStateException JavaDoc
208    {
209       if (!connected)
210       {
211          throw new IllegalStateException JavaDoc("Illegal access to getRunningModules");
212       }
213
214       // TODO
215
// Use JSR77 connection to get the target module ID
216

217       return null;
218    }
219
220
221    /**
222     * Returns an array of supported locales for this implementation.
223     *
224     * @return Locale[] the list of supported locales.
225     */

226    public Locale JavaDoc[] getSupportedLocales()
227    {
228       return supportedLocale;
229    }
230
231
232    /**
233     * Retrieve the list of deployment targets supported by this DeploymentManager.
234     *
235     * @return A list of deployment Target designators the user may select for application deployment or 'null' if there are none.
236     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
237     */

238    public Target[] getTargets() throws IllegalStateException JavaDoc
239    {
240       if (!connected)
241       {
242          throw new IllegalStateException JavaDoc("Illegal access to getTargets");
243       }
244
245       // TODO
246
// Use JSR77 connection to get the targets
247

248       return null;
249    }
250
251
252    /**
253     * Returns 'true' if the configuration beans support the J2EE platform version specified. It returns 'false' if the version is not supported.
254     *
255     * @param version a DConfigBeanVersionType object representing the J2EE platform version for which support is requested.
256     * @return 'true' if the version is supported and 'false if not.
257     */

258    public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType JavaDoc version)
259    {
260       return true;
261    }
262
263
264    /**
265     * Reports if this implementation supports the designated locale.
266     *
267     * @param locale Description of Parameter
268     * @return A value of 'true' means it is support and 'false' it is not.
269     */

270    public boolean isLocaleSupported(Locale JavaDoc locale)
271    {
272       for (int i = 0; i < supportedLocale.length; i++)
273       {
274          if (supportedLocale[i].equals(locale))
275          {
276             return true;
277          }
278       }
279       return true;
280    }
281
282
283    /**
284     * This method designates whether this platform vendor provides application redeployment functionality. A value of true means it is supported. False means it
285     * is not.
286     *
287     * @return A value of true means redeployment is supported by this vendor's DeploymentManager. False means it is not.
288     */

289    public boolean isRedeploySupported()
290    {
291       return true;
292    }
293
294
295    /**
296     * (optional) The redeploy method provides a means for updating currently deployed J2EE applications. This is an optional method for vendor implementation.
297     * Redeploy replaces a currently deployed application with an updated version. The runtime configuration information for the updated application must remain
298     * identical to the application it is updating. When an application update is redeployed, all existing client connections to the original running application
299     * must not be disrupted; new clients will connect to the application update. This operation is valid for TargetModuleIDs that represent a root module. A
300     * root TargetModuleID has no parent. A root TargetModuleID module and all its child modules will be redeployed. A child TargetModuleID module cannot be
301     * individually redeployed. The redeploy operation is complete only when this action for all the modules has completed.
302     *
303     * @param moduleIDList An array of designators of the applications to be updated.
304     * @param moduleArchive The file name of the application archive to be disrtibuted.
305     * @param deploymentPlan The deployment configuration information associated with this application archive.
306     * @return ProgressObject an object that tracks and reports the status of the redeploy operation.
307     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
308     * @throws UnsupportedOperationException this optional command is not supported by this implementation.
309     */

310
311    public ProgressObject redeploy(TargetModuleID[] moduleIDList, File JavaDoc moduleArchive, File JavaDoc deploymentPlan) throws UnsupportedOperationException JavaDoc, IllegalStateException JavaDoc
312    {
313       if (!connected)
314       {
315          throw new IllegalStateException JavaDoc("Illegal access to redeploy");
316       }
317       if (!isRedeploySupported())
318       {
319          throw new UnsupportedOperationException JavaDoc("Redeploy is not supported");
320       }
321
322       return null;
323    }
324
325
326    /**
327     * (optional) The redeploy method provides a means for updating currently deployed J2EE applications. This is an optional method for vendor implementation.
328     * Redeploy replaces a currently deployed application with an updated version. The runtime configuration information for the updated application must remain
329     * identical to the application it is updating. When an application update is redeployed, all existing client connections to the original running application
330     * must not be disrupted; new clients will connect to the application update. This operation is valid for TargetModuleIDs that represent a root module. A
331     * root TargetModuleID has no parent. A root TargetModuleID module and all its child modules will be redeployed. A child TargetModuleID module cannot be
332     * individually redeployed. The redeploy operation is complete only when this action for all the modules has completed.
333     *
334     * @param moduleIDList An array of designators of the applications to be updated.
335     * @param moduleArchive The input stream containing the application archive to be disrtibuted.
336     * @param deploymentPlan The input stream containing the runtime configuration information associated with this application archive.
337     * @return ProgressObject an object that tracks and reports the status of the redeploy operation.
338     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
339     * @throws UnsupportedOperationException this optional command is not supported by this implementation.
340     */

341    public ProgressObject redeploy(TargetModuleID[] moduleIDList, InputStream JavaDoc moduleArchive, InputStream JavaDoc deploymentPlan) throws UnsupportedOperationException JavaDoc, IllegalStateException JavaDoc
342    {
343       if (!connected)
344       {
345          throw new IllegalStateException JavaDoc("Illegal access to redeploy");
346       }
347       if (!isRedeploySupported())
348       {
349          throw new UnsupportedOperationException JavaDoc("Redeploy is not supported");
350       }
351
352       return null;
353    }
354
355
356
357    /**
358     * The release method is the mechanism by which the tool signals to the DeploymentManager that the tool does not need it to continue running connected to the
359     * platform. The tool may be signaling it wants to run in a disconnected mode or it is planning to shutdown. When release is called the DeploymentManager may
360     * close any J2EE resource connections it had for deployment configuration and perform other related resource cleanup. It should not accept any new operation
361     * requests (i.e., distribute, start stop, undeploy, redeploy. It should finish any operations that are currently in process. Each ProgressObject associated
362     * with a running operation should be marked as released (see the ProgressObject).
363     */

364    public void release()
365    {
366       if (connected)
367       {
368          // TODO
369
// Perfoms some disconnection
370
connected = false;
371       }
372    }
373
374
375    /**
376     * Set the configuration beans to be used to the J2EE platform version specificed.
377     *
378     * @param version a DConfigBeanVersionType object representing the J2EE platform version for which support is requested.
379     * @throws DConfigBeanVersionUnsupportedException when the requested bean version is not supported.
380     */

381    public void setDConfigBeanVersion(DConfigBeanVersionType JavaDoc version) throws DConfigBeanVersionUnsupportedException
382    {
383       if (false)
384       {
385          throw new DConfigBeanVersionUnsupportedException("");
386       }
387       versionType = version;
388    }
389
390
391    /**
392     * Set the active locale for this implementation of javax.enterprise.deploy.spi subpackages to run.
393     *
394     * @param locale The new value
395     * @throws UnsupportedOperationException the provide locale is not supported.
396     */

397    public void setLocale(Locale JavaDoc locale) throws UnsupportedOperationException JavaDoc
398    {
399       if (isLocaleSupported(locale))
400       {
401          currentLocale = locale;
402       }
403    }
404
405
406    /**
407     * Start the application running. <p>
408     *
409     * Only the TargetModuleIDs which represent a root module are valid for being started. A root TargetModuleID has no parent. A TargetModuleID with a parent
410     * can not be individually started. A root TargetModuleID module and all its child modules will be started.
411     *
412     * @param moduleIDList A array of TargetModuleID objects representing the modules to be started.
413     * @return ProgressObject an object that tracks and reports the status of the start operation.
414     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
415     */

416
417    public ProgressObject start(TargetModuleID[] moduleIDList) throws IllegalStateException JavaDoc
418    {
419       if (!connected)
420       {
421          throw new IllegalStateException JavaDoc("Illegal access to start");
422       }
423
424       return null;
425    }
426
427
428    /**
429     * Stop the application running. <p>
430     *
431     * Only the TargetModuleIDs which represent a root module are valid for being stopped. A root TargetModuleID has no parent. A TargetModuleID with a parent
432     * can not be individually stopped. A root TargetModuleID module and all its child modules will be stopped.
433     *
434     * @param moduleIDList A array of TargetModuleID objects representing the modules to be stopped.
435     * @return ProgressObject an object that tracks and reports the status of the stop operation.
436     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
437     */

438    public ProgressObject stop(TargetModuleID[] moduleIDList) throws IllegalStateException JavaDoc
439    {
440       if (!connected)
441       {
442          throw new IllegalStateException JavaDoc("Illegal access to stop");
443       }
444
445       return null;
446    }
447
448
449    /**
450     * Remove the application from the target server. <p>
451     *
452     * Only the TargetModuleIDs which represent a root module are valid for undeployment. A root TargetModuleID has no parent. A TargetModuleID with a parent can
453     * not be undeployed. A root TargetModuleID module and all its child modules will be undeployed. The root TargetModuleID module and all its child modules
454     * must stopped before they can be undeployed.
455     *
456     * @param moduleIDList An array of TargetModuleID objects representing the root modules to be stopped.
457     * @return ProgressObject an object that tracks and reports the status of the stop operation.
458     * @throws IllegalStateException is thrown when the method is called when running in disconnected mode.
459     */

460    public ProgressObject undeploy(TargetModuleID[] moduleIDList) throws IllegalStateException JavaDoc
461    {
462       if (!connected)
463       {
464          throw new IllegalStateException JavaDoc("Illegal access to undeploy");
465       }
466
467       return null;
468    }
469 }
470
471
Popular Tags