KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
25  * $Header: /cvs/glassfish/admin/mbeanapi-impl/src/java/com/sun/enterprise/management/config/VirtualServerConfigFactory.java,v 1.4 2006/03/09 20:30:42 llc Exp $
26  * $Revision: 1.4 $
27  * $Date: 2006/03/09 20:30:42 $
28  */

29 package com.sun.enterprise.management.config;
30
31 import java.util.Map JavaDoc;
32 import java.util.Properties JavaDoc;
33 import java.util.Set JavaDoc;
34 import java.util.Collections JavaDoc;
35
36 import javax.management.ObjectName JavaDoc;
37 import javax.management.AttributeList JavaDoc;
38
39 import com.sun.enterprise.management.support.oldconfig.OldConfigProxies;
40 import com.sun.enterprise.management.support.oldconfig.OldHTTPServiceMBean;
41 import com.sun.enterprise.management.support.oldconfig.OldConfigsMBean;
42
43 import com.sun.appserv.management.base.XTypes;
44 import com.sun.appserv.management.base.Util;
45
46 import com.sun.appserv.management.config.VirtualServerConfigKeys;
47
48 import com.sun.appserv.management.util.misc.MapUtil;
49 import com.sun.appserv.management.util.misc.GSetUtil;
50
51 import com.sun.enterprise.management.support.WebModuleSupport;
52
53
54
55 /**
56  */

57 public final class VirtualServerConfigFactory extends ConfigFactory
58 {
59     /**
60         @param callbacks ObjectName of the config to which this HTTPServiceConfigMBean belongs
61      */

62         public
63     VirtualServerConfigFactory( final ConfigFactoryCallback callbacks )
64     {
65         super( callbacks );
66     }
67     
68     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
69         GSetUtil.newUnmodifiableStringSet(
70         VirtualServerConfigKeys.HTTP_LISTENERS_KEY,
71         VirtualServerConfigKeys.STATE_KEY,
72         VirtualServerConfigKeys.DOC_ROOT_PROPERTY_KEY,
73         VirtualServerConfigKeys.ACCESS_LOG_PROPERTY_KEY
74 );
75     
76         protected Set JavaDoc<String JavaDoc>
77     getLegalOptionalCreateKeys()
78     {
79         return( LEGAL_OPTIONAL_KEYS );
80     }
81     
82     
83         protected Map JavaDoc<String JavaDoc,String JavaDoc>
84     getParamNameOverrides()
85     {
86         return( MapUtil.newMap( CONFIG_NAME_KEY, "id" ) );
87     }
88     
89     /**
90         The caller is responsible for dealing with any Properties.
91      */

92         protected ObjectName JavaDoc
93     createOldChildConfig(
94         final AttributeList JavaDoc translatedAttrs, final Properties JavaDoc props )
95     {
96         final String JavaDoc target = getConfigName();
97
98         final OldConfigsMBean oldConfigsMBean =
99             getOldConfigProxies().getOldConfigsMBean();
100         
101         trace( "VirtualServerConfigFactory.createOldChildConfig: creating using: " +
102             stringify( translatedAttrs ) );
103             
104         final ObjectName JavaDoc objectName =
105                 oldConfigsMBean.createVirtualServer( translatedAttrs, props, target );
106         
107         return( objectName );
108     }
109     
110     public final static String JavaDoc HOSTS_KEY = "Hosts";
111     
112     /**
113         Parameters:
114         <ul>
115         
116         <li>CONFIG_NAME_KEY</li>
117         <li>HOSTS_KEY</li>
118         <li>HTTP_LISTENERS_KEY</li>
119         <li>DEFAULT_WEB_MODULE_KEY</li>
120         <li>STATE_KEY</li>
121         <li>LOG_FILE_KEY</li>
122         <li>DOC_ROOT_KEY</li>
123         <li>ACCESS_LOG_KEY</li>
124         </ul>
125      */

126         public ObjectName JavaDoc
127     create(
128         final String JavaDoc name,
129         final String JavaDoc hosts,
130         final Map JavaDoc<String JavaDoc,String JavaDoc> optional )
131     {
132         final String JavaDoc[] requiredParams = new String JavaDoc[]
133         {
134             HOSTS_KEY, hosts,
135         };
136         
137         // special prefix
138
if ( ! WebModuleSupport.isLegalVirtualServerName( name ) )
139         {
140             throw new IllegalArgumentException JavaDoc( name );
141         }
142         
143         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams( name, requiredParams, optional );
144         
145         final ObjectName JavaDoc amxName = createNamedChild( name, params );
146         
147         return( amxName );
148     }
149     
150         public void
151     internalRemove( final ObjectName JavaDoc objectName )
152     {
153          // now - obtain Old HTTPService proxy
154
final OldHTTPServiceMBean oldHTTPServer =
155             getOldConfigProxies().getOldHTTPServiceMBean( getConfigName() );
156             
157          // and ask it to remove VirtualServer
158
final String JavaDoc name = Util.getName( objectName );
159          oldHTTPServer.removeVirtualServerById( name );
160     }
161 }
162
163
164
165
166
Popular Tags