1 17 18 package org.apache.geronimo.kernel.config; 19 20 import java.io.Serializable ; 21 import java.util.Map ; 22 import java.util.LinkedHashMap ; 23 24 29 public class ConfigurationModuleType implements Serializable { 30 private static final long serialVersionUID = -4121586344416418391L; 31 32 private static final Map typesByName = new LinkedHashMap (); 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); 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 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 index) { 62 return getFromValue(index.intValue()); 63 } 64 65 public static ConfigurationModuleType getByName(String name) { 66 return (ConfigurationModuleType) typesByName.get(name); 67 } 68 69 70 74 public ConfigurationModuleType(String name, int value) { 75 this.name = name; 76 this.value = value; 77 typesByName.put(name, this); 78 } 79 80 public String getName() { 81 return name; 82 } 83 84 90 public int getValue() { 91 return value; 92 } 93 94 public String toString() { 95 return name; 96 } 97 98 protected Object readResolve() { 99 return fromInt[value]; 100 } 101 102 } 103 | Popular Tags |