/
SystemPropertyConstants.java
339 lines (269 loc) · 13 KB
/
SystemPropertyConstants.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/*
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.enterprise.util;
import java.io.File;
import com.sun.enterprise.util.i18n.StringManager;
public class SystemPropertyConstants {
/**
* Field used by Monitoring to encode a forward slash and/or dot
*/
public static final String SLASH = "___SLASH___";
public static final String MONDOT = "___MONDOT___";
/**
* Field
*/
public static final String UNIX_ASENV_FILENAME = "asenv.conf";
/**
* Field
*/
public static final String WINDOWS_ASENV_FILENAME = "asenv.bat";
/**
* Field
*/
public static final String WEB_SERVICES_LIB_PROPERTY = "com.sun.aas.webServicesLib";
/**
* Field
*/
public static final String PERL_ROOT_PROPERTY = "com.sun.aas.perlRoot";
/**
* Field
*/
public static final String IMQ_LIB_PROPERTY = "com.sun.aas.imqLib";
/**
* Field
*/
public static final String IMQ_BIN_PROPERTY = "com.sun.aas.imqBin";
/**
* Field
*/
public static final String CONFIG_ROOT_PROPERTY = "com.sun.aas.configRoot";
/**
* Field
*/
public static final String INSTALL_ROOT_PROPERTY = "com.sun.aas.installRoot";
/**
* Field
*/
public static final String PRODUCT_ROOT_PROPERTY = "com.sun.aas.productRoot";
/**
* Field
*/
public static final String JAVA_ROOT_PROPERTY = "com.sun.aas.javaRoot";
public static final String JAVA_ROOT_PROPERTY_ASENV = "com.sun.aas.javaRoot.asenv";
/**
* Field
*/
public static final String ICU_LIB_PROPERTY = "com.sun.aas.icuLib";
/**
* Field
*/
public static final String DEFAULT_LOCALE_PROPERTY = "com.sun.aas.defaultLocale";
/**
* Field
*/
public static final String DOMAINS_ROOT_PROPERTY = "com.sun.aas.domainsRoot";
/**
* Field
*/
public static final String INSTANCE_ROOT_PROPERTY = "com.sun.aas.instanceRoot";
/**
* Field
*/
public static final String DEBUG_MODE_PROPERTY = "com.sun.aas.debugMode";
/**
* The certificate nick name specified in the System-Jmx-Conenctor of the DAS with which a Node Agent synchronizes
*/
public static final String AGENT_CERT_NICKNAME = "com.sun.aas.agentCertNickname";
public static final String AGENT_ROOT_PROPERTY = "com.sun.aas.agentRoot";
public static final String AGENT_NAME_PROPERTY = "com.sun.aas.agentName";
/**
* Field
*/
public static final String WEBCONSOLE_LIB_PROPERTY = "com.sun.aas.webconsoleLib";
public static final String WEBCONSOLE_APP_PROPERTY = "com.sun.aas.webconsoleApp";
public static final String JATO_ROOT_PROPERTY = "com.sun.aas.jatoRoot";
public static final String ANT_ROOT_PROPERTY = "com.sun.aas.antRoot";
public static final String ANT_LIB_PROPERTY = "com.sun.aas.antLib";
public static final String JHELP_ROOT_PROPERTY = "com.sun.aas.jhelpRoot";
/** name of the server instance key */
public static final String SERVER_NAME = "com.sun.aas.instanceName";
/** name of the server's cluster */
public static final String CLUSTER_NAME = "com.sun.aas.clusterName";
/** name of the HADB location property **/
public static final String HADB_ROOT_PROPERTY = "com.sun.aas.hadbRoot";
public static final String NSS_ROOT_PROPERTY = "com.sun.aas.nssRoot";
public static final String NSS_BIN_PROPERTY = "com.sun.aas.nssBin";
public static final String NATIVE_LAUNCHER = "com.sun.aas.nativeLauncher";
public static final String NATIVE_LAUNCHER_LIB_PREFIX = "com.sun.aas.nativeLauncherLibPrefix";
public static final String KEYSTORE_PROPERTY = "javax.net.ssl.keyStore";
public static final String JKS_KEYSTORE = System.getProperty("file.separator") + "config" + System.getProperty("file.separator") + "keystore.jks";
public static final String TRUSTSTORE_PROPERTY = "javax.net.ssl.trustStore";
public static final String JKS_TRUSTSTORE = System.getProperty("file.separator") + "config" + System.getProperty("file.separator") + "cacerts.jks";
public static final String ADMIN_REALM = "admin-realm";
public static final String NSS_DB_PROPERTY = "com.sun.appserv.nss.db";
public static final String NSS_DB_PASSWORD_PROPERTY = "com.sun.appserv.nss.db.password";
public static final String CLIENT_TRUSTSTORE_PROPERTY = TRUSTSTORE_PROPERTY;
// "com.sun.appserv.client.truststore";
public static final String CLIENT_TRUSTSTORE_PASSWORD_PROPERTY = "javax.net.ssl.trustStorePassword";
// "com.sun.appserv.client.truststore.password";
public static final String PID_FILE = ".__com_sun_appserv_pid";
public static final String REF_TS_FILE = "admsn";
public static final String KILLSERV_SCRIPT = "killserv";
public static final String KILL_SERV_UNIX = "killserv";
public static final String KILL_SERV_WIN = "killserv.bat";
public static final String KILL_SERV_OS = OS.isWindows() ? KILL_SERV_WIN : KILL_SERV_UNIX;
public static final String DAS_SERVER_NAME = "server";
@Deprecated
public static final String DEFAULT_SERVER_INSTANCE_NAME = DAS_SERVER_NAME;
public static final String DAS_SERVER_CONFIG = "server-config";
public static final String JDMK_HOME_PROPERTY = "com.sun.aas.jdmkHome";
public static final String DERBY_ROOT_PROPERTY = "com.sun.aas.derbyRoot";
/** Java ES Monitoring Framework install directory */
public static final String MFWK_HOME_PROPERTY = "com.sun.aas.mfwkHome";
/*
* An implementation note: This variable should be defined at one place. I have chosen this location because most of the
* other modules depend on appserv-commons for compilation.
*/
/** name of the domain key */
public static final String DOMAIN_NAME = "domain.name";
public static final String HOST_NAME_PROPERTY = "com.sun.aas.hostName";
public static final String CONFIG_NAME_PROPERTY = "com.sun.aas.configName";
public static final String DOCROOT_PROPERTY = "docroot";
public static final String ACCESSLOG_PROPERTY = "accesslog";
public static final String DEFAULT_SERVER_SOCKET_ADDRESS = "0.0.0.0";
public static final String CLUSTER_AWARE_FEATURE_FACTORY_CLASS = "com.sun.enterprise.ee.server.pluggable.EEPluggableFeatureImpl";
public static final String DROP_INTERRUPTED_COMMANDS = "org.glassfish.job-manager.drop-interrupted-commands";
/** Name of the default config that determines the configuration for the instances */
public static final String TEMPLATE_CONFIG_NAME = "default-config";
public static final String DEFAULT_ADMIN_USER = "admin";
public static final String DEFAULT_ADMIN_PASSWORD = "";
public static final String DEFAULT_ADMIN_TIMEOUT_PROPERTY = "org.glassfish.admin.timeout";
private static final int DEFAULT_ADMIN_TIMEOUT_VALUE = 5000;
private static final StringManager sm = StringManager.getManager(SystemPropertyConstants.class);
public static final String OPEN = "${";
public static final String CLOSE = "}";
/**
* A method that returns the passed String as a property that can be replaced at run time.
*
* @param name String that represents a property, e.g INSTANCE_ROOT_PROPERTY in this class. The String may not be null.
* @return a String that represents the replaceable value of passed String. Generally speaking it will be decorated with
* a pair of braces with $ in the front (e.g. "a" will be returned as "${a}").
* @throws IllegalArgumentException if the passed String is null
*/
public static final String getPropertyAsValue(final String name) {
if (name == null) {
throw new IllegalArgumentException(sm.getString("spc.null_name", "property"));
}
return new StringBuffer().append(OPEN)
.append(name)
.append(CLOSE)
.toString();
}
/**
* Returns the string removing the "system-property syntax" from it. If the given string is not in "system-property
* syntax" the same string is returned. The "system-propery syntax" is "${...}" The given String may not be null. The
* returned String may be an empty String, if it is of the form "${}" (rarely so).
*/
public static final String unSystemProperty(final String sp) {
if (sp == null) {
throw new IllegalArgumentException("null_arg");
}
String ret = sp;
if (isSystemPropertySyntax(sp)) {
ret = sp.substring(2, sp.length() - 1);
}
return ret;
}
public static final boolean isSystemPropertySyntax(final String s) {
if (s == null) {
throw new IllegalArgumentException("null_arg");
}
boolean sp = false;
if (s.startsWith(OPEN) && s.endsWith(CLOSE)) {
sp = true;
}
return sp;
}
/**
* Returns the default value (as would appear in the domain.xml on installation) of docroot of a virtual server, as a
* String. Never returns a null. Returned String contains no backslashes. Note that it is <b> not <b> the absolute value
* of the path on a file system.
*/
public static final String getDocRootDefaultValue() {
return new StringBuffer(getPropertyAsValue(INSTANCE_ROOT_PROPERTY)).append("/docroot").toString();
}
/**
* Returns the default value (as would appear in the domain.xml on installation) of file where the acess log of a
* virtual server is stored, as a String. Never returns a null. Returned String contains no backslashes. Note that it is
* <b> not <b> the absolute value of the path on a file system.
*/
public static final String getAccessLogDefaultValue() {
return new StringBuffer(getPropertyAsValue(INSTANCE_ROOT_PROPERTY)).append("/logs/access").toString();
}
/**
* Returns the system specific file.separator delimited path to the asadmin script. Any changes to file layout should
*
* be reflected here. The path will contain '/' as the separator character, regardless of operating platform. Never
* returns a null. Assumes the the property "INSTALL_ROOT_PROPERTY" is set in the VM before calling this. As of now
* (September 2005) all the server instances and asadmin VM itself has this property set. The method does not guarantee
* that the script exists on the given system. It should only be used when caller wants to know the location of the
* script. Caller should make sure it exists.
*
* @return String representing the Path to asadmin script. Might return a string beginning with "null", if the
* INSTALL_ROOT_PROPERTY is not defined
*/
public static final String getAsAdminScriptLocation() {
return getAdminScriptLocation(System.getProperty(INSTALL_ROOT_PROPERTY));
}
public static final String getAsAdminScriptLocation(String installRoot) {
return getAdminScriptLocation(installRoot);
}
public static final String getAdminScriptLocation(String installRoot) {
StringBuilder sb = new StringBuilder();
String ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : "";
String ASADMIN = "nadmin";
String suffix = new StringBuilder("lib").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString();
sb.append(installRoot);
final String fs = System.getProperty("file.separator");
if (!sb.toString().endsWith(fs)) {
sb.append(fs);
}
sb.append(suffix);
return sb.toString();
}
/**
* Returns the component identifier associated with the INSTALL_ROOT. For example if INSTALL_ROOT is
* /home/glassfish8/glassfish the component name will "glassfish".
*
* @return String representing the component identifier.
*/
public static final String getComponentName() {
return new File(System.getProperty(INSTALL_ROOT_PROPERTY)).getName();
}
/**
* Returns the default timeout in milliseconds used in some Admin commands.
*
* @return The value of the system property {@link SystemPropertyConstants#DEFAULT_ADMIN_TIMEOUT_PROPERTY} or the
* value {@link SystemPropertyConstants#DEFAULT_ADMIN_TIMEOUT_VALUE} if the system property not set.
*/
public static final Integer getDefaultAdminTimeout() {
final Integer result = Integer.getInteger(DEFAULT_ADMIN_TIMEOUT_PROPERTY);
if (result == null) {
return DEFAULT_ADMIN_TIMEOUT_VALUE;
}
return result;
}
}