1
19
20 package com.liferay.portal.util;
21
22 import com.liferay.portal.configuration.ConfigurationImpl;
23 import com.liferay.portal.kernel.configuration.Configuration;
24 import com.liferay.portal.kernel.configuration.Filter;
25 import com.liferay.util.SystemProperties;
26
27 import java.util.Properties;
28
29
35 public class PropsUtil {
36
37 public static void addProperties(Properties properties) {
38 _instance._addProperties(properties);
39 }
40
41 public static boolean contains(String key) {
42 return _instance._contains(key);
43 }
44
45 public static String get(String key) {
46 return _instance._get(key);
47 }
48
49 public static String get(String key, Filter filter) {
50 return _instance._get(key, filter);
51 }
52
53 public static String[] getArray(String key) {
54 return _instance._getArray(key);
55 }
56
57 public static String[] getArray(String key, Filter filter) {
58 return _instance._getArray(key, filter);
59 }
60
61 public static Properties getProperties() {
62 return _instance._getProperties();
63 }
64
65 public static Properties getProperties(
66 String prefix, boolean removePrefix) {
67
68 return _instance._getProperties(prefix, removePrefix);
69 }
70
71 public static void removeProperties(Properties properties) {
72 _instance._removeProperties(properties);
73 }
74
75 public static void set(String key, String value) {
76 _instance._set(key, value);
77 }
78
79 private PropsUtil() {
80 _configuration = new ConfigurationImpl(
81 PropsUtil.class.getClassLoader(), PropsFiles.PORTAL);
82
83
88 SystemProperties.set(
89 PropsKeys.RESOURCE_REPOSITORIES_ROOT,
90 _get(PropsKeys.RESOURCE_REPOSITORIES_ROOT));
91
92 SystemProperties.set(
93 "ehcache.disk.store.dir",
94 _get(PropsKeys.RESOURCE_REPOSITORIES_ROOT));
95 }
96
97 private void _addProperties(Properties properties) {
98 _configuration.addProperties(properties);
99 }
100
101 private boolean _contains(String key) {
102 return _configuration.contains(key);
103 }
104
105 private String _get(String key) {
106 return _configuration.get(key);
107 }
108
109 private String _get(String key, Filter filter) {
110 return _configuration.get(key, filter);
111 }
112
113 private String[] _getArray(String key) {
114 return _configuration.getArray(key);
115 }
116
117 private String[] _getArray(String key, Filter filter) {
118 return _configuration.getArray(key, filter);
119 }
120
121 private Properties _getProperties() {
122 return _configuration.getProperties();
123 }
124
125 private Properties _getProperties(String prefix, boolean removePrefix) {
126 return _configuration.getProperties(prefix, removePrefix);
127 }
128
129 private void _removeProperties(Properties properties) {
130 _configuration.removeProperties(properties);
131 }
132
133 private void _set(String key, String value) {
134 _configuration.set(key, value);
135 }
136
137 private static PropsUtil _instance = new PropsUtil();
138
139 private Configuration _configuration;
140
141 }