KickJava   Java API By Example, From Geeks To Geeks.

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


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 */

26
27 package com.sun.enterprise.management.config;
28
29 import java.util.Set JavaDoc;
30 import java.util.Map JavaDoc;
31 import java.util.HashMap JavaDoc;
32
33 import javax.management.ObjectName JavaDoc;
34 import javax.management.AttributeList JavaDoc;
35
36 import com.sun.appserv.management.config.AMXConfig;
37
38 import com.sun.appserv.management.base.Util;
39 import com.sun.appserv.management.base.XTypes;
40
41 import com.sun.appserv.management.config.ResourceRefConfig;
42 import com.sun.appserv.management.config.ResourceConfigKeys;
43 import com.sun.appserv.management.util.misc.MapUtil;
44 import com.sun.appserv.management.util.misc.GSetUtil;
45 import com.sun.appserv.management.util.jmx.JMXUtil;
46
47 import com.sun.enterprise.management.support.oldconfig.OldServerMBean;
48
49
50 public class ResourceRefConfigFactory extends ConfigFactory
51 {
52         public
53     ResourceRefConfigFactory( final ConfigFactoryCallback callbacks )
54     {
55         super( callbacks );
56     }
57
58         protected Map JavaDoc<String JavaDoc,String JavaDoc>
59     getParamNameOverrides()
60     {
61         return( MapUtil.newMap( AMXConfig.NAME_KEY, "ref" ) );
62     }
63
64     /* WHY is this code doing it this way instead of using the usual facilities? */
65         public ObjectName JavaDoc
66     create(
67         final String JavaDoc referencedResourceName,
68         final Map JavaDoc<String JavaDoc,String JavaDoc> optional)
69     {
70         final String JavaDoc j2eeType = getFactoryContainer().getJ2EEType();
71         final String JavaDoc containerName = getFactoryContainer().getName();
72
73         getOldResourcesMBean().createResourceReference(containerName, true,
74                 referencedResourceName);
75
76         ObjectName JavaDoc pattern = null;
77         if( XTypes.STANDALONE_SERVER_CONFIG.equals(j2eeType) )
78         {
79             pattern = Util.newObjectNamePattern( "com.sun.appserv",
80                 "type=resource-ref,ref=" + referencedResourceName +
81                 ",server=" + containerName);
82         }
83         else
84         {
85             pattern = Util.newObjectNamePattern( "com.sun.appserv",
86                 "type=resource-ref,ref=" + referencedResourceName +
87                 ",cluster=" + containerName);
88         }
89
90         final Set JavaDoc<ObjectName JavaDoc> oldNames =
91             JMXUtil.queryNames( getCallbacks().getMBeanServer(), pattern, null );
92         final ObjectName JavaDoc oldObjectName = GSetUtil.getSingleton( oldNames );
93
94         final ObjectName JavaDoc amxName = syncNewAMXMBeanWithOld( oldObjectName );
95
96         return( amxName );
97     }
98
99         public ObjectName JavaDoc
100     create(final String JavaDoc referencedResourceName)
101     {
102         return create(referencedResourceName, null);
103     }
104
105
106         public ObjectName JavaDoc
107     create(
108         final String JavaDoc referencedResourceName,
109         final boolean enabled)
110     {
111         final Map JavaDoc<String JavaDoc,String JavaDoc> optionalParams = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
112         optionalParams.put( ResourceConfigKeys.ENABLED_KEY,Boolean.toString(enabled));
113         
114         return create(referencedResourceName, optionalParams);
115     }
116
117         protected void
118     internalRemove( final ObjectName JavaDoc objectName )
119     {
120         final String JavaDoc containerName = getFactoryContainer().getName();
121
122         getOldResourcesMBean().deleteResourceReference( containerName, Util.getName( objectName ));
123     }
124 }
125
126
127
128
129
130
131
132
133
Popular Tags