KickJava   Java API By Example, From Geeks To Geeks.

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


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/ConfigConfigFactory.java,v 1.8 2006/03/17 03:34:15 llc Exp $
26  * $Revision: 1.8 $
27  * $Date: 2006/03/17 03:34:15 $
28  */

29 package com.sun.enterprise.management.config;
30
31 import java.util.Map JavaDoc;
32 import java.util.Set JavaDoc;
33 import java.util.Collections JavaDoc;
34 import java.util.Properties JavaDoc;
35
36 import javax.management.ObjectName JavaDoc;
37 import javax.management.AttributeList JavaDoc;
38 import javax.management.InstanceNotFoundException JavaDoc;
39 import javax.management.IntrospectionException JavaDoc;
40 import javax.management.ReflectionException JavaDoc;
41
42
43 import com.sun.appserv.management.base.XTypes;
44 import com.sun.enterprise.management.config.AMXConfigImplBase;
45 import com.sun.enterprise.management.support.Delegate;
46
47 import com.sun.appserv.management.base.XTypes;
48
49 import com.sun.appserv.management.config.ConfigConfig;
50 import com.sun.appserv.management.config.ConfigConfigKeys;
51
52 import com.sun.appserv.management.util.jmx.JMXUtil;
53
54 import com.sun.appserv.management.util.misc.GSetUtil;
55
56 import com.sun.enterprise.management.support.ObjectNames;
57 import com.sun.enterprise.management.support.oldconfig.OldConfigsMBean;
58
59 /**
60  */

61 public final class ConfigConfigFactory extends ConfigFactory
62 {
63     private String JavaDoc mSrcConfigName;
64     private String JavaDoc mNewConfigName;
65     
66         public
67     ConfigConfigFactory( final ConfigFactoryCallback callbacks )
68     {
69         super( callbacks );
70         
71         mSrcConfigName = null;
72         mNewConfigName = null;
73     }
74     
75     private final Set JavaDoc<String JavaDoc> LEGAL_OPTIONAL_KEYS =
76         GSetUtil.newUnmodifiableStringSet(
77         ConfigConfigKeys.DYNAMIC_RECONFIGURATION_ENABLED_KEY,
78         ConfigConfigKeys.SRC_CONFIG_NAME_KEY );
79     
80         protected Set JavaDoc<String JavaDoc>
81     getLegalOptionalCreateKeys()
82     {
83         return( LEGAL_OPTIONAL_KEYS );
84     }
85     
86     
87         protected ObjectName JavaDoc
88     createOldChildConfig(
89         final AttributeList JavaDoc translatedAttrs,
90         final Properties JavaDoc props )
91     {
92         trace( "ConfigConfigFactory.createOldChildConfig: creating using: " +
93             stringify( translatedAttrs ) );
94
95         final OldConfigsMBean old = getOldConfigProxies().getOldConfigsMBean();
96         
97         final ObjectName JavaDoc objectName = old.copyConfiguration( mSrcConfigName, mNewConfigName, props);
98
99         return( objectName );
100     }
101
102         public ObjectName JavaDoc
103     create(
104         final String JavaDoc name,
105         final Map JavaDoc<String JavaDoc,String JavaDoc> optional)
106     {
107         final String JavaDoc[] requiredParams = new String JavaDoc[] {};
108         final Map JavaDoc<String JavaDoc,String JavaDoc> params = initParams(name, requiredParams, optional);
109         
110         mNewConfigName = name;
111         mSrcConfigName = (String JavaDoc)optional.get( ConfigConfigKeys.SRC_CONFIG_NAME_KEY );
112         if ( mSrcConfigName == null )
113         {
114             mSrcConfigName = ConfigConfigKeys.DEFAULT_SRC_CONFIG_NAME;
115         }
116         
117         
118         final ObjectName JavaDoc amxName = createNamedChild(name, params);
119         
120         
121         // set any optional params
122
if ( amxName != null )
123         {
124             final ConfigConfig config = getCallbacks().getProxyFactory().getProxy( amxName, ConfigConfig.class);
125             
126             Object JavaDoc value;
127             
128             value = optional.get( ConfigConfigKeys.DYNAMIC_RECONFIGURATION_ENABLED_KEY );
129             if ( value != null )
130             {
131                 config.setDynamicReconfigurationEnabled( Boolean.parseBoolean( "" + value ) );
132             }
133         }
134         
135         return( amxName );
136     }
137
138
139         protected void
140     removeByName(String JavaDoc name)
141     {
142         getOldConfigProxies().getOldConfigsMBean().deleteConfiguration(name);
143     }
144 }
145
146
147
148
149
Popular Tags