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;
023:
024: import java.io.ObjectStreamException;
025: import java.io.Serializable;
026:
027: /**
028: * A type-safe enumeration for the status a DeploymentInfo may be in
029: *
030: * @author Scott.Stark@jboss.org
031: * @version $Revision: 57205 $
032: */
033: public class DeploymentState implements Serializable {
034: /** @since 4.0.2 */
035: private static final long serialVersionUID = -2319062412502366783L;
036:
037: public static final DeploymentState CONSTRUCTED = new DeploymentState(
038: "CONSTRUCTED");
039: public static final DeploymentState INIT_WAITING_DEPLOYER = new DeploymentState(
040: "INIT_WAITING_DEPLOYER");
041: public static final DeploymentState INIT_HAS_DEPLOYER = new DeploymentState(
042: "INIT_HAS_DEPLOYER");
043: public static final DeploymentState INIT_DEPLOYER = new DeploymentState(
044: "INIT_DEPLOYER");
045: public static final DeploymentState INITIALIZED = new DeploymentState(
046: "INITIALIZED");
047:
048: public static final DeploymentState CREATE_SUBDEPLOYMENTS = new DeploymentState(
049: "CREATE_SUBDEPLOYMENTS");
050: public static final DeploymentState CREATE_DEPLOYER = new DeploymentState(
051: "CREATE_DEPLOYER");
052: public static final DeploymentState CREATED = new DeploymentState(
053: "CREATED");
054:
055: public static final DeploymentState START_SUBDEPLOYMENTS = new DeploymentState(
056: "START_SUBDEPLOYMENTS");
057: public static final DeploymentState START_DEPLOYER = new DeploymentState(
058: "START_DEPLOYER");
059: public static final DeploymentState STARTED = new DeploymentState(
060: "STARTED");
061:
062: public static final DeploymentState STOPPED = new DeploymentState(
063: "STOPPED");
064: public static final DeploymentState DESTROYED = new DeploymentState(
065: "DESTROYED");
066: public static final DeploymentState FAILED = new DeploymentState(
067: "FAILED");
068:
069: private String state;
070:
071: /** Private CTOR to disable direct object construction
072: */
073: private DeploymentState(String state) {
074: this .state = state;
075: }
076:
077: /** A factory to translate a string into the corresponding DeploymentState.
078: */
079: public static DeploymentState getDeploymentState(String state) {
080: DeploymentState theState = null;
081: state = state.toUpperCase();
082: if (state.equals("CONSTRUCTED"))
083: theState = CONSTRUCTED;
084: else if (state.equals("INIT_WAITING_DEPLOYER"))
085: theState = INIT_WAITING_DEPLOYER;
086: else if (state.equals("INIT_HAS_DEPLOYER"))
087: theState = INIT_HAS_DEPLOYER;
088: else if (state.equals("INIT_DEPLOYER"))
089: theState = INIT_DEPLOYER;
090: else if (state.equals("INITIALIZED"))
091: theState = INITIALIZED;
092: else if (state.equals("CREATE_SUBDEPLOYMENTS"))
093: theState = CREATE_SUBDEPLOYMENTS;
094: else if (state.equals("CREATE_DEPLOYER"))
095: theState = CREATE_DEPLOYER;
096: else if (state.equals("CREATED"))
097: theState = CREATED;
098: else if (state.equals("START_SUBDEPLOYMENTS"))
099: theState = START_SUBDEPLOYMENTS;
100: else if (state.equals("START_DEPLOYER"))
101: theState = START_DEPLOYER;
102: else if (state.equals("STARTED"))
103: theState = STARTED;
104: else if (state.equals("STOPPED"))
105: theState = STOPPED;
106: else if (state.equals("DESTROYED"))
107: theState = DESTROYED;
108: else if (state.equals("FAILED"))
109: theState = FAILED;
110:
111: return theState;
112: }
113:
114: public String toString() {
115: return state;
116: }
117:
118: /** Resolve objects on deserialization to one of the identity objects.
119: */
120: private Object readResolve() throws ObjectStreamException {
121: Object identity = getDeploymentState(state);
122: return identity;
123: }
124:
125: }
|