KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployment > spi > status > ProgressObjectImpl


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.deployment.spi.status;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import javax.enterprise.deploy.shared.StateType JavaDoc;
28 import javax.enterprise.deploy.spi.TargetModuleID JavaDoc;
29 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException JavaDoc;
30 import javax.enterprise.deploy.spi.status.ClientConfiguration JavaDoc;
31 import javax.enterprise.deploy.spi.status.DeploymentStatus JavaDoc;
32 import javax.enterprise.deploy.spi.status.ProgressEvent JavaDoc;
33 import javax.enterprise.deploy.spi.status.ProgressListener JavaDoc;
34 import javax.enterprise.deploy.spi.status.ProgressObject JavaDoc;
35
36 /**
37  * The ProgressObject interface tracks and reports the progress
38  * of the deployment activities, distribute, start, stop, undeploy.
39  *
40  * @author thomas.diesler@jboss.org
41  * @version $Revision: 38480 $
42  */

43 public class ProgressObjectImpl implements ProgressObject JavaDoc
44 {
45    // list of ProgressListener objects
46
private List JavaDoc listeners = new ArrayList JavaDoc();
47
48    private DeploymentStatusImpl deploymentStatus;
49    private TargetModuleID JavaDoc[] targetModules;
50
51    public ProgressObjectImpl(DeploymentStatus JavaDoc deploymentStatus, TargetModuleID JavaDoc[] targetModules)
52    {
53       this.deploymentStatus = (DeploymentStatusImpl)deploymentStatus;
54       this.targetModules = targetModules;
55    }
56
57    /**
58     * Set the current deployment status
59     */

60    public void sendProgressEvent(StateType JavaDoc stateType, String JavaDoc message, TargetModuleID JavaDoc moduleID)
61    {
62       deploymentStatus.setStateType(stateType);
63       deploymentStatus.setMessage(message);
64       ProgressEvent JavaDoc progressEvent = new ProgressEvent JavaDoc(this, moduleID, deploymentStatus);
65       for (int i = 0; i < listeners.size(); i++)
66       {
67          ProgressListener JavaDoc progressListener = (ProgressListener JavaDoc)listeners.get(i);
68          progressListener.handleProgressEvent(progressEvent);
69       }
70    }
71
72    /**
73     * Retrieve the status of the deployment
74     *
75     * @return the status
76     */

77    public DeploymentStatus JavaDoc getDeploymentStatus()
78    {
79       return deploymentStatus;
80    }
81
82    /**
83     * Retrieve the resulting target module ids
84     *
85     * @return the module ids
86     */

87    public TargetModuleID JavaDoc[] getResultTargetModuleIDs()
88    {
89       return targetModules;
90    }
91
92    /**
93     * Return the client configuration associated with the module
94     *
95     * @param id the module id
96     * @return the client configuration or null if none exists
97     */

98    public ClientConfiguration JavaDoc getClientConfiguration(TargetModuleID JavaDoc id)
99    {
100       return null; //[todo] implement method
101
}
102
103    /**
104     * Is cancel supported
105     *
106     * @return true when cancel is supported, false otherwise
107     */

108    public boolean isCancelSupported()
109    {
110       return false;
111    }
112
113    /**
114     * Cancels the deployment
115     *
116     * @throws javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException
117     * when cancel is not supported
118     */

119    public void cancel() throws OperationUnsupportedException JavaDoc
120    {
121       throw new OperationUnsupportedException JavaDoc("cancel not supported");
122    }
123
124    /**
125     * Is stop supported
126     *
127     * @return true when stop is supported, false otherwise
128     */

129    public boolean isStopSupported()
130    {
131       return false;
132    }
133
134    /**
135     * Stops the deployment
136     *
137     * @throws javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException
138     * when stop is not supported
139     */

140    public void stop() throws OperationUnsupportedException JavaDoc
141    {
142       throw new OperationUnsupportedException JavaDoc("stop not supported");
143    }
144
145    /**
146     * Add a progress listener
147     *
148     * @param listener the listener
149     */

150    public void addProgressListener(ProgressListener JavaDoc listener)
151    {
152       listeners.add(listener);
153    }
154
155    /**
156     * Remove a progress listener
157     *
158     * @param listener the listener
159     */

160    public void removeProgressListener(ProgressListener JavaDoc listener)
161    {
162       listeners.remove(listener);
163    }
164 }
165
Popular Tags