KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployment > DeploymentState


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.deployment;
23
24 import java.io.ObjectStreamException JavaDoc;
25 import java.io.Serializable JavaDoc;
26
27 /**
28  * A type-safe enumeration for the status a DeploymentInfo may be in
29  *
30  * @author Scott.Stark@jboss.org
31  * @version $Revision: 57108 $
32  */

33 public class DeploymentState implements Serializable JavaDoc
34 {
35    /** @since 4.0.2 */
36    private static final long serialVersionUID = -2319062412502366783L;
37    
38    public static final DeploymentState CONSTRUCTED = new DeploymentState("CONSTRUCTED");
39    public static final DeploymentState INIT_WAITING_DEPLOYER = new DeploymentState("INIT_WAITING_DEPLOYER");
40    public static final DeploymentState INIT_HAS_DEPLOYER = new DeploymentState("INIT_HAS_DEPLOYER");
41    public static final DeploymentState INIT_DEPLOYER = new DeploymentState("INIT_DEPLOYER");
42    public static final DeploymentState INITIALIZED = new DeploymentState("INITIALIZED");
43
44    public static final DeploymentState CREATE_SUBDEPLOYMENTS = new DeploymentState("CREATE_SUBDEPLOYMENTS");
45    public static final DeploymentState CREATE_DEPLOYER = new DeploymentState("CREATE_DEPLOYER");
46    public static final DeploymentState CREATED = new DeploymentState("CREATED");
47
48    public static final DeploymentState START_SUBDEPLOYMENTS = new DeploymentState("START_SUBDEPLOYMENTS");
49    public static final DeploymentState START_DEPLOYER = new DeploymentState("START_DEPLOYER");
50    public static final DeploymentState STARTED = new DeploymentState("STARTED");
51
52    public static final DeploymentState STOPPED = new DeploymentState("STOPPED");
53    public static final DeploymentState DESTROYED = new DeploymentState("DESTROYED");
54    public static final DeploymentState FAILED = new DeploymentState("FAILED");
55
56    private String JavaDoc state;
57    
58    /** Private CTOR to disable direct object construction
59     */

60    private DeploymentState(String JavaDoc state)
61    {
62       this.state = state;
63    }
64
65    /** A factory to translate a string into the corresponding DeploymentState.
66     */

67    public static DeploymentState getDeploymentState(String JavaDoc state)
68    {
69       DeploymentState theState = null;
70       state = state.toUpperCase();
71       if( state.equals("CONSTRUCTED") )
72          theState = CONSTRUCTED;
73       else if( state.equals("INIT_WAITING_DEPLOYER") )
74          theState = INIT_WAITING_DEPLOYER;
75       else if( state.equals("INIT_HAS_DEPLOYER") )
76          theState = INIT_HAS_DEPLOYER;
77       else if( state.equals("INIT_DEPLOYER") )
78          theState = INIT_DEPLOYER;
79       else if( state.equals("INITIALIZED") )
80          theState = INITIALIZED;
81       else if( state.equals("CREATE_SUBDEPLOYMENTS") )
82          theState = CREATE_SUBDEPLOYMENTS;
83       else if( state.equals("CREATE_DEPLOYER") )
84          theState = CREATE_DEPLOYER;
85       else if( state.equals("CREATED") )
86          theState = CREATED;
87       else if( state.equals("START_SUBDEPLOYMENTS") )
88          theState = START_SUBDEPLOYMENTS;
89       else if( state.equals("START_DEPLOYER") )
90          theState = START_DEPLOYER;
91       else if( state.equals("STARTED") )
92          theState = STARTED;
93       else if( state.equals("STOPPED") )
94          theState = STOPPED;
95       else if( state.equals("DESTROYED") )
96          theState = DESTROYED;
97       else if( state.equals("FAILED") )
98          theState = FAILED;
99
100       return theState;
101    }
102
103    public String JavaDoc toString()
104    {
105       return state;
106    }
107
108    /** Resolve objects on deserialization to one of the identity objects.
109    */

110    private Object JavaDoc readResolve() throws ObjectStreamException JavaDoc
111    {
112       Object JavaDoc identity = getDeploymentState(state);
113       return identity;
114    }
115
116 }
117
Popular Tags