KickJava   Java API By Example, From Geeks To Geeks.

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


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
26 import java.util.HashMap JavaDoc;
27 import java.util.Properties JavaDoc;
28 import java.util.Iterator JavaDoc;
29
30 import java.util.HashSet JavaDoc;
31 import java.util.Set JavaDoc;
32 import java.util.Map JavaDoc;
33
34 import com.sun.enterprise.util.SystemPropertyConstants;
35
36 /**
37  * This class defines the keys that are used to create the domain config object.
38  * Almost all the methods of DomainsManager require the domain config to be
39  * passed as java.util.Map, the key set of which is defined here.
40  */

41 public class DomainConfig extends RepositoryConfig
42 {
43     /**
44      * These constants define the possbile Hash Map keys that can reside
45      * in DomainConfig
46      * MAKE SURE THAT KEYS FOR PORTS END IN THE STRING "PORT" (case ignored) - this
47      * is used in PEDomainConfigValidator to ensure that the ports are unique!
48      */

49     public static final String JavaDoc K_USER = "domain.user";
50     public static final String JavaDoc K_PASSWORD = "domain.password";
51     public static final String JavaDoc K_NEW_MASTER_PASSWORD = "domain.newMasterPassword";
52     public static final String JavaDoc K_MASTER_PASSWORD = "domain.masterPassword";
53     public static final String JavaDoc K_SAVE_MASTER_PASSWORD = "domain.saveMasterPassword";
54     public static final String JavaDoc K_ADMIN_PORT = "domain.adminPort";
55     public static final String JavaDoc K_INSTANCE_PORT = "domain.instancePort";
56     public static final String JavaDoc K_DOMAINS_ROOT = "domains.root";
57     public static final String JavaDoc K_HOST_NAME = "domain.hostName";
58     public static final String JavaDoc K_JMS_PASSWORD = "jms.password";
59     public static final String JavaDoc K_JMS_PORT = "jms.port";
60     public static final String JavaDoc K_JMS_USER = "jms.user";
61     public static final String JavaDoc K_ORB_LISTENER_PORT = "orb.listener.port";
62     public static final String JavaDoc K_SERVERID = "server.id";
63     public static final String JavaDoc K_TEMPLATE_NAME = "template.name";
64     public static final String JavaDoc K_HTTP_SSL_PORT = "http.ssl.port";
65     public static final String JavaDoc K_IIOP_SSL_PORT = "orb.ssl.port";
66     public static final String JavaDoc K_IIOP_MUTUALAUTH_PORT = "orb.mutualauth.port";
67     public static final String JavaDoc K_DEBUG = "domain.debug";
68     public static final String JavaDoc K_VERBOSE = "domain.verbose";
69     public static final String JavaDoc K_VALIDATE_PORTS = "domain.validatePorts";
70     //This token is used for SE/EE only now, but it is likely that we will want to expose it
71
//in PE (i.e. to access the exposed Mbeans). Remember that the http jmx port (used by
72
//asadmin) will not be exposed pubically.
73
public static final String JavaDoc K_JMX_PORT = "domain.jmxPort";
74     public static final String JavaDoc K_EXTRA_PASSWORDS = "domain.extraPasswords";
75     
76     public static final int K_FLAG_START_DOMAIN_NEEDS_ADMIN_USER = 0x1;
77     
78     /**
79      * The DomainConfig always contains the K_DOMAINS_ROOT and K_HOST_NAME
80      * attributes.
81      */

82     public DomainConfig(String JavaDoc domainName, String JavaDoc domainRoot) throws DomainException
83     {
84         super(domainName, domainRoot);
85         try {
86             put(K_DOMAINS_ROOT, domainRoot);
87             // net to get fully qualified host, not just hostname
88
put(K_HOST_NAME, System.getProperty(SystemPropertyConstants.HOST_NAME_PROPERTY));
89         } catch (Exception JavaDoc ex) {
90             throw new DomainException(ex);
91         }
92     }
93  
94     /**
95      * This constructor is used at domain creation time only.
96      */

97     public DomainConfig(String JavaDoc domainName, Integer JavaDoc adminPort, String JavaDoc domainRoot,
98         String JavaDoc adminUser, String JavaDoc adminPassword, String JavaDoc masterPassword,
99         Boolean JavaDoc saveMasterPassword, Integer JavaDoc instancePort,
100         String JavaDoc jmsUser, String JavaDoc jmsPassword, Integer JavaDoc jmsPort,
101         Integer JavaDoc orbPort, Integer JavaDoc httpSSLPort,
102         Integer JavaDoc iiopSSLPort, Integer JavaDoc iiopMutualAuthPort,
103         Integer JavaDoc jmxAdminPort,
104         Properties JavaDoc domainProperties) throws DomainException
105     {
106         this(domainName, domainRoot);
107         try {
108             put(K_ADMIN_PORT, adminPort);
109             put(K_JMS_USER, jmsUser);
110             put(K_JMS_PASSWORD, jmsPassword);
111             put(K_PASSWORD, adminPassword);
112             put(K_MASTER_PASSWORD, masterPassword);
113             put(K_SAVE_MASTER_PASSWORD, saveMasterPassword);
114             put(K_USER, adminUser);
115             put(K_INSTANCE_PORT, instancePort);
116             put(K_JMS_PORT, jmsPort);
117             put(K_ORB_LISTENER_PORT, orbPort);
118             put(K_HTTP_SSL_PORT, httpSSLPort);
119             put(K_IIOP_SSL_PORT, iiopSSLPort);
120             put(K_IIOP_MUTUALAUTH_PORT, iiopMutualAuthPort);
121             put(K_JMX_PORT, jmxAdminPort);
122
123             if(domainProperties!=null) {
124                 Iterator JavaDoc iterator = domainProperties.keySet().iterator();
125                 while (iterator.hasNext()) {
126                     String JavaDoc key = (String JavaDoc)iterator.next();
127                     String JavaDoc value = (String JavaDoc)domainProperties.get(key);
128                     put(key,value);
129                 }
130             }
131         } catch (Exception JavaDoc ex) {
132             throw new DomainException(ex);
133         }
134     }
135     
136     public String JavaDoc getDomainName() {
137         return super.getRepositoryName();
138     }
139     
140     public String JavaDoc getDomainRoot()
141     {
142         return super.getRepositoryRoot();
143     }
144
145   public Map JavaDoc getPorts(){
146     final Iterator JavaDoc it = ((Map JavaDoc) this).keySet().iterator();
147     final Map JavaDoc result = new HashMap JavaDoc();
148     while (it.hasNext()){
149       String JavaDoc key = (String JavaDoc) it.next();
150       if (key.toLowerCase().endsWith("port")){
151         result.put(key, this.get(key));
152       }
153     }
154     return result;
155   }
156     
157
158
159 }
160
Popular Tags