KickJava   Java API By Example, From Geeks To Geeks.

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


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/ConnectorResourceConfigFactory.java,v 1.6 2006/03/09 20:30:37 llc Exp $
26  * $Revision: 1.6 $
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 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.base.XTypes;
42
43 import com.sun.appserv.management.config.ResourceRefConfig;
44
45 import com.sun.enterprise.management.config.AMXConfigImplBase;
46
47 import com.sun.enterprise.management.support.Delegate;
48
49 import com.sun.appserv.management.util.misc.MapUtil;
50
51
52 public final class ConnectorResourceConfigFactory extends ResourceFactoryImplBase
53 {
54         public
55     ConnectorResourceConfigFactory( final ConfigFactoryCallback callbacks )
56     {
57         super( callbacks );
58     }
59   
60         protected Map JavaDoc<String JavaDoc,String JavaDoc>
61     getParamNameOverrides()
62     {
63         return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi-name" ) );
64     }
65     
66         protected ObjectName JavaDoc
67     createOldChildConfig(
68         final AttributeList JavaDoc translatedAttrs,
69         final Properties JavaDoc props )
70     {
71         return( getOldResourcesMBean().createConnectorResource( translatedAttrs, props, null ) );
72     }
73     
74     
75     public final static String JavaDoc RESOURCE_POOL_NAME_KEY = "PoolName";
76     
77     /**
78          Creates a new &lt;connector-resource&gt;
79
80          @param jndiName
81          @param poolName
82          @param optional
83      */

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