KickJava   Java API By Example, From Geeks To Geeks.

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


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/src/java/com/sun/enterprise/management/config/AdminObjectResourceConfigFactory.java,v 1.6 2006/03/09 20:30:36 llc Exp $
26  * $Revision: 1.6 $
27  * $Date: 2006/03/09 20:30:36 $
28  */

29
30
31 package com.sun.enterprise.management.config;
32
33 import java.util.Map JavaDoc;
34 import java.util.Set JavaDoc;
35 import java.util.Properties JavaDoc;
36 import java.util.Collections JavaDoc;
37
38 import javax.management.ObjectName JavaDoc;
39 import javax.management.AttributeList JavaDoc;
40     
41 import com.sun.appserv.management.util.misc.MapUtil;
42
43 import com.sun.appserv.management.config.AMXConfig;
44 import com.sun.appserv.management.config.ResourceConfigKeys;
45 import com.sun.appserv.management.config.ResourceRefConfig;
46
47 import com.sun.appserv.management.base.XTypes;
48
49 import com.sun.enterprise.management.config.AMXConfigImplBase;
50 import com.sun.enterprise.management.support.Delegate;
51
52
53 /**
54     
55  */

56
57 public final class AdminObjectResourceConfigFactory extends ResourceFactoryImplBase
58 {
59         public
60     AdminObjectResourceConfigFactory( final ConfigFactoryCallback callbacks )
61     {
62         super( callbacks );
63     }
64     
65                        
66         protected Map JavaDoc<String JavaDoc,String JavaDoc>
67     getParamNameOverrides()
68     {
69         return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi_name" ) );
70     }
71     
72     /**
73         The caller is responsible for dealing with any Properties.
74      */

75         protected ObjectName JavaDoc
76     createOldChildConfig(
77         final AttributeList JavaDoc translatedAttrs )
78     {
79         return( getOldResourcesMBean().createAdminObjectResource( translatedAttrs ) );
80     }
81     
82     
83     /**
84          Creates a new &lt;admin-object-resource&gt;
85
86          @param jndiName
87          @param resType
88          @param resAdapter
89          @param reserved
90      */

91         public ObjectName JavaDoc
92     create(
93         final String JavaDoc jndiName,
94         final String JavaDoc resType,
95         final String JavaDoc resAdapter,
96         final Map JavaDoc<String JavaDoc,String JavaDoc> reserved )
97     {
98         final String JavaDoc[] requiredParams = new String JavaDoc[]
99         {
100             RESOURCE_TYPE_KEY, resType,
101             RESOURCE_ADAPTER_KEY, resAdapter,
102         };
103         
104         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams( jndiName, requiredParams, reserved );
105         
106         final ObjectName JavaDoc amxName = createNamedChild( jndiName, params );
107         
108         return( amxName );
109     }
110     
111     
112         protected void
113     removeByName( final String JavaDoc name )
114     {
115         final Set JavaDoc<ResourceRefConfig> refs =
116             findAllRefConfigs( XTypes.ADMIN_OBJECT_RESOURCE_CONFIG, name );
117         
118         if ( refs.size() == 0 )
119         {
120             getOldResourcesMBean().removeAdminObjectResourceByJndiName( name );
121         }
122         else
123         {
124             for( final ResourceRefConfig ref : refs )
125             {
126                 final String JavaDoc target = ref.getContainer().getName();
127                 getOldResourcesMBean().deleteAdminObjectResource( name, target );
128             }
129         }
130     }
131 }
132
133
Popular Tags