KickJava   Java API By Example, From Geeks To Geeks.

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


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
27 import com.sun.appserv.management.base.Container;
28 import com.sun.appserv.management.base.XTypes;
29
30 import com.sun.appserv.management.config.AMXConfig;
31 import com.sun.appserv.management.config.DomainConfig;
32 import com.sun.appserv.management.config.JNDIResourceConfig;
33
34 import com.sun.appserv.management.helper.RefHelper;
35
36 /**
37  */

38 public final class JNDIResourceConfigTest extends ResourceConfigTestBase
39 {
40     private static final String JavaDoc JNDI_RESOURCE_JNDI_LOOKUP_NAME = "jndi/jndiTest";
41     private static final String JavaDoc JNDI_RESOURCE_RES_TYPE = "javax.sql.DataSource";
42     private static final String JavaDoc JNDI_RESOURCE_FACTORY_CLASS = "com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl";
43     private static final Map JavaDoc<String JavaDoc,String JavaDoc> OPTIONAL = null;
44
45         public
46     JNDIResourceConfigTest ()
47     {
48         if ( checkNotOffline( "ensureDefaultInstance" ) )
49         {
50             ensureDefaultInstance( getDomainConfig() );
51         }
52     }
53     
54          public static String JavaDoc
55     getDefaultInstanceName()
56     {
57         return getDefaultInstanceName( "JNDIResourceConfig" );
58     }
59     
60          public static JNDIResourceConfig
61     ensureDefaultInstance( final DomainConfig dc )
62     {
63         JNDIResourceConfig result =
64             dc.getJNDIResourceConfigMap().get( getDefaultInstanceName() );
65         
66         if ( result == null )
67         {
68             result = createInstance( dc,
69                 getDefaultInstanceName(),
70                 JNDI_RESOURCE_JNDI_LOOKUP_NAME,
71                 JNDI_RESOURCE_RES_TYPE,
72                 JNDI_RESOURCE_FACTORY_CLASS,
73                 OPTIONAL );
74         }
75         
76         return result;
77     }
78     
79         public static JNDIResourceConfig
80     createInstance(
81         final DomainConfig dc,
82         final String JavaDoc name,
83         final String JavaDoc jndiLookupName,
84         final String JavaDoc resType,
85         final String JavaDoc factoryClass,
86         final Map JavaDoc<String JavaDoc,String JavaDoc> optional)
87     {
88         return dc.createJNDIResourceConfig(
89                 name, jndiLookupName, resType, factoryClass , optional );
90     }
91     
92     
93         protected Container
94     getProgenyContainer()
95     {
96         return getDomainConfig();
97     }
98
99         protected String JavaDoc
100     getProgenyJ2EEType()
101     {
102         return XTypes.JNDI_RESOURCE_CONFIG;
103     }
104
105
106         protected void
107     removeProgeny( final String JavaDoc name )
108     {
109         final JNDIResourceConfig item =
110             getDomainConfig().getJNDIResourceConfigMap().get( name );
111         
112         getDomainConfig().removeJNDIResourceConfig( name );
113     }
114
115         protected final AMXConfig
116     createProgeny(final String JavaDoc name, final Map JavaDoc<String JavaDoc,String JavaDoc> options)
117     {
118         final JNDIResourceConfig config = getDomainConfig().createJNDIResourceConfig( name,
119                 JNDI_RESOURCE_JNDI_LOOKUP_NAME,
120                 JNDI_RESOURCE_RES_TYPE,
121                 JNDI_RESOURCE_FACTORY_CLASS,
122                 options );
123         
124         addReference( config );
125         
126         return( config );
127     }
128 }
129
130
131
Popular Tags