01: /*
02: * @(#)SystemProperties.java 1.10 01/08/01 Sun Microsystems
03: *
04: */
05:
06: package com.sun.portal.cli.cert;
07:
08: import java.io.*;
09: import com.sun.portal.log.common.PortalLogger;
10: import java.util.Properties;
11:
12: /*
13: * <P>Utility class that provides access to system properties for
14: * the portal server srap.
15: *
16: * <P>Allows access to property values and properties objects
17: * loaded from:
18: * <UL>
19: * <LI><CODE>/etc/opt/SUNWportal/platform.conf.instance_name</CODE> (Platform)
20: * </UL>
21: *
22: */
23:
24: public class SystemProperties {
25:
26: private static Properties platformProp = new Properties();
27:
28: public static void init(String filename) throws CertAdminException {
29: FileInputStream stream = null;
30: try {
31:
32: File file = new File(filename);
33: stream = new FileInputStream(file);
34: platformProp.load(stream);
35: stream.close();
36: } catch (Exception e) {
37: CertAdminUtil.println(CertAdminLocale.getPFString("m2",
38: CertAdminConstants.m2));
39: throw new CertAdminException(CertAdminLocale.getPFString(
40: "m2", CertAdminConstants.m2));
41: } finally {
42: if (stream != null) {
43: try {
44: stream.close();
45: } catch (Exception e) {
46: }
47: }
48: }
49: }
50:
51: /*
52: * <P>Get system property.
53: *
54: * @param key key to search for.
55: * @return property value
56: */
57:
58: public static String get(String key) {
59: return platformProp.getProperty(key, null);
60: }
61:
62: /*
63: * <P>Get system property.
64: *
65: * @param key key
66: * @param def default value
67: * @return property value
68: */
69:
70: public static String get(String key, String def) {
71: return platformProp.getProperty(key, def);
72: }
73:
74: }
|