KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > util > SystemPropertyConstants


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.util;
24
25 import com.sun.enterprise.util.i18n.StringManager;
26 import com.sun.enterprise.util.OS;
27
28 public class SystemPropertyConstants
29 {
30
31     /**
32      * Field
33      */

34     public static final String JavaDoc UNIX_ASENV_FILENAME = "asenv.conf";
35
36     /**
37      * Field
38      */

39     public static final String JavaDoc WINDOWS_ASENV_FILENAME = "asenv.bat";
40
41     /**
42      * Field
43      */

44     public static final String JavaDoc WEB_SERVICES_LIB_PROPERTY =
45         "com.sun.aas.webServicesLib";
46
47     /**
48      * Field
49      */

50     public static final String JavaDoc PERL_ROOT_PROPERTY = "com.sun.aas.perlRoot";
51
52     /**
53      * Field
54      */

55     public static final String JavaDoc IMQ_LIB_PROPERTY = "com.sun.aas.imqLib";
56
57     /**
58      * Field
59      */

60     public static final String JavaDoc IMQ_BIN_PROPERTY = "com.sun.aas.imqBin";
61
62     /**
63      * Field
64      */

65     public static final String JavaDoc CONFIG_ROOT_PROPERTY = "com.sun.aas.configRoot";
66
67     /**
68      * Field
69      */

70     public static final String JavaDoc INSTALL_ROOT_PROPERTY =
71         "com.sun.aas.installRoot";
72
73     /**
74      * Field
75      */

76     public static final String JavaDoc JAVA_ROOT_PROPERTY = "com.sun.aas.javaRoot";
77
78     /**
79      * Field
80      */

81     public static final String JavaDoc ICU_LIB_PROPERTY = "com.sun.aas.icuLib";
82
83     /**
84      * Field
85      */

86     public static final String JavaDoc DEFAULT_LOCALE_PROPERTY =
87         "com.sun.aas.defaultLocale";
88
89     /**
90      * Field
91      */

92     public static final String JavaDoc DOMAINS_ROOT_PROPERTY =
93         "com.sun.aas.domainsRoot";
94
95     /**
96      * Field
97      */

98     public static final String JavaDoc INSTANCE_ROOT_PROPERTY =
99         "com.sun.aas.instanceRoot";
100
101     /**
102      * Field
103      */

104     public static final String JavaDoc WEBCONSOLE_LIB_PROPERTY =
105         "com.sun.aas.webconsoleLib";
106     public static final String JavaDoc WEBCONSOLE_APP_PROPERTY =
107         "com.sun.aas.webconsoleApp";
108
109     public static final String JavaDoc JATO_ROOT_PROPERTY =
110         "com.sun.aas.jatoRoot";
111
112     public static final String JavaDoc ANT_ROOT_PROPERTY = "com.sun.aas.antRoot";
113
114     public static final String JavaDoc ANT_LIB_PROPERTY = "com.sun.aas.antLib";
115     
116     public static final String JavaDoc JHELP_ROOT_PROPERTY = "com.sun.aas.jhelpRoot";
117
118     /** name of the server instance key */
119     public static final String JavaDoc SERVER_NAME = "com.sun.aas.instanceName";
120
121     /** name of the server's cluster */
122     public static final String JavaDoc CLUSTER_NAME = "com.sun.aas.clusterName";
123
124     /** name of the HADB location property **/
125     public static final String JavaDoc HADB_ROOT_PROPERTY = "com.sun.aas.hadbRoot";
126
127         public static final String JavaDoc NSS_ROOT_PROPERTY = "com.sun.aas.nssRoot";
128
129     public static final String JavaDoc NSS_BIN_PROPERTY = "com.sun.aas.nssBin";
130
131     public static final String JavaDoc NATIVE_LAUNCHER = "com.sun.aas.nativeLauncher";
132     public static final String JavaDoc NATIVE_LAUNCHER_LIB_PREFIX = "com.sun.aas.nativeLauncherLibPrefix";
133     
134     public static final String JavaDoc KEYSTORE_PROPERTY = "javax.net.ssl.keyStore";
135     public static final String JavaDoc KEYSTORE_PASSWORD_PROPERTY = "javax.net.ssl.keyStorePassword";
136     
137     public static final String JavaDoc TRUSTSTORE_PROPERTY = "javax.net.ssl.trustStore";
138     public static final String JavaDoc TRUSTSTORE_PASSWORD_PROPERTY = "javax.net.ssl.trustStorePassword";
139     
140     public static final String JavaDoc NSS_DB_PROPERTY = "com.sun.appserv.nss.db";
141
142     public static final String JavaDoc NSS_DB_PASSWORD_PROPERTY = "com.sun.appserv.nss.db.password";
143
144     public static final String JavaDoc CLIENT_TRUSTSTORE_PROPERTY =
145         TRUSTSTORE_PROPERTY;
146         //"com.sun.appserv.client.truststore";
147

148     public static final String JavaDoc CLIENT_TRUSTSTORE_PASSWORD_PROPERTY =
149         TRUSTSTORE_PASSWORD_PROPERTY;
150         //"com.sun.appserv.client.truststore.password";
151

152     public static final String JavaDoc DEFAULT_SERVER_INSTANCE_NAME = "server";
153
154     public static final String JavaDoc JDMK_HOME_PROPERTY="com.sun.aas.jdmkHome";
155     
156     public static final String JavaDoc DERBY_ROOT_PROPERTY="com.sun.aas.derbyRoot";
157
158     /** Java ES Monitoring Framework install directory */
159     public static final String JavaDoc MFWK_HOME_PROPERTY="com.sun.aas.mfwkHome";
160  
161     /* An implementation note: This variable should be defined at one place.
162      * I have chosen this location because most of the other modules depend
163      * on appserv-commons for compilation.
164      */

165     /** name of the domain key */
166     public static final String JavaDoc DOMAIN_NAME = "domain.name";
167     public static final String JavaDoc HOST_NAME_PROPERTY = "com.sun.aas.hostName";
168     public static final String JavaDoc CONFIG_NAME_PROPERTY = "com.sun.aas.configName";
169     public static final String JavaDoc DOCROOT_PROPERTY = "docroot";
170     public static final String JavaDoc ACCESSLOG_PROPERTY = "accesslog";
171     public static final String JavaDoc DEFAULT_SERVER_SOCKET_ADDRESS="0.0.0.0";
172     
173     private static final StringManager sm = StringManager.getManager(SystemPropertyConstants.class);
174
175     /** A method that returns the passed String as a property that can
176      * be replaced at run time.
177      * @param a String that represents a property, e.g INSTANCE_ROOT_PROPERTY
178      * in this class. The String may not be null.
179      * @return a String that represents the replaceable value of passed String. Generally
180      * speaking it will be decorated with a pair of braces.
181      * @throws IllegalArgumentException if the passed String is null
182      */

183     public static final String JavaDoc getPropertyAsValue(final String JavaDoc name) {
184         if (name == null) {
185             final String JavaDoc pn = "spc.null_name";
186             final String JavaDoc pv = "property";
187             throw new IllegalArgumentException JavaDoc(sm.getString(pn, pv));
188         }
189         final StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
190         sb.append(OPEN).append(name).append(CLOSE);
191         return ( sb.toString() );
192     }
193         
194         private static final String JavaDoc OPEN = "${";
195         private static final String JavaDoc CLOSE = "}";
196         
197         /** Returns the string removing the "system-property syntax" from it.
198          * If the given string is not in "system-property syntax" the same string is returned.
199          * The "system-propery syntax" is "${...}"
200          * The given String may not be null.
201          * The returned String may be an empty String, if it is of the form "${}" (rarely so).
202          */

203         public static final String JavaDoc unSystemProperty(final String JavaDoc sp) {
204             if (sp == null)
205                 throw new IllegalArgumentException JavaDoc ("null_arg");
206             String JavaDoc ret = sp;
207             if (isSystemPropertySyntax(sp)) {
208                 ret = sp.substring(2, sp.length() - 1);
209             }
210             return ( ret );
211         }
212         
213         public static final boolean isSystemPropertySyntax(final String JavaDoc s) {
214             if ( s == null)
215                 throw new IllegalArgumentException JavaDoc ("null_arg");
216             boolean sp = false;
217             if (s.startsWith(OPEN) && s.endsWith(CLOSE))
218                 sp = true;
219             return ( sp );
220         }
221     
222     /** Returns the default value (as would appear in the domain.xml on installation)
223      * of docroot of a virtual server, as a String. Never returns a null.
224      * Returned String contains no backslashes.
225      * Note that it is <b> not <b> the absolute value of the path on a file system.
226      */

227     public static final String JavaDoc getDocRootDefaultValue() {
228         final StringBuffer JavaDoc sb = new StringBuffer JavaDoc(getPropertyAsValue(INSTANCE_ROOT_PROPERTY));
229         return ( sb.append("/docroot").toString() );
230     }
231     
232     /** Returns the default value (as would appear in the domain.xml on installation)
233      * of file where the acess log of a virtual server is stored, as a String. Never returns a null.
234      * Returned String contains no backslashes.
235      * Note that it is <b> not <b> the absolute value of the path on a file system.
236      */

237     public static final String JavaDoc getAccessLogDefaultValue() {
238         final StringBuffer JavaDoc sb = new StringBuffer JavaDoc(getPropertyAsValue(INSTANCE_ROOT_PROPERTY));
239         return ( sb.append("/logs/access").toString() );
240     }
241     
242     /** Returns the system specific file.separator delimited path to the asadmin script. Any changes to file layout should
243
244      * be reflected here. The path will contain '/' as the separator character, regardless of operating
245      * platform. Never returns a null. Assumes the the property "INSTALL_ROOT_PROPERTY" is set in the VM
246      * before calling this. As of now (September 2005) all the server instances and asadmin VM itself has
247      * this property set. The method does not guarantee that the script exists on the given system. It should
248      * only be used when caller wants to know the location of the script. Caller should make sure it exists.
249      * @return String representing the Path to asadmin script. Might return a string beginning with "null", if
250      * the INSTALL_ROOT_PROPERTY is not defined
251      */

252     public static final String JavaDoc getAsAdminScriptLocation() {
253         final StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
254         final String JavaDoc ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : "";
255         final String JavaDoc ASADMIN = "asadmin";
256         final String JavaDoc suffix = new StringBuilder JavaDoc("bin").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString();
257         sb.append(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
258         final String JavaDoc fs = System.getProperty("file.separator");
259         if (!sb.toString().endsWith(fs))
260             sb.append(fs);
261         sb.append(suffix);
262         
263         return ( sb.toString() );
264     }
265
266 }
267
Popular Tags