01: package com.sun.portal.util;
02:
03: import java.net.URL;
04: import java.util.Properties;
05: import java.util.logging.Level;
06: import java.util.logging.Logger;
07:
08: import com.sun.portal.log.common.PortalLogger;
09:
10: public class PropertiesFile extends Properties {
11: // static Logger logger = Logger.getLogger("com.sun.portal.sra.rproxy");
12: private static Logger logger = PortalLogger
13: .getLogger(PropertiesFile.class);
14:
15: // read main ReverseProxy URL
16: public PropertiesFile(String _URL) {
17: super ();
18:
19: try {
20: load(new URL(_URL).openStream());
21: } catch (Exception e) {
22: System.out.println("Property file " + _URL + " not found!");
23: }
24: }
25:
26: public String getString(String property, String def) {
27: StringBuffer sb;
28: String string;
29: char c;
30:
31: sb = new StringBuffer();
32:
33: try {
34: string = (String) get(property);
35: if (string == null) {
36: logger.warning("Couldn't find \'" + property
37: + "\' returning default: " + def);
38: return def;
39: }
40:
41: sb.setLength(0);
42: for (int i = 0; i < string.length(); i++) {
43: c = string.charAt(i);
44: if (!Character.isISOControl(c))
45: sb.append(c);
46: }
47: } catch (Exception ex) {
48: // logger.log(Level.SEVERE, "Couldn't find \'" + property + "\'
49: // returning default: " + def, ex);
50: Object[] params0 = { property, "\' returning default: ",
51: def, ex };
52: logger.log(Level.SEVERE, "PSSR_CSPU090", params0);
53: return def;
54: }
55:
56: return sb.toString();
57: }
58:
59: public int getInt(String property, int def) {
60: try {
61: return Integer.parseInt(getString(property, Integer
62: .toString(def)));
63: } catch (Exception ex) {
64: return def;
65: }
66: }
67: }
|