001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.j2ee.deployclient;
030:
031: import javax.enterprise.deploy.shared.ActionType;
032: import javax.enterprise.deploy.shared.CommandType;
033: import javax.enterprise.deploy.shared.StateType;
034: import javax.enterprise.deploy.spi.status.DeploymentStatus;
035: import java.io.Serializable;
036:
037: /**
038: * Represents the status of a deployed module.
039: */
040: public class DeploymentStatusImpl implements DeploymentStatus,
041: Serializable {
042: public static final int RUNNING = 0;
043: public static final int COMPLETED = 1;
044: public static final int FAILED = 2;
045: public static final int RELEASED = 3;
046:
047: private String _message;
048: private int _state = RUNNING;
049:
050: /**
051: * Returns the StateType value.
052: */
053: public StateType getState() {
054: switch (_state) {
055: case RUNNING:
056: return StateType.RUNNING;
057: case COMPLETED:
058: return StateType.COMPLETED;
059: case FAILED:
060: return StateType.FAILED;
061: case RELEASED:
062: return StateType.RELEASED;
063: default:
064: return StateType.FAILED;
065: }
066: }
067:
068: public void setState(StateType stateType) {
069: if (stateType == StateType.RUNNING)
070: _state = RUNNING;
071: else if (stateType == StateType.COMPLETED)
072: _state = COMPLETED;
073: else if (stateType == StateType.FAILED)
074: _state = FAILED;
075: else if (stateType == StateType.RELEASED)
076: _state = RELEASED;
077: else
078: throw new AssertionError(stateType);
079: }
080:
081: /**
082: * Returns the CommandType value.
083: */
084: public CommandType getCommand() {
085: return CommandType.DISTRIBUTE;
086: }
087:
088: /**
089: * Returns the ActionType value.
090: */
091: public ActionType getAction() {
092: return ActionType.EXECUTE;
093: }
094:
095: /**
096: * Returns additional information.
097: */
098: public String getMessage() {
099: return _message;
100: }
101:
102: /**
103: * Sets the message.
104: */
105: public void setMessage(String message) {
106: _message = message;
107: }
108:
109: /**
110: * Returns true if the deployment is completed.
111: */
112: public boolean isCompleted() {
113: return _state == COMPLETED;
114: }
115:
116: /**
117: * Returns true if the deployment is failed.
118: */
119: public boolean isFailed() {
120: return _state == FAILED;
121: }
122:
123: /**
124: * Returns true if the deployment is running.
125: */
126: public boolean isRunning() {
127: return _state == RUNNING;
128: }
129:
130: public String toString() {
131: return "DeploymentStatusImpl[" + getState() + ","
132: + getMessage() + "]";
133: }
134: }
|