KickJava   Java API By Example, From Geeks To Geeks.

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


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

29
30
31 package com.sun.enterprise.management.config;
32
33 import java.util.Set JavaDoc;
34 import java.util.Properties JavaDoc;
35 import java.util.Map JavaDoc;
36 import java.util.HashMap JavaDoc;
37 import java.util.Collections JavaDoc;
38
39 import javax.management.ObjectName JavaDoc;
40 import javax.management.AttributeList JavaDoc;
41 import javax.management.ObjectName JavaDoc;
42
43 import com.sun.appserv.management.config.DomainConfig;
44 import com.sun.appserv.management.config.ResourceAdapterConfig;
45
46 import com.sun.appserv.management.util.misc.MapUtil;
47 import com.sun.appserv.management.util.misc.GSetUtil;
48
49 import com.sun.appserv.management.config.ConnectorConnectionPoolConfigKeys;
50 import com.sun.appserv.management.config.CommonConfigKeys;
51
52 /**
53     MBean managing all instances of Connector resource.
54  */

55
56 public final class ConnectorConnectionPoolConfigFactory extends ResourceFactoryImplBase
57     // implements ConnectorConnectionPoolConfigMgr
58
{
59         public
60     ConnectorConnectionPoolConfigFactory( final ConfigFactoryCallback callbacks)
61     {
62         super( callbacks );
63     }
64      
65         
66     /**
67         The caller is responsible for dealing with any Properties.
68      */

69         protected ObjectName JavaDoc
70     createOldChildConfig(
71         final AttributeList JavaDoc translatedAttrs )
72     {
73         return( getOldResourcesMBean().createConnectorConnectionPool( translatedAttrs ) );
74     }
75     
76     
77     public static final String JavaDoc CONNECTION_DEFINITION_NAME_KEY = "ConnectionDefinitionName";
78     public static final String JavaDoc RESOURCE_ADAPTER_NAME_KEY = "ResourceAdapterName";
79     
80     
81     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
82         GSetUtil.newUnmodifiableStringSet(
83         ConnectorConnectionPoolConfigKeys.STEADY_POOL_SIZE_KEY,
84         ConnectorConnectionPoolConfigKeys.MAX_POOL_SIZE_KEY,
85         ConnectorConnectionPoolConfigKeys.MAX_WAIT_TIME_IN_MILLIS_KEY,
86         ConnectorConnectionPoolConfigKeys.POOL_RESIZE_QUANTITY_KEY,
87         ConnectorConnectionPoolConfigKeys.IDLE_TIMEOUT_IN_SECONDS_KEY,
88         ConnectorConnectionPoolConfigKeys.FAIL_ALL_CONNECTIONS_KEY,
89         ConnectorConnectionPoolConfigKeys.TRANSACTION_SUPPORT_KEY,
90         ConnectorConnectionPoolConfigKeys.TRANSACTION_SUPPORT_KEY,
91         CommonConfigKeys.IGNORE_MISSING_REFERENCES_KEY );
92     
93         protected Set JavaDoc<String JavaDoc>
94     getLegalOptionalCreateKeys()
95     {
96         return( LEGAL_OPTIONAL_KEYS );
97     }
98     
99     
100         private void
101     checkResourceAdapterExists( final String JavaDoc resourceAdapterName )
102     {
103         final Map JavaDoc<String JavaDoc,ResourceAdapterConfig> resourceAdapters =
104             getDomainRoot().getDomainConfig().getResourceAdapterConfigMap();
105         
106         if( ! resourceAdapters.containsKey( resourceAdapterName ) )
107         {
108             throw new IllegalArgumentException JavaDoc( "No resource adapter exists with the name: " + resourceAdapterName );
109         }
110     }
111     
112         public ObjectName JavaDoc
113     create(
114         final String JavaDoc name,
115         final String JavaDoc resourceAdapterName,
116         final String JavaDoc connectionDefinitionName,
117         final Map JavaDoc<String JavaDoc,String JavaDoc> options )
118     {
119         final String JavaDoc[] requiredParams = new String JavaDoc[]
120         {
121             RESOURCE_ADAPTER_NAME_KEY, resourceAdapterName,
122             CONNECTION_DEFINITION_NAME_KEY, connectionDefinitionName,
123         };
124         
125         if ( requireValidReferences( options ) )
126         {
127             checkResourceAdapterExists( resourceAdapterName );
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     
138         protected void
139     removeByName( final String JavaDoc name )
140     {
141         getOldResourcesMBean().removeConnectorConnectionPoolByName( name );
142     }
143 }
144
145
146
147
148
149
150
151
Popular Tags