1 package mircoders.global;
4 import mircoders.localizer.*;
6 public class MirGlobal {
7 static private MirConfig configuration;
8 static private MirLocalizer localizer;
9 static private ProducerEngine producerEngine;
11 public static MirLocalizer localizer() {
12 String localizerClassName;
15 if (localizer == null ) {
16 synchronized(MirGlobal.class) {
17 if (localizer == null ) {
18 localizerClassName = getConfigPropertyWithDefault("Mir.Localizer", "mirlocal.loaclizer.basic.MirBasicLocalizer");
21 localizerClass = Class.forName(localizerClassName);
24 throw new ConfigException("localizer class '" + localizerClassName + "' not found: " + t.toString());
27 if (!(MirLocalizer.class.isAssignableFrom(localizerClass)))
28 throw new ConfigException("localizer class '" + localizerClassName + "' is not assignable from MirLocalizer");
31 localizer = new MirCachingLocalizerDecorator((MirLocalizer) localizerClass.newInstance());
34 throw new ConfigException("localizer class '" + localizerClassName + "' cannot be instantiated: " + t.toString());
43 public static MirConfig config() {
44 if (configuration == null) {
45 configuration = new MirConfig();
51 public static ProducerEngine producerEngine() {
52 if (producerEngine == null) {
53 producerEngine = new ProducerEngine();
56 return producerEngine;
59 public static String getConfigPropertyWithDefault(String aPropertyName, String aDefault) {
62 result = config().getProp(aPropertyName);
70 public static String getConfigProperty(String aPropertyName) {
73 result = config().getProp(aPropertyName);
76 throw new ConfigException("Property '" + aPropertyName + "' not present");
81 public static int getConfigIntegerProperty(String aPropertyName) {
84 result = config().getProp(aPropertyName);
86 return Integer.parseInt(result);
89 public static boolean getConfigBooleanProperty(String aPropertyName) {
92 result = config().getProp(aPropertyName);
95 throw new ConfigException("Boolean property '" + aPropertyName + "' not present");
97 return (result.equals("yes") || result.equals("1"));