KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > ConfigSetup


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.management.config;
25
26 import java.util.Map JavaDoc;
27 import java.util.HashMap JavaDoc;
28
29 import com.sun.appserv.management.DomainRoot;
30
31 import com.sun.appserv.management.config.ConfigConfig;
32 import com.sun.appserv.management.config.StandaloneServerConfig;
33 import com.sun.appserv.management.config.DomainConfig;
34 import com.sun.appserv.management.config.ServerConfigKeys;
35
36
37 /**
38  */

39 public final class ConfigSetup
40 {
41     final DomainRoot mDomainRoot;
42     
43     public static final String JavaDoc TEST_SERVER_NAME = "testServer";
44     public static final String JavaDoc TEST_CONFIG_NAME = TEST_SERVER_NAME + "-config";
45     
46         public
47     ConfigSetup( final DomainRoot domainRoot )
48     {
49         mDomainRoot = domainRoot;
50     }
51     
52         public DomainConfig
53     getDomainConfig()
54     {
55         return mDomainRoot.getDomainConfig();
56     }
57     
58         public ConfigConfig
59     createConfig( final String JavaDoc name)
60     {
61         final Map JavaDoc<String JavaDoc,String JavaDoc> options = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
62         
63         final ConfigConfig config =
64             getDomainConfig().createConfigConfig( name, options );
65             
66         return config;
67     }
68     
69         public boolean
70     removeConfig( final String JavaDoc name)
71     {
72        boolean exists = getDomainConfig().getConfigConfigMap().get( name ) != null;
73         
74         if ( exists )
75         {
76             getDomainConfig().removeConfigConfig( name );
77         }
78         
79        return exists;
80     }
81     
82         public void
83     setupServerPorts(
84         final Map JavaDoc<String JavaDoc,String JavaDoc> options,
85         final int basePort )
86     {
87         options.put( ServerConfigKeys.HTTP_LISTENER_1_PORT_KEY, "" + (basePort + 0) );
88         options.put( ServerConfigKeys.HTTP_LISTENER_2_PORT_KEY, "" + (basePort + 1) );
89         options.put( ServerConfigKeys.ORB_LISTENER_1_PORT_KEY, "" + (basePort + 2) );
90         options.put( ServerConfigKeys.SSL_PORT_KEY, "" + (basePort + 3) );
91         options.put( ServerConfigKeys.SSL_MUTUALAUTH_PORT_KEY, "" + (basePort + 4) );
92         options.put( ServerConfigKeys.JMX_SYSTEM_CONNECTOR_PORT_KEY, "" + (basePort + 5) );
93         options.put( ServerConfigKeys.JMS_PROVIDER_PORT_KEY, "" + (basePort + 6) );
94         options.put( ServerConfigKeys.ADMIN_LISTENER_PORT_KEY, "" + (basePort + 7) );
95     }
96     
97         public StandaloneServerConfig
98     createServer(
99         final String JavaDoc name,
100         int basePort,
101         final String JavaDoc nodeAgentName,
102         final String JavaDoc configName )
103     {
104         final Map JavaDoc<String JavaDoc,String JavaDoc> options = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
105         
106         setupServerPorts( options, basePort );
107         
108         final StandaloneServerConfig server =
109             getDomainConfig().createStandaloneServerConfig(
110                 name, nodeAgentName, configName, options );
111             
112         return server;
113     }
114     
115
116         public boolean
117     removeServer( final String JavaDoc name )
118     {
119         boolean exists = getDomainConfig().getStandaloneServerConfigMap().get( name ) != null;
120
121         if ( exists )
122         {
123             getDomainConfig().removeStandaloneServerConfig( name );
124         }
125
126         return exists;
127     }
128 }
129
130
131
132
133
134
135
Popular Tags