001: /*
002: * CoadunationLib: The coaduntion implementation library.
003: * Copyright (C) 2007 Rift IT Contracting
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
018: *
019: * DeploymentMonitor.java
020: */
021:
022: package com.rift.coad.lib.deployment;
023:
024: /**
025: * This object is responsible for supplying information about the deployment
026: * process.
027: *
028: * @author Brett Chaldecott
029: */
030: public class DeploymentMonitor {
031:
032: // class singleton
033: private static DeploymentMonitor singleton = null;
034:
035: // private member variables
036: private boolean initDeployComplete = false;
037: private boolean terminated = false;
038:
039: /**
040: * Creates a new instance of DeploymentMonitor
041: */
042: private DeploymentMonitor() {
043: }
044:
045: /**
046: * This method returns the instance of the DeploymentMonitor.
047: */
048: public static synchronized DeploymentMonitor getInstance() {
049: if (singleton == null) {
050: singleton = new DeploymentMonitor();
051: }
052: return singleton;
053: }
054:
055: /**
056: * This method returns true if the initial deploy is complete and false if
057: * it is not.
058: *
059: * @return TRUE if initial deploy complete, FALSE if not.
060: */
061: public synchronized boolean isInitDeployComplete() {
062: return initDeployComplete;
063: }
064:
065: /**
066: * This method will mark the initial deploy as completed.
067: */
068: public synchronized void initDeployCompleted() {
069: initDeployComplete = true;
070: notify();
071: }
072:
073: /**
074: * This method is called to check if the deployment process is terminated.
075: */
076: public synchronized boolean isTerminated() {
077: return terminated;
078: }
079:
080: /**
081: * This method terminates the deployment process.
082: */
083: public synchronized void terminate() {
084: terminated = true;
085: notify();
086: }
087:
088: /**
089: * This method when called will wait until the deployment process is
090: * complete.
091: */
092: public synchronized void waitUntilInitDeployComplete() {
093: try {
094: if (!initDeployComplete && !terminated) {
095: wait();
096: }
097: } catch (Exception ex) {
098: // ignore
099: }
100: }
101: }
|