001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.deployment.spi.status;
023:
024: import javax.enterprise.deploy.shared.ActionType;
025: import javax.enterprise.deploy.shared.CommandType;
026: import javax.enterprise.deploy.shared.StateType;
027: import javax.enterprise.deploy.spi.status.DeploymentStatus;
028:
029: /**
030: * The DeploymentStatus interface provides information about the progress status of a deployment action.
031: *
032: * @author thomas.diesler@jboss.org
033: * @version $Revision: 62520 $
034: */
035: public class DeploymentStatusImpl implements DeploymentStatus {
036:
037: private StateType stateType;
038: private CommandType commandType;
039: private ActionType actionType;
040: private String message;
041:
042: public DeploymentStatusImpl(StateType stateType,
043: CommandType commandType, ActionType actionType,
044: String message) {
045: this .stateType = stateType;
046: this .commandType = commandType;
047: this .actionType = actionType;
048: this .message = message;
049: }
050:
051: /**
052: * Set the current deployment status
053: */
054: void setStateType(StateType stateType) {
055: this .stateType = stateType;
056: }
057:
058: /**
059: * Set the current deployment message
060: */
061: void setMessage(String message) {
062: this .message = message;
063: }
064:
065: /**
066: * Get the state of the deployment
067: *
068: * @return the state
069: */
070: public StateType getState() {
071: return stateType;
072: }
073:
074: /**
075: * The deployment command
076: *
077: * @return the command
078: */
079: public CommandType getCommand() {
080: return commandType;
081: }
082:
083: /**
084: * The action of this deployment
085: *
086: * @return the action
087: */
088: public ActionType getAction() {
089: return actionType;
090: }
091:
092: /**
093: * Get the message
094: *
095: * @return the message
096: */
097: public String getMessage() {
098: return message;
099: }
100:
101: /**
102: * Is the deployment complete
103: *
104: * @return true when complete, false otherwise
105: */
106: public boolean isCompleted() {
107: return stateType == StateType.COMPLETED;
108: }
109:
110: /**
111: * Has the deployment failed
112: *
113: * @return true when failed, false otherwise
114: */
115: public boolean isFailed() {
116: return stateType == StateType.FAILED;
117: }
118:
119: /**
120: * Is the deployment in progress
121: *
122: * @return true when in progress, false otherwise
123: */
124: public boolean isRunning() {
125: return stateType == StateType.RUNNING;
126: }
127:
128: public String toString() {
129: return "[ stateType=" + stateType + ", commandType="
130: + commandType + ", actionType=" + actionType
131: + ", message=" + message + " ]";
132: }
133: }
|