KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.management.config;
24
25 import java.util.Map JavaDoc;
26 import java.util.HashMap JavaDoc;
27
28 import javax.management.ObjectName JavaDoc;
29
30 import com.sun.appserv.management.base.Container;
31 import com.sun.appserv.management.base.XTypes;
32
33 import com.sun.appserv.management.config.AMXConfig;
34 import com.sun.appserv.management.config.DomainConfig;
35 import com.sun.appserv.management.config.CustomResourceConfig;
36
37
38 import com.sun.enterprise.management.AMXTestBase;
39 import com.sun.enterprise.management.Capabilities;
40
41 /**
42  */

43 public final class CustomResourceConfigTest extends ResourceConfigTestBase
44 {
45     static final Map JavaDoc<String JavaDoc,String JavaDoc> OPTIONAL = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
46     
47     // doesn't exist, just give a syntactically valid name
48
static private final String JavaDoc RES_TYPE = "CustomResourceConfigTest.Dummy";
49     static private final String JavaDoc FACTORY_CLASS =
50         "com.sun.enterprise.management.config.CustomResourceConfigTestDummy";
51     
52         public
53     CustomResourceConfigTest ()
54     {
55         if ( checkNotOffline( "ensureDefaultInstance" ) )
56         {
57             ensureDefaultInstance( getDomainConfig() );
58         }
59     }
60     
61         public static String JavaDoc
62     getDefaultInstanceName()
63     {
64         return getDefaultInstanceName( "CustomResourceConfig" );
65     }
66     
67     
68         public static CustomResourceConfig
69     ensureDefaultInstance( final DomainConfig domainConfig )
70     {
71         CustomResourceConfig result =
72             domainConfig.getCustomResourceConfigMap().get( getDefaultInstanceName() );
73         
74         if ( result == null )
75         {
76             result = createInstance( domainConfig,
77                 getDefaultInstanceName(), RES_TYPE, FACTORY_CLASS, null );
78         }
79         
80         return result;
81     }
82     
83         public static CustomResourceConfig
84     createInstance(
85         final DomainConfig domainConfig,
86         final String JavaDoc name,
87         final String JavaDoc resType,
88         final String JavaDoc factoryClass,
89         final Map JavaDoc<String JavaDoc,String JavaDoc> optional )
90     {
91         final CustomResourceConfig config =
92             domainConfig.createCustomResourceConfig( name, resType, factoryClass, optional );
93         
94         return config;
95     }
96     
97     
98         protected Container
99     getProgenyContainer()
100     {
101         return getDomainConfig();
102     }
103
104         protected String JavaDoc
105     getProgenyJ2EEType()
106     {
107         return XTypes.CUSTOM_RESOURCE_CONFIG;
108     }
109
110
111         protected void
112     removeProgeny( final String JavaDoc name )
113     {
114         getDomainConfig().removeCustomResourceConfig( name );
115     }
116     
117         protected String JavaDoc
118     getProgenyTestName()
119     {
120         return( "CustomResourceConfigTest" );
121     }
122     
123         protected final AMXConfig
124     createProgeny(final String JavaDoc name, final Map JavaDoc<String JavaDoc,String JavaDoc> options )
125     {
126         final CustomResourceConfig config =
127             createInstance( getDomainConfig(), name, RES_TYPE, FACTORY_CLASS, options );
128         
129         addReference( config );
130         
131         return config;
132     }
133 }
134
135
136
Popular Tags