KickJava   Java API By Example, From Geeks To Geeks.

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


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/HTTPListenerConfigFactory.java,v 1.4 2006/03/09 20:30:38 llc Exp $
26  * $Revision: 1.4 $
27  * $Date: 2006/03/09 20:30:38 $
28  */

29 package com.sun.enterprise.management.config;
30
31 import java.util.Map JavaDoc;
32 import java.util.Set JavaDoc;
33 import java.util.Collections JavaDoc;
34
35 import javax.management.ObjectName JavaDoc;
36 import javax.management.AttributeList JavaDoc;
37
38 import com.sun.appserv.management.config.HTTPListenerConfigKeys;
39 import com.sun.appserv.management.config.HTTPServiceConfig;
40 import com.sun.appserv.management.config.VirtualServerConfig;
41
42 import com.sun.appserv.management.util.misc.MapUtil;
43
44 import com.sun.enterprise.management.support.oldconfig.OldHTTPServiceMBean;
45
46 import com.sun.appserv.management.util.misc.GSetUtil;
47
48 public final class HTTPListenerConfigFactory extends ConfigFactory
49 {
50     private final OldHTTPServiceMBean mOldHTTPServiceMBean;
51     
52         public
53     HTTPListenerConfigFactory( final ConfigFactoryCallback callbacks )
54     {
55         super( callbacks );
56         
57         mOldHTTPServiceMBean =
58             getOldConfigProxies().getOldHTTPServiceMBean( getConfigName() );
59     }
60     
61     
62     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
63         GSetUtil.newUnmodifiableStringSet(
64         HTTPListenerConfigKeys.ADDRESS_KEY,
65         HTTPListenerConfigKeys.PORT_KEY,
66         HTTPListenerConfigKeys.ENABLED_KEY,
67         HTTPListenerConfigKeys.SECURITY_ENABLED_KEY,
68         HTTPListenerConfigKeys.DEFAULT_VIRTUAL_SERVER_KEY,
69         HTTPListenerConfigKeys.ACCEPTOR_THREADS_KEY,
70         HTTPListenerConfigKeys.XPOWERED_BY_KEY,
71         HTTPListenerConfigKeys.XPOWERED_BY_KEY,
72         HTTPListenerConfigKeys.IGNORE_MISSING_REFERENCES_KEY );
73     
74         protected Set JavaDoc<String JavaDoc>
75     getLegalOptionalCreateKeys()
76     {
77         return( LEGAL_OPTIONAL_KEYS );
78     }
79     
80         protected Map JavaDoc<String JavaDoc,String JavaDoc>
81     getParamNameOverrides()
82     {
83         return( MapUtil.newMap( CONFIG_NAME_KEY, "id" ) );
84     }
85     
86         protected ObjectName JavaDoc
87     createOldChildConfig( final AttributeList JavaDoc translatedAttrs )
88     {
89         return mOldHTTPServiceMBean.createHttpListener( translatedAttrs );
90     }
91     
92     
93         private void
94     checkVirtualServerExists( final String JavaDoc virtualServerName )
95     {
96         final HTTPServiceConfig httpService = (HTTPServiceConfig)getFactoryContainer();
97         
98         final Map JavaDoc<String JavaDoc,VirtualServerConfig> virtualServers =
99             httpService.getVirtualServerConfigMap();
100         
101         if( ! virtualServers.containsKey( virtualServerName ) )
102         {
103             throw new IllegalArgumentException JavaDoc( "No virtual server exists with the name: " + virtualServerName );
104         }
105     }
106     
107     
108         public ObjectName JavaDoc
109     create(
110         final String JavaDoc name,
111         final String JavaDoc address,
112         final int port,
113         final String JavaDoc defaultVirtualServer,
114         final String JavaDoc serverName,
115         final Map JavaDoc<String JavaDoc,String JavaDoc> options )
116     {
117         final String JavaDoc[] requiredParams =
118         {
119             HTTPListenerConfigKeys.ADDRESS_KEY, address,
120             HTTPListenerConfigKeys.PORT_KEY, "" + port,
121             HTTPListenerConfigKeys.DEFAULT_VIRTUAL_SERVER_KEY, defaultVirtualServer,
122             HTTPListenerConfigKeys.SERVER_NAME_KEY, serverName,
123         };
124         
125         if ( requireValidReferences( options ) )
126         {
127             checkVirtualServerExists( defaultVirtualServer );
128         }
129
130         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams( name, requiredParams, options );
131
132         final ObjectName JavaDoc amxName = createNamedChild( name, params );
133         
134         return( amxName );
135     }
136     
137         protected final void
138     removeByName( String JavaDoc name )
139     {
140         mOldHTTPServiceMBean.removeHttpListenerById( name );
141     }
142 }
143
144
145
146
147
148
149
Popular Tags