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: package com.caucho.server.admin;
029:
030: import javax.enterprise.deploy.spi.status.DeploymentStatus;
031: import javax.enterprise.deploy.shared.StateType;
032: import javax.enterprise.deploy.shared.CommandType;
033: import javax.enterprise.deploy.shared.ActionType;
034: import java.io.Serializable;
035:
036: /**
037: * Represents the status of a deployed module.
038: */
039: public class DeploymentStatusImpl implements DeploymentStatus,
040: Serializable {
041: public static final int RUNNING = 0;
042: public static final int COMPLETED = 1;
043: public static final int FAILED = 2;
044: public static final int RELEASED = 3;
045:
046: private String _message;
047: private int _state = RUNNING;
048:
049: /**
050: * Returns the StateType value.
051: */
052: public StateType getState() {
053: switch (_state) {
054: case RUNNING:
055: return StateType.RUNNING;
056: case COMPLETED:
057: return StateType.COMPLETED;
058: case FAILED:
059: return StateType.FAILED;
060: case RELEASED:
061: return StateType.RELEASED;
062: default:
063: return StateType.FAILED;
064: }
065: }
066:
067: public void setState(StateType stateType) {
068: if (stateType == StateType.RUNNING)
069: _state = RUNNING;
070: else if (stateType == StateType.COMPLETED)
071: _state = COMPLETED;
072: else if (stateType == StateType.FAILED)
073: _state = FAILED;
074: else if (stateType == StateType.RELEASED)
075: _state = RELEASED;
076: else
077: throw new AssertionError(stateType);
078: }
079:
080: /**
081: * Returns the CommandType value.
082: */
083: public CommandType getCommand() {
084: return CommandType.DISTRIBUTE;
085: }
086:
087: /**
088: * Returns the ActionType value.
089: */
090: public ActionType getAction() {
091: return ActionType.EXECUTE;
092: }
093:
094: /**
095: * Returns additional information.
096: */
097: public String getMessage() {
098: return _message;
099: }
100:
101: /**
102: * Sets the message.
103: */
104: public void setMessage(String message) {
105: _message = message;
106: }
107:
108: /**
109: * Returns true if the deployment is completed.
110: */
111: public boolean isCompleted() {
112: return _state == COMPLETED;
113: }
114:
115: /**
116: * Returns true if the deployment is failed.
117: */
118: public boolean isFailed() {
119: return _state == FAILED;
120: }
121:
122: /**
123: * Returns true if the deployment is running.
124: */
125: public boolean isRunning() {
126: return _state == RUNNING;
127: }
128:
129: public String toString() {
130: return "DeploymentStatusImpl[" + getState() + ","
131: + getMessage() + "]";
132: }
133: }
|