KickJava   Java API By Example, From Geeks To Geeks.

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


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

29 package com.sun.enterprise.management.config;
30
31 import java.util.Map JavaDoc;
32 import java.util.HashMap 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.ConnectorConnectionPoolConfig;
40 import com.sun.appserv.management.config.ConnectorConnectionPoolConfigKeys;
41
42 import com.sun.appserv.management.util.misc.MapUtil;
43
44 /**
45  */

46 public final class ConnectorConnectionPoolConfigTest extends ConfigMgrTestBase
47 {
48     private static final String JavaDoc CONNECTOR_DEF_NAME = "javax.resource.cci.ConnectionFactory";
49     private static final String JavaDoc RESOURCE_ADAPTOR_NAME = "cciblackbox-tx";
50     private static final Map JavaDoc<String JavaDoc,String JavaDoc> OPTIONS = MapUtil.newMap(
51         ConnectorConnectionPoolConfigKeys.IGNORE_MISSING_REFERENCES_KEY, "true" );
52
53     public ConnectorConnectionPoolConfigTest()
54     {
55         if ( checkNotOffline( "ensureDefaultInstance" ) )
56         {
57             ensureDefaultInstance( getDomainConfig() );
58         }
59     }
60     
61         public static String JavaDoc
62     getDefaultInstanceName()
63     {
64         return getDefaultInstanceName( "ConnectorConnectionPoolConfig" );
65     }
66     
67         public static ConnectorConnectionPoolConfig
68     ensureDefaultInstance( final DomainConfig dc )
69     {
70         ConnectorConnectionPoolConfig result =
71             dc.getConnectorConnectionPoolConfigMap().get( getDefaultInstanceName() );
72         
73         if ( result == null )
74         {
75             result = createInstance( dc, getDefaultInstanceName(),
76                 ResourceAdapterConfigTest.ensureDefaultInstance( dc ).getName(),
77                 CONNECTOR_DEF_NAME, OPTIONS);
78         }
79         
80         return result;
81     }
82     
83         public static ConnectorConnectionPoolConfig
84     createInstance(
85         final DomainConfig dc,
86         final String JavaDoc name,
87         final String JavaDoc resourceAdapterName,
88         final String JavaDoc connectorDefinitionName,
89         Map JavaDoc<String JavaDoc,String JavaDoc> optional)
90     {
91         return dc.createConnectorConnectionPoolConfig( name,
92                 connectorDefinitionName, resourceAdapterName, optional );
93     }
94     
95         protected Container
96     getProgenyContainer()
97     {
98         return getDomainConfig();
99     }
100
101         protected String JavaDoc
102     getProgenyJ2EEType()
103     {
104         return XTypes.CONNECTOR_CONNECTION_POOL_CONFIG;
105     }
106
107         protected void
108     removeProgeny( final String JavaDoc name )
109     {
110         getDomainConfig().removeConnectorConnectionPoolConfig( name );
111     }
112     
113         protected final AMXConfig
114     createProgeny(final String JavaDoc name, final Map JavaDoc<String JavaDoc,String JavaDoc> options )
115     {
116         final Map JavaDoc<String JavaDoc,String JavaDoc> allOptions = MapUtil.newMap( OPTIONS, options );
117         
118         final ConnectorConnectionPoolConfig config =
119             getDomainConfig().createConnectorConnectionPoolConfig(
120                        name,
121                        RESOURCE_ADAPTOR_NAME,
122                        CONNECTOR_DEF_NAME, allOptions);
123         return( config );
124     }
125 }
126
127
128
Popular Tags