KickJava   Java API By Example, From Geeks To Geeks.

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


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.Set JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.util.Collections JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30 import javax.management.AttributeList JavaDoc;
31
32
33 import com.sun.appserv.management.base.XTypes;
34
35 import com.sun.appserv.management.util.misc.MapUtil;
36 import com.sun.appserv.management.util.misc.GSetUtil;
37
38 import com.sun.appserv.management.config.PersistenceManagerFactoryResourceConfigKeys;
39 import com.sun.appserv.management.config.ResourceRefConfig;
40
41 /**
42     
43  */

44 public final class PersistenceManagerFactoryResourceConfigFactory extends ResourceFactoryImplBase
45 {
46         public
47     PersistenceManagerFactoryResourceConfigFactory( final ConfigFactoryCallback callbacks )
48     {
49         super( callbacks );
50     }
51
52     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
53         GSetUtil.newUnmodifiableStringSet(
54             PersistenceManagerFactoryResourceConfigKeys.FACTORY_CLASS_KEY,
55             PersistenceManagerFactoryResourceConfigKeys.JDBC_RESOURCE_JNDI_NAME_KEY );
56     
57         protected Set JavaDoc<String JavaDoc>
58     getLegalOptionalCreateKeys()
59     {
60         return( LEGAL_OPTIONAL_KEYS );
61     }
62     
63        
64         /**
65         The caller is responsible for dealing with any Properties.
66      */

67         protected ObjectName JavaDoc
68     createOldChildConfig(
69         final AttributeList JavaDoc translatedAttrs )
70     {
71         final ObjectName JavaDoc objectName =
72                 getOldResourcesMBean().createPersistenceManagerFactoryResource( translatedAttrs );
73         
74         return( objectName );
75     }
76                 
77         protected Map JavaDoc<String JavaDoc,String JavaDoc>
78     getParamNameOverrides()
79     {
80         return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi-name" ) );
81     }
82                 
83                 
84     /**
85         Create a new &lt;persistence-resource%gt;
86         
87         @param jndiName
88         @param optional
89      */

90         public ObjectName JavaDoc
91     create( final String JavaDoc jndiName, final Map JavaDoc<String JavaDoc,String JavaDoc> optional)
92     {
93         final String JavaDoc[] requiredParams = new String JavaDoc[]{};
94         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams( jndiName, requiredParams, optional );
95         final ObjectName JavaDoc amxName = createNamedChild( jndiName, params );
96         return( amxName );
97     }
98
99         protected void
100     removeByName( final String JavaDoc name )
101     {
102         final Set JavaDoc<ResourceRefConfig> refs =
103             findAllRefConfigs( XTypes.PERSISTENCE_MANAGER_FACTORY_RESOURCE_CONFIG, name );
104         
105         if ( refs.size() == 0 )
106         {
107             getOldResourcesMBean().removePersistenceManagerFactoryResourceByJndiName( name );
108         }
109         else
110         {
111             for( final ResourceRefConfig ref : refs )
112             {
113                 final String JavaDoc target = ref.getContainer().getName();
114                 getOldResourcesMBean().deletePersistenceManagerFactoryResource( name, target );
115             }
116         }
117     }
118     
119 }
120
121
Popular Tags