KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > common > UpdateProgressManager


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * UpdateProgressManager.java
26  *
27  * Created on February 12, 2004, 12:37 PM
28  */

29
30 package com.sun.enterprise.tools.upgrade.common ;
31
32 /**
33  *
34  * @author prakash
35  */

36
37 import java.util.*;
38
39 public class UpdateProgressManager {
40     
41     private java.util.Vector JavaDoc upgradeUpdateListeners = null;
42     private static UpdateProgressManager updateProgressManager = null;
43     
44     // In any event of errors this boolean will be set to false by any module.
45
// If this state is set to false, the upgrade process will be aborted.
46
// Currently UpgradeHarness checks to see if this state is GREEN
47
private boolean continueUpgrade = true;
48     
49     /** Creates a new instance of UpdateProgressManager */
50     private UpdateProgressManager() {
51         upgradeUpdateListeners = new java.util.Vector JavaDoc();
52     }
53     public static UpdateProgressManager getProgressManager(){
54         if(updateProgressManager == null)
55             updateProgressManager = new UpdateProgressManager();
56         return updateProgressManager;
57     }
58     public void addUpgradeUpdateListener(UpgradeUpdateListener listener){
59         this.upgradeUpdateListeners.addElement(listener);
60     }
61     public void removeUpgradeUpdateListener(UpgradeUpdateListener listener){
62         this.upgradeUpdateListeners.removeElement(listener);
63     }
64     /*
65      * This is needed to send back gui the finish action.
66      */

67     public void processUpgradeUpdateEvent(int progressState){
68         UpgradeUpdateEvent de = new UpgradeUpdateEvent(this, progressState);
69         de.setProgressState(progressState);
70         for(int i=0 ; i<this.upgradeUpdateListeners.size(); i++){
71             ((UpgradeUpdateListener)upgradeUpdateListeners.elementAt(i)).upgradeProcessUpdate(de);
72         }
73     }
74     public void setContinueUpgrade(boolean state){
75         this.continueUpgrade = state;
76     }
77     public boolean canContinueUpgrade(){
78         return this.continueUpgrade;
79     }
80     
81 }
82
Popular Tags