KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > deployment > DeploymentMonitor


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2007 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * DeploymentMonitor.java
20  */

21
22 package com.rift.coad.lib.deployment;
23
24 /**
25  * This object is responsible for supplying information about the deployment
26  * process.
27  *
28  * @author Brett Chaldecott
29  */

30 public class DeploymentMonitor {
31     
32     // class singleton
33
private static DeploymentMonitor singleton = null;
34     
35     // private member variables
36
private boolean initDeployComplete = false;
37     private boolean terminated = false;
38     
39     /**
40      * Creates a new instance of DeploymentMonitor
41      */

42     private DeploymentMonitor() {
43     }
44     
45     
46     /**
47      * This method returns the instance of the DeploymentMonitor.
48      */

49     public static synchronized DeploymentMonitor getInstance() {
50         if (singleton == null) {
51             singleton = new DeploymentMonitor();
52         }
53         return singleton;
54     }
55     
56     
57     /**
58      * This method returns true if the initial deploy is complete and false if
59      * it is not.
60      *
61      * @return TRUE if initial deploy complete, FALSE if not.
62      */

63     public synchronized boolean isInitDeployComplete() {
64         return initDeployComplete;
65     }
66     
67     
68     /**
69      * This method will mark the initial deploy as completed.
70      */

71     public synchronized void initDeployCompleted() {
72         initDeployComplete = true;
73         notify();
74     }
75     
76     
77     /**
78      * This method is called to check if the deployment process is terminated.
79      */

80     public synchronized boolean isTerminated() {
81         return terminated;
82     }
83     
84     
85     /**
86      * This method terminates the deployment process.
87      */

88     public synchronized void terminate() {
89         terminated = true;
90         notify();
91     }
92     
93     
94     /**
95      * This method when called will wait until the deployment process is
96      * complete.
97      */

98     public synchronized void waitUntilInitDeployComplete() {
99         try {
100             if (!initDeployComplete && !terminated) {
101                 wait();
102             }
103         } catch (Exception JavaDoc ex) {
104             // ignore
105
}
106     }
107 }
108
Popular Tags