KickJava   Java API By Example, From Geeks To Geeks.

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


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/CustomResourceConfigFactory.java,v 1.5 2006/03/09 20:30:37 llc Exp $
26  * $Revision: 1.5 $
27  * $Date: 2006/03/09 20:30:37 $
28  */

29
30
31 package com.sun.enterprise.management.config;
32
33 import java.util.Set JavaDoc;
34 import java.util.Map JavaDoc;
35
36 import javax.management.ObjectName JavaDoc;
37 import javax.management.AttributeList JavaDoc;
38
39 import com.sun.appserv.management.base.XTypes;
40 import com.sun.appserv.management.util.misc.MapUtil;
41
42 import com.sun.appserv.management.config.ResourceRefConfig;
43
44 /**
45     
46  */

47
48 public final class CustomResourceConfigFactory extends ResourceFactoryImplBase
49     //implements CustomResourceConfigMgr
50
{
51         public
52     CustomResourceConfigFactory( final ConfigFactoryCallback callbacks )
53     {
54         super( callbacks );
55     }
56        
57
58   
59                 
60         /**
61         The caller is responsible for dealing with any Properties.
62      */

63         protected ObjectName JavaDoc
64     createOldChildConfig(
65         final AttributeList JavaDoc translatedAttrs )
66     {
67         trace( "CustomResourceConfigFactory.createOldChildConfig: creating using: " +
68             stringify( translatedAttrs ) );
69             
70         final ObjectName JavaDoc objectName =
71                 getOldResourcesMBean().createCustomResource( translatedAttrs );
72
73         return objectName;
74     }
75     
76         protected Map JavaDoc<String JavaDoc,String JavaDoc>
77     getParamNameOverrides()
78     {
79         return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi-name" ) );
80     }
81     
82     public static final String JavaDoc RES_TYPE_KEY = "ResType";
83     public static final String JavaDoc FACTORY_CLASS_KEY = "FactoryClass";
84     
85     /**
86      Creates a new custom resource.
87
88      @param jndiName
89      @param resType
90      @param factoryClass
91      @param optional
92      */

93     public ObjectName JavaDoc create(
94         String JavaDoc jndiName,
95         String JavaDoc resType,
96         String JavaDoc factoryClass,
97         Map JavaDoc<String JavaDoc,String JavaDoc> optional)
98     {
99         final String JavaDoc[] requiredParams = new String JavaDoc[]
100         {
101             RES_TYPE_KEY, resType,
102             FACTORY_CLASS_KEY, factoryClass,
103         };
104                 
105         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams( jndiName, requiredParams, optional );
106         
107         final ObjectName JavaDoc amxName = createNamedChild( jndiName, params );
108         
109         return( amxName );
110     }
111     
112         
113         protected void
114     removeByName( final String JavaDoc name )
115     {
116         final Set JavaDoc<ResourceRefConfig> refs =
117             findAllRefConfigs( XTypes.CUSTOM_RESOURCE_CONFIG, name );
118         
119         if ( refs.size() == 0 )
120         {
121             getOldResourcesMBean().removeCustomResourceByJndiName( name );
122         }
123         else
124         {
125             for( final ResourceRefConfig ref : refs )
126             {
127                 final String JavaDoc target = ref.getContainer().getName();
128                 getOldResourcesMBean().deleteCustomResource( name, target );
129             }
130         }
131     }
132 }
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Popular Tags