KickJava   Java API By Example, From Geeks To Geeks.

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


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/tests/com/sun/enterprise/management/config/JDBCConnectionPoolConfigTest.java,v 1.5 2006/03/09 20:30:54 llc Exp $
26  * $Revision: 1.5 $
27  * $Date: 2006/03/09 20:30:54 $
28  */

29 package com.sun.enterprise.management.config;
30
31 import java.util.Collections JavaDoc;
32 import java.util.Map JavaDoc;
33
34 import com.sun.appserv.management.base.Container;
35 import com.sun.appserv.management.base.XTypes;
36
37 import com.sun.appserv.management.config.AMXConfig;
38 import com.sun.appserv.management.config.DomainConfig;
39 import com.sun.appserv.management.config.JDBCConnectionPoolConfig;
40
41 /**
42  */

43 public final class JDBCConnectionPoolConfigTest extends ConfigMgrTestBase
44 {
45     private static final String JavaDoc JDBC_DATASOURCE_CLASSNAME = "com.pointbase.xa.xaDataSource";
46
47
48     public JDBCConnectionPoolConfigTest()
49     {
50         if ( checkNotOffline( "ensureDefaultInstance" ) )
51         {
52             ensureDefaultInstance( getDomainConfig() );
53         }
54     }
55     
56           public static String JavaDoc
57     getDefaultInstanceName()
58     {
59         return getDefaultInstanceName( "JDBCConnectionPoolConfig" );
60     }
61     
62          public static JDBCConnectionPoolConfig
63     ensureDefaultInstance( final DomainConfig domainConfig )
64     {
65         JDBCConnectionPoolConfig result =
66             domainConfig.getJDBCConnectionPoolConfigMap().get(
67                 getDefaultInstanceName() );
68         
69         if ( result == null )
70         {
71             result = createInstance( domainConfig,
72                 getDefaultInstanceName(), JDBC_DATASOURCE_CLASSNAME, null );
73         }
74         
75         return result;
76     }
77     
78         public static JDBCConnectionPoolConfig
79     createInstance(
80         final DomainConfig domainConfig,
81         final String JavaDoc name,
82         final String JavaDoc datasourceClassname,
83         final Map JavaDoc<String JavaDoc,String JavaDoc> optional )
84     {
85         return domainConfig.createJDBCConnectionPoolConfig(
86                 name, datasourceClassname, optional );
87     }
88     
89     
90         protected Container
91     getProgenyContainer()
92     {
93         return getDomainConfig();
94     }
95
96         protected String JavaDoc
97     getProgenyJ2EEType()
98     {
99         return XTypes.JDBC_CONNECTION_POOL_CONFIG;
100     }
101
102
103         protected void
104     removeProgeny( final String JavaDoc name )
105     {
106         getDomainConfig().removeJDBCConnectionPoolConfig( name );
107     }
108     
109         protected final AMXConfig
110     createProgeny(String JavaDoc name, Map JavaDoc<String JavaDoc,String JavaDoc> options )
111     {
112         final JDBCConnectionPoolConfig config =
113             getDomainConfig().createJDBCConnectionPoolConfig( name,
114                 JDBC_DATASOURCE_CLASSNAME,
115                 options );
116         assert( config != null );
117         return( config );
118     }
119 }
120
121
122
Popular Tags