KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > servermgmt > SMFService


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
24 package com.sun.enterprise.admin.servermgmt;
25 import com.sun.enterprise.util.SystemPropertyConstants;
26 import com.sun.enterprise.util.ProcessExecutor;
27 import com.sun.enterprise.util.io.FileUtils;
28 import com.sun.enterprise.util.i18n.StringManager;
29 import java.io.File JavaDoc;
30 import java.io.BufferedInputStream JavaDoc;
31 import java.io.FileInputStream JavaDoc;
32 import java.util.Date JavaDoc;
33 import java.util.HashMap JavaDoc;
34 import java.util.HashSet JavaDoc;
35 import java.util.Map JavaDoc;
36 import java.util.Arrays JavaDoc;
37 import java.util.Set JavaDoc;
38 import java.util.StringTokenizer JavaDoc;
39 import java.util.Properties JavaDoc;
40
41 /** Represents the SMF Service.
42  * Holds the tokens and their values that are consumed by the SMF templates. The recommended
43  * way to use this class (or its instances) is to initialize it with default constructor
44  * and then apply various mutators to configure the service. Finally, callers should
45  * make sure that the configuration is valid, before attempting to create the service in
46  * the Solaris platform.
47  * @since SJSAS 9.0
48  * @see #isConfigValid
49  * @see SMFServiceHandler
50  */

51 public class SMFService {
52     
53     public static final String JavaDoc DATE_CREATED_TN = "DATE_CREATED";
54     public static final String JavaDoc SERVICE_NAME_TN = "NAME";
55     public static final String JavaDoc SERVICE_TYPE_TN = "TYPE";
56     public static final String JavaDoc CFG_LOCATION_TN = "LOCATION";
57     public static final String JavaDoc ENTITY_NAME_TN = "ENTITY_NAME";
58     public static final String JavaDoc FQSN_TN = "FQSN";
59     public static final String JavaDoc AS_ADMIN_PATH_TN = "AS_ADMIN_PATH";
60     public static final String JavaDoc AS_ADMIN_USER_TN = "AS_ADMIN_USER";
61     public static final String JavaDoc AS_ADMIN_PASSWORD_TN = "AS_ADMIN_PASSWORD";
62     public static final String JavaDoc AS_ADMIN_MASTERPASSWORD_TN = "AS_ADMIN_MASTERPASSWORD";
63     public static final String JavaDoc PASSWORD_FILE_PATH_TN = "PASSWORD_FILE_PATH";
64     public static final String JavaDoc TIMEOUT_SECONDS_TN = "TIMEOUT_SECONDS";
65     public static final String JavaDoc OS_USER_TN = "OS_USER";
66     public static final String JavaDoc PRIVILEGES_TN = "PRIVILEGES";
67     
68     public static final String JavaDoc TIMEOUT_SECONDS_DV = "0";
69     public static final String JavaDoc AS_ADMIN_USER_DEF_VAL = "admin";
70     public static final String JavaDoc SVCCFG = "svccfg";
71     public static final String JavaDoc SP_DELIMITER = ":";
72     public static final String JavaDoc PRIVILEGES_DEFAULT_VAL = "basic";
73     public static final String JavaDoc NETADDR_PRIV_VAL = "net_privaddr";
74     public static final String JavaDoc BASIC_NETADDR_PRIV_VAL = PRIVILEGES_DEFAULT_VAL + "," + NETADDR_PRIV_VAL;
75     public static final String JavaDoc START_INSTANCES_TN = "START_INSTANCES";
76     public static final String JavaDoc START_INSTANCES_DEFAULT_VAL = Boolean.TRUE.toString();
77     public static final String JavaDoc NO_START_INSTANCES_PROPERTY = "startinstances=false";
78
79     public static final String JavaDoc MANIFEST_HOME = "/var/svc/manifest/application/SUNWappserver/";
80     
81     private static final String JavaDoc NULL_VALUE = "null";
82     private static final String JavaDoc SERVICE_NAME_PREFIX = "application/SUNWappserver/";
83     private static final StringManager sm = StringManager.getManager(SMFService.class);
84     private static final String JavaDoc nullArgMsg = sm.getString("null_arg");
85     private static final String JavaDoc MANIFEST_FILE_SUFFIX = "-service-smf.xml";
86     private static final String JavaDoc MANIFEST_FILE_TEMPL_SUFFIX = MANIFEST_FILE_SUFFIX + ".template";
87
88     private final Map JavaDoc<String JavaDoc, String JavaDoc> pairs;
89     
90     /**
91      * Creates SMFService instance. All the tokens are initialized to default values.
92      * Callers must verify that the tokens are properly token-replaced before
93      * using this instance.
94      */

95     public SMFService() {
96         pairs = new HashMap JavaDoc<String JavaDoc, String JavaDoc> ();
97         init();
98     }
99     
100     /**
101      * Creates SMFService instance with tokens initialized from given map. Given
102      * Map may not be null. Callers must verify that the tokens are properly token-replaced before
103      * using this instance.
104      * @param tv a Map of <String, String> that contains mappings between tokens and their values
105      * @throws IllegalArgumentException in case the parameter is null
106      */

107     public SMFService(final Map JavaDoc<String JavaDoc, String JavaDoc> tv) {
108         if (tv == null)
109             throw new IllegalArgumentException JavaDoc(nullArgMsg);
110         pairs = new HashMap JavaDoc<String JavaDoc, String JavaDoc> (tv);
111     }
112     
113     /** Returns the <code> name </code> of the SMF Service.
114      */

115     public String JavaDoc getName() {
116         return ( pairs.get(SERVICE_NAME_TN) );
117     }
118     
119     /** Sets the name of the service. Parameter may not be null,
120      * an IllegalArgumentException results otherwise.
121      */

122     public void setName(final String JavaDoc name) {
123         if (name == null)
124             throw new IllegalArgumentException JavaDoc(nullArgMsg);
125         final String JavaDoc fullName = SERVICE_NAME_PREFIX + name;
126         if (serviceNameExists(fullName)) {
127             final String JavaDoc msg = sm.getString("serviceNameExists", fullName);
128             throw new IllegalArgumentException JavaDoc(msg);
129         }
130         pairs.put(SERVICE_NAME_TN, fullName);
131     }
132     /** Returns the <code> type </code> of service as an enum AppserverServiceType, from the given String.
133      * @throws IllegalArgumentException if the enum value in the internal data structure is
134      * not valid.
135      * @see AppserverServiceType
136      */

137     public AppserverServiceType getType() {
138         return ( AppserverServiceType.valueOf(pairs.get(SERVICE_TYPE_TN)) );
139     }
140     /** Sets the type of the service to the given value in the enum.
141      * @see AppserverServiceType
142      */

143     public void setType(final AppserverServiceType type) {
144         pairs.put(SERVICE_TYPE_TN, type.toString());
145     }
146     
147     /** Returns the date the service is created.
148      * @return A String Representation of Date.
149      * @see java.util.Date
150      */

151     public String JavaDoc getDate() {
152         return ( pairs.get(DATE_CREATED_TN) );
153     }
154     /** Sets the date as the date when this service is created.
155      * @param date String representation of the date
156      * @throws IllegalArgumentException if the parameter is null
157      */

158     public void setDate(final String JavaDoc date) {
159         if (date == null)
160             throw new IllegalArgumentException JavaDoc(nullArgMsg);
161         pairs.put(DATE_CREATED_TN, date);
162     }
163     
164     /** Returns the location where configuration of the service is stored
165      * on the disk.
166      */

167     public String JavaDoc getLocation() {
168         return ( pairs.get(CFG_LOCATION_TN) );
169     }
170     /** Sets the location to the parent of given location.
171      * The location is treated as absolute and hence caller
172      * must ensure that it passes the absolute location.
173      */

174     public void setLocation(final String JavaDoc cfgLocation) {
175         if (cfgLocation == null)
176             throw new IllegalArgumentException JavaDoc(nullArgMsg);
177         final File JavaDoc cf = FileUtils.safeGetCanonicalFile(new File JavaDoc(cfgLocation));
178         pairs.put(CFG_LOCATION_TN, cf.getParent());
179         pairs.put(ENTITY_NAME_TN, cf.getName());
180     }
181     /** Returns the so-called <b> Fully Qualified Service Name </b> for this service.
182      * It is a function of name and location where the configuration of the
183      * service is stored. Might not return the intended value if the name and/or
184      * location is not set prior to this call.
185      * @return String representing the place where the manifest is stored
186      */

187     public String JavaDoc getFQSN() {
188         return ( pairs.get(FQSN_TN) );
189     }
190     /** Sets the so-called <b> Fully Qualified Service Name </b> for this service.
191      * Note that there is no parameter accepted by this method. This is because the
192      * <b> Fully Qualified Service Name </b> is a function of name and location. The
193      * callers are expected to call this method once name and location is set on
194      * this service.
195      */

196     public void setFQSN() {
197         //note that this is function of name and location
198
//note that it is a programming error to call this method b4 setName()
199
assert !NULL_VALUE.equals(pairs.get(SERVICE_NAME_TN)):"Internal: Caller tried to call this method before setName()";
200         final String JavaDoc underscored = pairs.get(ENTITY_NAME_TN) + pairs.get(CFG_LOCATION_TN).replace('/', '_');
201         pairs.put(FQSN_TN, underscored);
202     }
203     
204     /** Returns the absolute path to the asadmin script.
205      */

206     public String JavaDoc getAsadminPath() {
207         return (pairs.get(AS_ADMIN_PATH_TN) );
208     }
209     /** Sets the absolute path to the asadmin script. May not be null.
210      */

211     public void setAsadminPath(final String JavaDoc path) {
212         if (path == null)
213             throw new IllegalArgumentException JavaDoc(nullArgMsg);
214         if (! new File JavaDoc(path).exists()) {
215             final String JavaDoc msg = sm.getString("doesNotExist", path);
216             throw new IllegalArgumentException JavaDoc(msg);
217         }
218         pairs.put(AS_ADMIN_PATH_TN, path);
219     }
220     /** Returns the absolute path of the password file that contains asadmin
221      * authentication artifacts.
222      */

223     public String JavaDoc getPasswordFilePath() {
224         return (pairs.get(PASSWORD_FILE_PATH_TN) );
225     }
226     /** Sets the absolute path of the password file that contains asadmin
227      * authentication artifacts. Parameter may not be null.
228      */

229     public void setPasswordFilePath(final String JavaDoc path) {
230         if (path == null)
231             throw new IllegalArgumentException JavaDoc(nullArgMsg);
232         String JavaDoc msg = null;
233         if (!new File JavaDoc(path).exists()) {
234             msg = sm.getString("doesNotExist", path);
235             throw new IllegalArgumentException JavaDoc(msg);
236         }
237         final String JavaDoc cp = FileUtils.safeGetCanonicalPath(new File JavaDoc(path));
238         final Map JavaDoc<String JavaDoc, String JavaDoc> tv = new HashMap JavaDoc<String JavaDoc, String JavaDoc> ();
239         if (!fileContainsToken(cp, AS_ADMIN_USER_TN, tv)) {
240             msg = sm.getString("missingParamsInFile", cp, AS_ADMIN_USER_TN);
241             throw new IllegalArgumentException JavaDoc(msg);
242         }
243         if (!fileContainsToken(cp, AS_ADMIN_PASSWORD_TN, tv)) {
244             msg = sm.getString("missingParamsInFile", cp, AS_ADMIN_PASSWORD_TN);
245             throw new IllegalArgumentException JavaDoc(msg);
246         }
247         if (!fileContainsToken(path, AS_ADMIN_MASTERPASSWORD_TN, tv)) {
248             msg = sm.getString("missingParamsInFile", cp, AS_ADMIN_MASTERPASSWORD_TN);
249             throw new IllegalArgumentException JavaDoc(msg);
250         }
251         pairs.put(AS_ADMIN_USER_TN, tv.get(AS_ADMIN_USER_TN));
252         pairs.put(PASSWORD_FILE_PATH_TN, cp);
253     }
254     /** Returns timeout in seconds before the master boot restarter should
255      * give up starting this service.
256      */

257     public int getTimeoutSeconds() {
258         final int to = Integer.parseInt(pairs.get(TIMEOUT_SECONDS_TN));
259         return ( to );
260     }
261     /** Sets timeout in seconds before the master boot restarter should
262      * give up starting this service.
263      * @param number a non-negative integer representing timeout. A value of zero implies infinite timeout.
264      */

265     public void setTimeoutSeconds(final int number) {
266         Integer JavaDoc to = new Integer JavaDoc(number);
267         if (to < 0) {
268             final String JavaDoc msg = sm.getString("invalidTO", number);
269             throw new IllegalArgumentException JavaDoc(msg);
270         }
271         pairs.put(TIMEOUT_SECONDS_TN, to.toString() );
272     }
273     /** Returns the OS-level user-id who should start and own the processes started
274      * by this service.
275      */

276     public String JavaDoc getOSUser() {
277         return (pairs.get(OS_USER_TN) );
278     }
279     /** Sets the OS-level user-id who should start and own the processes started
280      * by this service. This user is the same as the value returned by
281      * System.getProperty("user.name"). The idea is that the method is
282      * called by the user who actually wants to own the service.
283      * @throws IllegalArgumentException if the user can not modify MANIFEST_HOME
284      * @throws IllegalArgumentException if solaris.smf.modify Authorization is not implied by the authorizations available for the user.
285      */

286     public void setOSUser() {
287         final String JavaDoc user = System.getProperty("user.name");
288         String JavaDoc msg;
289         if (!canCreateManifest()) {
290             msg = sm.getString("noPermissionToCreateManifest", user, MANIFEST_HOME);
291             throw new IllegalArgumentException JavaDoc(msg);
292         }
293         final StringBuilder JavaDoc auths = new StringBuilder JavaDoc();
294         if (!isUserSmfAuthorized(user, auths)) {
295             msg = sm.getString("noSmfAuth", user, auths);
296             throw new IllegalArgumentException JavaDoc(msg);
297         }
298         pairs.put(OS_USER_TN, user);
299     }
300     
301     /** Returns the additional properties of the Service.
302      * @return String representing addtional properties of the service. May return default properties as well.
303      */

304     public String JavaDoc getServiceProperties() {
305         return ( pairs.get(PRIVILEGES_TN) );
306     }
307     
308     /** Sets the additional service properties that are specific to it.
309      * @param must be a colon separated String, if not null. No effect, if null is passed.
310      */

311     public void setServiceProperties(final String JavaDoc cds) {
312         /* For now, we have to take care of only net_privaddr privilege property.
313          * Additional properties will result in additional tokens being replaced.
314          * A null value for parameter results in setting the basic privilege property.
315          */

316         if (cds != null) {
317             final Set JavaDoc<String JavaDoc> props = ps2Pairs(cds);
318             if (props.contains(NETADDR_PRIV_VAL)) {
319                 pairs.put(PRIVILEGES_TN, BASIC_NETADDR_PRIV_VAL); // you get both basic, netaddr_priv
320
}
321             if (props.contains(NO_START_INSTANCES_PROPERTY)) {
322                pairs.put(START_INSTANCES_TN, Boolean.FALSE.toString());
323             }
324         }
325     }
326     
327     /** Determines if the configuration of the method is valid. When this class
328      * is constructed, appropriate defaults are used. But before attempting to create
329      * the service in the Solaris platform, it is important that the necessary
330      * configuration is done by the users via various mutator methods of this class.
331      * This method must be called to guard against some abnormal failures before
332      * creating the service. It makes sure that the caller has set all the necessary
333      * parameters reasonably. Note that it does not validate the actual values.
334      * @throws RuntimeException if the configuration is not valid
335      * @return true if the configuration is valid, an exception is thrown otherwise
336      */

337     public boolean isConfigValid() {
338         final Set JavaDoc<String JavaDoc> keys = pairs.keySet();
339         for (final String JavaDoc k : keys) {
340             final boolean aNullValue = NULL_VALUE.equals(pairs.get(k));
341             if (aNullValue) {
342                 final String JavaDoc msg = sm.getString("smfTokenNeeded", k, pairs.get(k));
343                 throw new RuntimeException JavaDoc(msg);
344             }
345         }
346         final File JavaDoc mf = new File JavaDoc(getManifestFileTemplatePath());
347         if (!mf.exists()) {
348             final String JavaDoc msg = sm.getString("serviceTemplateNotFound", getManifestFileTemplatePath());
349             throw new RuntimeException JavaDoc(msg);
350         }
351         return ( true );
352     }
353     
354     /** Returns the tokens and values of the service as a map.
355      * Note that a copy is returned.
356      * @return a copy of tokens and values
357      */

358     public Map JavaDoc<String JavaDoc, String JavaDoc> tokensAndValues() {
359         return ( new HashMap JavaDoc<String JavaDoc, String JavaDoc> (pairs) ); //send only copy
360
}
361     /** Returns the absolute location of the manifest file as SMF understands it.
362      * It takes into account the name, type and configuration location of the
363      * service. It is expected that these are set before calling this method.
364      * If the <b> Fully Qualified Service Name </b> is invalid, a RuntimeException results.
365      */

366     public String JavaDoc getManifestFilePath() {
367         final String JavaDoc fqsn = getFQSN();
368         if (NULL_VALUE.equals(fqsn)) {
369             final String JavaDoc msg = sm.getString("serviceNameInvalid", fqsn);
370             throw new RuntimeException JavaDoc(msg);
371         }
372         //now we are sure that this is called after proper configuration
373
final String JavaDoc fn = new StringBuilder JavaDoc().append(MANIFEST_HOME).append(fqsn).append("/").append(this.getType().toString()).append(MANIFEST_FILE_SUFFIX).toString();
374         return ( fn ) ;
375     }
376     /** Returns the absolute location of the template for the given service.
377      * The type of the service must be set before calling this method, otherwise
378      * a runtime exception results.
379      */

380     public String JavaDoc getManifestFileTemplatePath() {
381         /* Implementation Note: This should actually come from PEFileLayout or EEFileLayout, but
382          * it is too complex to get access to PEFileLayout instance and hence this
383          * (rather incorrect) approach of getting template path information is
384          */

385         if (NULL_VALUE.equals(getType().toString())) {
386             final String JavaDoc msg = sm.getString("serviceTypeNotSet");
387             throw new RuntimeException JavaDoc(msg);
388         }
389         final StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
390         sb.append(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
391         if (sb.charAt(sb.length() - 1) == '/')
392             sb.setLength(sb.length() - 1); //strip trailing '/' if present
393
sb.append("/lib/install/templates/");
394         sb.append(this.getType().toString()); //Domain or NodeAgent
395
sb.append(MANIFEST_FILE_TEMPL_SUFFIX); //-service.xml.template
396
return ( sb.toString() );
397     }
398     /** Returns a String representation of the SMFService. It contains a new-line
399         separated "name=value" String that contains the name and value of each of
400         of the tokens that were set in the service.
401         @return a String according to above description, never returns null
402     */

403     public String JavaDoc toString() {
404         /* toString method useful for debugging */
405         final StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
406         final String JavaDoc[] ka = new String JavaDoc[pairs.size()];
407         Arrays.sort(pairs.keySet().toArray(ka));
408         for (final String JavaDoc n : ka) {
409             sb.append(n).append("=").append(pairs.get(n)).append(System.getProperty("line.separator"));
410         }
411         return ( sb.toString() );
412     }
413
414     private void init() {
415         pairs.put(DATE_CREATED_TN, new Date JavaDoc().toString());
416         pairs.put(SERVICE_NAME_TN, NULL_VALUE);
417         pairs.put(SERVICE_TYPE_TN, NULL_VALUE);
418         pairs.put(CFG_LOCATION_TN, NULL_VALUE);
419         pairs.put(ENTITY_NAME_TN, NULL_VALUE);
420         pairs.put(FQSN_TN, NULL_VALUE);
421         pairs.put(START_INSTANCES_TN, START_INSTANCES_DEFAULT_VAL);
422         pairs.put(AS_ADMIN_PATH_TN, NULL_VALUE);
423         pairs.put(AS_ADMIN_USER_TN, AS_ADMIN_USER_DEF_VAL);
424         pairs.put(PASSWORD_FILE_PATH_TN, NULL_VALUE);
425         pairs.put(TIMEOUT_SECONDS_TN, TIMEOUT_SECONDS_DV);
426         pairs.put(OS_USER_TN, NULL_VALUE);
427         pairs.put(PRIVILEGES_TN, PRIVILEGES_DEFAULT_VAL);
428     }
429     private Set JavaDoc<String JavaDoc> ps2Pairs(final String JavaDoc cds) {
430         final StringTokenizer JavaDoc p = new StringTokenizer JavaDoc(cds, SP_DELIMITER);
431         final Set JavaDoc<String JavaDoc> tokens = new HashSet JavaDoc<String JavaDoc>();
432         while (p.hasMoreTokens()) {
433             tokens.add(p.nextToken());
434         }
435         return ( tokens );
436     }
437     private boolean canCreateManifest() {
438         final File JavaDoc mh = new File JavaDoc(MANIFEST_HOME);
439         boolean ok = true;
440         if (!mh.exists()) {
441             ok = mh.mkdirs();
442         }
443         if (ok) {
444             if (!mh.canWrite()) {
445                 ok = false;
446             }
447         }
448         return ( ok );
449     }
450     private boolean isUserSmfAuthorized(final String JavaDoc user, final StringBuilder JavaDoc auths) {
451           boolean authorized = false;
452           String JavaDoc path2Auths = "auths";
453           String JavaDoc at = ",";
454           final String JavaDoc AUTH1 = "solaris.*";
455           final String JavaDoc AUTH2 = "solaris.smf.*";
456           final String JavaDoc AUTH3 = "solaris.smf.modify";
457           if (System.getProperty("PATH_2_AUTHS") != null)
458               path2Auths = System.getProperty("PATH_2_AUTHS");
459           if (System.getProperty("AUTH_TOKEN") != null)
460               at = System.getProperty("AUTH_TOKEN");
461           try {
462               final String JavaDoc[] cmd = new String JavaDoc[]{path2Auths, user};
463               ProcessExecutor pe = new ProcessExecutor(cmd);
464               pe.setExecutionRetentionFlag(true);
465               pe.execute();
466               auths.append(pe.getLastExecutionOutput());
467               final StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(pe.getLastExecutionOutput(), at);
468               while (st.hasMoreTokens()) {
469                   String JavaDoc t = st.nextToken();
470                   if (t != null)
471                       t = t.trim();
472                   if (AUTH1.equals(t) || AUTH2.equals(t) || AUTH3.equals(t)) {
473                       authorized = true;
474                       break;
475                   }
476               }
477               return ( authorized );
478          } catch(Exception JavaDoc e) {
479              throw new RuntimeException JavaDoc(e);
480          }
481     }
482     private boolean fileContainsToken(final String JavaDoc path, final String JavaDoc t, final Map JavaDoc<String JavaDoc, String JavaDoc> tv) throws RuntimeException JavaDoc {
483         BufferedInputStream JavaDoc bis = null;
484         try {
485             boolean present = false;
486             bis = new BufferedInputStream JavaDoc(new FileInputStream JavaDoc(path));
487             final Properties JavaDoc p = new Properties JavaDoc();
488             p.load(bis);
489             if (p.containsKey(t)) {
490                 tv.put(t, (String JavaDoc)p.get(t));
491                 present = true;
492             }
493             return ( present );
494         }
495         catch(final Exception JavaDoc e) {
496             throw new RuntimeException JavaDoc(e);
497         }
498         finally {
499             if (bis != null)
500                 try {
501                     bis.close();
502                 } catch(Exception JavaDoc ee) {}
503         }
504     }
505     private boolean serviceNameExists(final String JavaDoc sn) {
506         boolean exists = false;
507         try {
508             final String JavaDoc[] cmd = new String JavaDoc[] {"svcs", sn};
509             ProcessExecutor pe = new ProcessExecutor(cmd);
510             pe.setExecutionRetentionFlag(true);
511             pe.execute();
512             exists = true;
513         } catch(final Exception JavaDoc e) {
514             //returns a non-zero status -- the service does not exist, status is already set
515
}
516         return ( exists );
517     }
518     public enum AppserverServiceType {
519         Domain,
520         NodeAgent
521     }
522 }
523
Popular Tags