KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > kernel > config > ConfigurationModuleType


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.kernel.config;
19
20 import java.io.Serializable JavaDoc;
21 import java.util.Map JavaDoc;
22 import java.util.LinkedHashMap JavaDoc;
23
24 /**
25  * Configuration types.
26  *
27  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
28  */

29 public class ConfigurationModuleType implements Serializable JavaDoc {
30     private static final long serialVersionUID = -4121586344416418391L;
31
32     private static final Map JavaDoc typesByName = new LinkedHashMap JavaDoc();
33
34     public static final ConfigurationModuleType EAR = new ConfigurationModuleType("EAR", 0);
35
36     public static final ConfigurationModuleType EJB = new ConfigurationModuleType("EJB", 1);
37
38     public static final ConfigurationModuleType CAR = new ConfigurationModuleType("CAR", 2); // app client
39

40     public static final ConfigurationModuleType RAR = new ConfigurationModuleType("RAR", 3);
41
42     public static final ConfigurationModuleType WAR = new ConfigurationModuleType("WAR", 4);
43
44     public static final ConfigurationModuleType SERVICE = new ConfigurationModuleType("SERVICE", 5);
45
46     public static final ConfigurationModuleType SPR = new ConfigurationModuleType("SPR", 6);
47
48     private static final ConfigurationModuleType[] fromInt = {EAR, EJB, CAR, RAR, WAR, SERVICE, SPR};
49
50     private final String JavaDoc name;
51
52     private final int value;
53
54     public static ConfigurationModuleType getFromValue(int index) {
55         if (index < 0 || index >= fromInt.length) {
56             return null;
57         }
58         return fromInt[index];
59     }
60
61     public static ConfigurationModuleType getFromValue(Integer JavaDoc index) {
62         return getFromValue(index.intValue());
63     }
64
65     public static ConfigurationModuleType getByName(String JavaDoc name) {
66         return (ConfigurationModuleType) typesByName.get(name);
67     }
68
69
70     /**
71      * This constructor is intentionally public: this class is not a type-safe
72      * enumeration.
73      */

74     public ConfigurationModuleType(String JavaDoc name, int value) {
75         this.name = name;
76         this.value = value;
77         typesByName.put(name, this);
78     }
79
80     public String JavaDoc getName() {
81         return name;
82     }
83
84     /**
85      * Gets the identifier of this type. For a configuration associated to
86      * a J2EE ModuleType, this value MUST be equal to ModuleType.getValue().
87      *
88      * @return the index
89      */

90     public int getValue() {
91         return value;
92     }
93
94     public String JavaDoc toString() {
95         return name;
96     }
97
98     protected Object JavaDoc readResolve() {
99         return fromInt[value];
100     }
101
102 }
103
Popular Tags