KickJava   Java API By Example, From Geeks To Geeks.

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


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.Collections JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import com.sun.appserv.management.base.Container;
29 import com.sun.appserv.management.base.XTypes;
30
31 import com.sun.appserv.management.config.AMXConfig;
32 import com.sun.appserv.management.config.DomainConfig;
33 import com.sun.appserv.management.config.PersistenceManagerFactoryResourceConfig;
34
35 /**
36  */

37 public final class PersistenceManagerFactoryResourceConfigTest extends ResourceConfigTestBase
38 {
39     public PersistenceManagerFactoryResourceConfigTest()
40     {
41         if ( checkNotOffline( "ensureDefaultInstance" ) )
42         {
43             ensureDefaultInstance( getDomainConfig() );
44         }
45     }
46     
47          public static String JavaDoc
48     getDefaultInstanceName()
49     {
50         return getDefaultInstanceName( "PersistenceManagerFactoryResourceConfig" );
51     }
52     
53          public static PersistenceManagerFactoryResourceConfig
54     ensureDefaultInstance( final DomainConfig dc )
55     {
56         PersistenceManagerFactoryResourceConfig result =
57             dc.getPersistenceManagerFactoryResourceConfigMap().get( getDefaultInstanceName() );
58         
59         if ( result == null )
60         {
61             result = createInstance( dc,
62                 getDefaultInstanceName(),
63                 null );
64         }
65         
66         return result;
67     }
68     
69         public static PersistenceManagerFactoryResourceConfig
70     createInstance(
71         final DomainConfig dc,
72         final String JavaDoc name,
73         final Map JavaDoc<String JavaDoc,String JavaDoc> optional)
74     {
75         return dc.createPersistenceManagerFactoryResourceConfig(
76                 name, optional );
77     }
78     
79     
80     
81         protected Container
82     getProgenyContainer()
83     {
84         return getDomainConfig();
85     }
86
87         protected String JavaDoc
88     getProgenyJ2EEType()
89     {
90         return XTypes.PERSISTENCE_MANAGER_FACTORY_RESOURCE_CONFIG;
91     }
92
93
94         protected void
95     removeProgeny( final String JavaDoc name )
96     {
97         getDomainConfig().removePersistenceManagerFactoryResourceConfig( name );
98     }
99     
100         protected final AMXConfig
101     createProgeny(final String JavaDoc name, final Map JavaDoc<String JavaDoc,String JavaDoc> options )
102     {
103         final PersistenceManagerFactoryResourceConfig config =
104             getDomainConfig().createPersistenceManagerFactoryResourceConfig( name, options);
105             
106         addReference( config );
107         
108         return( config );
109     }
110 }
111
112
113
Popular Tags