001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2006 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: DeployAction.java 9393 2006-08-08 09:47:57Z durieuxp $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.management.monitoring;
025:
026: /**
027: * Action of deployment on a remote server
028: * Used by jonasAdmin to follow the progression of operations
029: * @author durieuxp
030: */
031: public class DeployAction {
032:
033: /**
034: * Current state of the operation
035: */
036: private int state = FAILED;
037: public static final int FAILED = -1;
038: public static final int SUCCESS = 0;
039: public static final int UPLOADING = 1;
040: public static final int DEPLOYING = 2;
041: public static final int UNDEPLOYING = 3;
042:
043: /**
044: * Error message when failed
045: */
046: private String errorMessage;
047:
048: private ServerProxy proxy;
049: private String filename;
050:
051: /**
052: * Deployment Action
053: */
054: private int action;
055: public static final int DEPLOY = 1;
056: public static final int UNDEPLOY = 2;
057: public static final int UPLOAD = 3;
058: public static final int UPLOADDEPLOY = 4;
059: public static final int START = 5;
060: public static final int STOP = 6;
061:
062: /**
063: * Constructor
064: */
065: public DeployAction(ServerProxy proxy, String filename, int action) {
066: this .proxy = proxy;
067: this .filename = filename;
068: this .action = action;
069: switch (action) {
070: case DEPLOY:
071: state = DEPLOYING;
072: break;
073: case UNDEPLOY:
074: state = UNDEPLOYING;
075: break;
076: case UPLOAD:
077: case UPLOADDEPLOY:
078: state = UPLOADING;
079: break;
080: }
081: }
082:
083: /**
084: * Action is successful
085: */
086: public void setOK() {
087: state = SUCCESS;
088: }
089:
090: /**
091: * Set state to Deploying
092: */
093: public void setDeploying() {
094: state = DEPLOYING;
095: }
096:
097: /**
098: * Action has failed
099: */
100: public void setError(String mess) {
101: state = FAILED;
102: errorMessage = mess;
103: }
104:
105: /**
106: * @return Current state of the action
107: */
108: public int getState() {
109: return state;
110: }
111:
112: /**
113: * @return Current state of the action (String form)
114: */
115: public String getStateAsString() {
116: switch (state) {
117: case FAILED:
118: return "FAILED :";
119: case SUCCESS:
120: return "SUCCESS";
121: case DEPLOYING:
122: return "IN PROGRESS : DEPLOY";
123: case UNDEPLOYING:
124: return "IN PROGRESS : UNDEPLOY";
125: case UPLOADING:
126: return "IN PROGRESS : UPLOAD";
127: }
128: return "error";
129: }
130:
131: /**
132: * @return The error message when failed
133: */
134: public String getErrorMessage() {
135: return errorMessage;
136: }
137:
138: /**
139: * @return The deployment action
140: */
141: public int getAction() {
142: return action;
143: }
144:
145: /**
146: * @return Filename used for deployment action
147: */
148: public String getFileName() {
149: return filename;
150: }
151:
152: /**
153: * @return servername
154: */
155: public String getServerName() {
156: return proxy.getName();
157: }
158:
159: }
|