KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > j2ee > deployclient > DeploymentStatusImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.j2ee.deployclient;
30
31 import javax.enterprise.deploy.shared.ActionType JavaDoc;
32 import javax.enterprise.deploy.shared.CommandType JavaDoc;
33 import javax.enterprise.deploy.shared.StateType JavaDoc;
34 import javax.enterprise.deploy.spi.status.DeploymentStatus JavaDoc;
35 import java.io.Serializable JavaDoc;
36
37 /**
38  * Represents the status of a deployed module.
39  */

40 public class DeploymentStatusImpl implements DeploymentStatus JavaDoc, Serializable JavaDoc {
41   public static final int RUNNING = 0;
42   public static final int COMPLETED = 1;
43   public static final int FAILED = 2;
44   public static final int RELEASED = 3;
45
46   private String JavaDoc _message;
47   private int _state = RUNNING;
48
49   /**
50    * Returns the StateType value.
51    */

52   public StateType JavaDoc getState()
53   {
54     switch (_state) {
55       case RUNNING:
56         return StateType.RUNNING;
57       case COMPLETED:
58         return StateType.COMPLETED;
59       case FAILED:
60         return StateType.FAILED;
61       case RELEASED:
62         return StateType.RELEASED;
63       default:
64         return StateType.FAILED;
65     }
66   }
67
68   public void setState(StateType JavaDoc stateType)
69   {
70     if (stateType == StateType.RUNNING)
71       _state = RUNNING;
72     else if (stateType == StateType.COMPLETED)
73       _state = COMPLETED;
74     else if (stateType == StateType.FAILED)
75       _state = FAILED;
76     else if (stateType == StateType.RELEASED)
77       _state = RELEASED;
78     else throw new AssertionError JavaDoc(stateType);
79   }
80
81   /**
82    * Returns the CommandType value.
83    */

84   public CommandType JavaDoc getCommand()
85   {
86     return CommandType.DISTRIBUTE;
87   }
88
89   /**
90    * Returns the ActionType value.
91    */

92   public ActionType JavaDoc getAction()
93   {
94     return ActionType.EXECUTE;
95   }
96   
97   /**
98    * Returns additional information.
99    */

100   public String JavaDoc getMessage()
101   {
102     return _message;
103   }
104
105   /**
106    * Sets the message.
107    */

108   public void setMessage(String JavaDoc message)
109   {
110     _message = message;
111   }
112   
113   /**
114    * Returns true if the deployment is completed.
115    */

116   public boolean isCompleted()
117   {
118     return _state == COMPLETED;
119   }
120   
121   /**
122    * Returns true if the deployment is failed.
123    */

124   public boolean isFailed()
125   {
126     return _state == FAILED;
127   }
128
129   /**
130    * Returns true if the deployment is running.
131    */

132   public boolean isRunning()
133   {
134     return _state == RUNNING;
135   }
136
137   public String JavaDoc toString()
138   {
139     return "DeploymentStatusImpl[" + getState() + "," + getMessage() + "]";
140   }
141 }
142
143
Popular Tags