KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > servermgmt > pe > PEScriptsTokens


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.pe;
25
26 import java.io.File JavaDoc;
27
28 import com.sun.enterprise.admin.util.TokenValue;
29 import com.sun.enterprise.admin.util.TokenValueSet;
30 import com.sun.enterprise.admin.servermgmt.DomainConfig;
31 import com.sun.enterprise.admin.servermgmt.pe.PEFileLayout;
32
33 /**
34  * This class defines the tokens required by the startserv & stopserv scripts.
35  */

36 public final class PEScriptsTokens
37 {
38     public static final String JavaDoc CONFIG_HOME = "CONFIG_HOME";
39     public static final String JavaDoc INSTANCE_ROOT = "INSTANCE_ROOT";
40     public static final String JavaDoc SERVER_NAME = "SERVER_NAME";
41     public static final String JavaDoc DOMAIN_NAME = "DOMAIN_NAME";
42
43     /**
44      * @return Returns the TokenValueSet that has the (token, value) pairs for
45      * startserv & stopserv scripts.
46      * @param domainConfig
47      */

48     public static TokenValueSet getTokenValueSet(DomainConfig domainConfig)
49     {
50         final PEFileLayout layout = new PEFileLayout(domainConfig);
51
52         final TokenValueSet tokens = new TokenValueSet();
53
54         final String JavaDoc configRootDir = domainConfig.getConfigRoot();
55         TokenValue tv = new TokenValue(CONFIG_HOME, configRootDir);
56         tokens.add(tv);
57
58         final String JavaDoc instanceRoot =
59             layout.getRepositoryDir().getAbsolutePath();
60         tv = new TokenValue(INSTANCE_ROOT, instanceRoot);
61         tokens.add(tv);
62
63         final String JavaDoc instanceName = (String JavaDoc)domainConfig.get(DomainConfig.K_SERVERID);
64         if((instanceName == null) || (instanceName.equals("")))
65             tv = new TokenValue(SERVER_NAME, PEFileLayout.DEFAULT_INSTANCE_NAME);
66         else
67             tv = new TokenValue(SERVER_NAME, instanceName);
68         tokens.add(tv);
69
70         tv = new TokenValue(DOMAIN_NAME, domainConfig.getDomainName());
71         tokens.add(tv);
72
73         return ( tokens );
74     }
75 }
76
Popular Tags