Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/alicebot/server/core/Globals.java


1   // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov.
2   // Jad home page: http://www.geocities.com/kpdus/jad.html
3   // Decompiler options: packimports(3) 
4   
5   package org.alicebot.server.core;
6   
7   import java.io.*;
8   import java.net.InetAddress;
9   import java.net.UnknownHostException;
10  import java.util.Properties;
11  import org.alicebot.server.core.logging.Log;
12  import org.alicebot.server.core.util.InputNormalizer;
13  import org.alicebot.server.core.util.UserError;
14  
15  public class Globals
16  {
17  
18      private Globals()
19      {
20      }
21  
22      public static void load(String s)
23      {
24          properties = new Properties();
25          try
26          {
27              properties.load(new FileInputStream(s));
28          }
29          catch(IOException ioexception)
30          {
31              System.err.println("Could not find \"" + s + "\"!");
32              System.exit(1);
33          }
34          loadProperties();
35      }
36  
37      public static void loadProperties()
38      {
39          if(properties == null)
40          {
41              System.err.println("Server properties not loaded!");
42              System.exit(1);
43          }
44          useWatcher = Boolean.valueOf(properties.getProperty("programd.watcher", "false")).booleanValue();
45          haveAHeart = Boolean.valueOf(properties.getProperty("programd.heart.enabled", "false")).booleanValue();
46          useShell = Boolean.valueOf(properties.getProperty("programd.shell", "true")).booleanValue();
47          showConsole = Boolean.valueOf(properties.getProperty("programd.console", "true")).booleanValue();
48          showMatchTrace = showConsole ? Boolean.valueOf(properties.getProperty("programd.console.match-trace", "true")).booleanValue() : false;
49          useTargeting = Boolean.valueOf(properties.getProperty("programd.targeting", "true")).booleanValue();
50          targetsAIMLPath = properties.getProperty("programd.targeting.aiml.path", "./targets/targets.aiml");
51          targetsDataPath = properties.getProperty("programd.targeting.data.path", "./targets/targets.xml");
52          try
53          {
54              targetSkip = Integer.parseInt(properties.getProperty("programd.targeting.targetskip", "1"));
55          }
56          catch(NumberFormatException numberformatexception)
57          {
58              targetSkip = 1;
59          }
60          targetSkip = targetSkip >= 1 ? targetSkip : 1;
61          mergePolicy = properties.getProperty("programd.merge", "true");
62          botNamePredicate = properties.getProperty("programd.console.bot-name-predicate", "name");
63          clientNamePredicate = properties.getProperty("programd.console.client-name-predicate", "name");
64          predicateEmptyDefault = properties.getProperty("programd.emptydefault", "");
65          infiniteLoopInput = InputNormalizer.patternFitIgnoreCase(properties.getProperty("programd.infinite-loop-input", "INFINITE LOOP"));
66          osAccessAllowed = Boolean.valueOf(properties.getProperty("programd.os-access-allowed", "false")).booleanValue();
67          jsAccessAllowed = Boolean.valueOf(properties.getProperty("programd.javascript-allowed", "false")).booleanValue();
68          systemDirectory = properties.getProperty("programd.interpreter.system.directory", "./");
69          systemPrefix = properties.getProperty("programd.interpreter.system.prefix", "");
70          supportDeprecatedTags = Boolean.valueOf(properties.getProperty("programd.deprecated-tags-support", "false")).booleanValue();
71          warnAboutDeprecatedTags = supportDeprecatedTags ? Boolean.valueOf(properties.getProperty("programd.deprecated-tags-warn", "false")).booleanValue() : false;
72          nonAIMLRequireNamespaceQualification = Boolean.valueOf(properties.getProperty("programd.non-aiml-require-namespace-qualifiers", "false")).booleanValue();
73          try
74          {
75              predicateValueCacheMax = Integer.parseInt(properties.getProperty("programd.predicate-cache.max", "5000"));
76          }
77          catch(NumberFormatException numberformatexception1)
78          {
79              predicateValueCacheMax = 5000;
80          }
81          predicateValueCacheMax = predicateValueCacheMax <= 0 ? 5000 : predicateValueCacheMax;
82          javaScriptInterpreter = properties.getProperty("programd.interpreter.javascript", "");
83          try
84          {
85              categoryLoadNotifyInterval = Integer.parseInt(properties.getProperty("programd.console.category-load-notify-interval", "1000"));
86          }
87          catch(NumberFormatException numberformatexception2)
88          {
89              categoryLoadNotifyInterval = 1000;
90          }
91          categoryLoadNotifyInterval = categoryLoadNotifyInterval <= 0 ? 1000 : categoryLoadNotifyInterval;
92          try
93          {
94              responseTimeout = Integer.parseInt(properties.getProperty("programd.response-timeout", "1000"));
95          }
96          catch(NumberFormatException numberformatexception3)
97          {
98              responseTimeout = 1000;
99          }
100         responseTimeout = responseTimeout <= 0 ? 1000 : responseTimeout;
101         try
102         {
103             startupFilePath = (new File(properties.getProperty("programd.startup", "startup.xml"))).getCanonicalPath();
104         }
105         catch(IOException ioexception)
106         {
107             String s = "Startup file does not exist (check server properties).";
108             Log.log(s, Log.STARTUP);
109             throw new UserError(s);
110         }
111         isLoaded = true;
112     }
113 
114     public static boolean isLoaded()
115     {
116         return isLoaded;
117     }
118 
119     public static String getVersion()
120     {
121         return version;
122     }
123 
124     public static String getStartupFilePath()
125     {
126         return startupFilePath;
127     }
128 
129     public static String getClientNamePredicate()
130     {
131         return clientNamePredicate;
132     }
133 
134     public static String getBotNamePredicate()
135     {
136         return botNamePredicate;
137     }
138 
139     public static String getPredicateEmptyDefault()
140     {
141         return predicateEmptyDefault;
142     }
143 
144     public static String getInfiniteLoopInput()
145     {
146         return infiniteLoopInput;
147     }
148 
149     public static boolean showConsole()
150     {
151         return showConsole;
152     }
153 
154     public static boolean showMatchTrace()
155     {
156         return showMatchTrace;
157     }
158 
159     public static boolean isWatcherActive()
160     {
161         return useWatcher;
162     }
163 
164     public static boolean useHeart()
165     {
166         return haveAHeart;
167     }
168 
169     public static boolean useShell()
170     {
171         return useShell;
172     }
173 
174     public static String getMergePolicy()
175     {
176         return mergePolicy;
177     }
178 
179     public static boolean useTargeting()
180     {
181         return useTargeting;
182     }
183 
184     public static String getTargetsAIMLPath()
185     {
186         return targetsAIMLPath;
187     }
188 
189     public static String getTargetsDataPath()
190     {
191         return targetsDataPath;
192     }
193 
194     public static int getTargetSkip()
195     {
196         return targetSkip;
197     }
198 
199     public static int getCategoryLoadNotifyInterval()
200     {
201         return categoryLoadNotifyInterval;
202     }
203 
204     public static void setHttpPort(int i)
205     {
206         httpPort = i;
207     }
208 
209     public static int getHttpPort()
210     {
211         return httpPort;
212     }
213 
214     public static int getResponseTimeout()
215     {
216         return responseTimeout;
217     }
218 
219     public static String getHostName()
220     {
221         return hostName;
222     }
223 
224     public static boolean supportDeprecatedTags()
225     {
226         return supportDeprecatedTags;
227     }
228 
229     public static boolean warnAboutDeprecatedTags()
230     {
231         return warnAboutDeprecatedTags;
232     }
233 
234     public static boolean nonAIMLRequireNamespaceQualification()
235     {
236         return nonAIMLRequireNamespaceQualification;
237     }
238 
239     public static int predicateValueCacheMax()
240     {
241         return predicateValueCacheMax;
242     }
243 
244     public static boolean osAccessAllowed()
245     {
246         return osAccessAllowed;
247     }
248 
249     public static boolean jsAccessAllowed()
250     {
251         return jsAccessAllowed;
252     }
253 
254     public static String javaScriptInterpreter()
255     {
256         return javaScriptInterpreter;
257     }
258 
259     public static String getSystemDirectory()
260     {
261         return systemDirectory;
262     }
263 
264     public static String getSystemPrefix()
265     {
266         return systemPrefix;
267     }
268 
269     public static String getProperty(String s)
270     {
271         return properties.getProperty(s);
272     }
273 
274     public static String getProperty(String s, String s1)
275     {
276         return properties.getProperty(s, s1);
277     }
278 
279     public static Properties getProperties()
280     {
281         return properties;
282     }
283 
284     private static boolean isLoaded = false;
285     private static Properties properties;
286     private static String botNamePredicate;
287     private static String clientNamePredicate;
288     private static String predicateEmptyDefault;
289     private static String infiniteLoopInput;
290     private static boolean osAccessAllowed;
291     private static String systemDirectory;
292     private static String systemPrefix;
293     private static boolean jsAccessAllowed;
294     private static boolean supportDeprecatedTags;
295     private static boolean warnAboutDeprecatedTags;
296     private static boolean nonAIMLRequireNamespaceQualification;
297     private static int predicateValueCacheMax;
298     private static String startupFilePath;
299     private static String targetsDataPath;
300     private static String targetsAIMLPath;
301     private static int categoryLoadNotifyInterval;
302     private static String mergePolicy;
303     private static boolean showConsole;
304     private static boolean showMatchTrace;
305     private static boolean useShell;
306     private static boolean useWatcher;
307     private static boolean haveAHeart;
308     private static int targetSkip;
309     private static boolean useTargeting;
310     private static String version = "4.1.8";
311     private static String hostName;
312     private static int httpPort;
313     private static String javaScriptInterpreter;
314     private static int responseTimeout;
315     private static final String EMPTY_STRING = "";
316 
317     static 
318     {
319         try
320         {
321             hostName = InetAddress.getLocalHost().getHostName();
322         }
323         catch(UnknownHostException unknownhostexception)
324         {
325             hostName = "unknown-host";
326         }
327     }
328 }