KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.management.config;
24
25
26 import java.util.Map JavaDoc;
27
28 import javax.management.AttributeList JavaDoc;
29 import javax.management.ObjectName JavaDoc;
30
31 import com.sun.appserv.management.base.Util;
32
33 import com.sun.enterprise.management.support.oldconfig.OldApplicationsConfigMBean;
34     
35
36 public final class LifecycleModuleConfigFactory extends ConfigFactory
37 {
38         public
39     LifecycleModuleConfigFactory( final ConfigFactoryCallback callbacks )
40     {
41         super( callbacks );
42     }
43               
44     private static final String JavaDoc CLASSNAME_KEY = "class-name";
45     private static final String JavaDoc CLASSPATH_KEY = "classpath";
46     private static final String JavaDoc ENABLED_KEY = "enabled";
47     private static final String JavaDoc LOAD_ORDER_KEY = "load-order";
48     private static final String JavaDoc IS_FAILURE_FATAL_KEY = "is-failure-fatal";
49     private static final String JavaDoc DESCRIPTION_KEY = "description";
50
51
52         private OldApplicationsConfigMBean
53     getOldApplicationsConfigMBean()
54     {
55          return getOldConfigProxies().getOldApplicationsConfigMBean();
56     }
57
58     /**
59     The caller is responsible for dealing with any Properties.
60     */

61     protected ObjectName JavaDoc createOldChildConfig(
62               final AttributeList JavaDoc translatedAttrs )
63     {
64
65          trace( "LifecycleModuleConfigFactory.createOldChildConfig: creating using: " +
66              stringify( translatedAttrs ) );
67
68          final ObjectName JavaDoc objectName =
69               getOldApplicationsConfigMBean().createLifecycleModule(translatedAttrs);
70          
71          return( objectName );
72     }
73
74     /**
75         Create a new lifecycle module with all attributes specified.
76
77         @return the ObjectName of the MBean representing the new module
78     */

79         public ObjectName JavaDoc
80     create(
81         final String JavaDoc name,
82         final String JavaDoc description,
83         final String JavaDoc classname,
84         final String JavaDoc classpath,
85         final String JavaDoc loadOrder,
86         final boolean isFailureFatal,
87         final boolean enabled,
88         final Map JavaDoc<String JavaDoc,String JavaDoc> reserved )
89     {
90         final String JavaDoc[] requiredParams =
91         {
92             DESCRIPTION_KEY, (description == null ? "" : description),
93             CLASSNAME_KEY, classname,
94             CLASSPATH_KEY, (classpath == null ? "" : classpath),
95             LOAD_ORDER_KEY, loadOrder,
96             IS_FAILURE_FATAL_KEY, "" + isFailureFatal,
97             ENABLED_KEY, "" + enabled,
98         };
99
100         final Map JavaDoc<String JavaDoc,String JavaDoc> params =
101             initParams( name, requiredParams, reserved );
102
103         final ObjectName JavaDoc amxName = createNamedChild( name, params );
104         return( amxName );
105     }
106
107
108     /**
109         Removes an existing lifecycle module.
110
111         @param objectName the name of the lifecycle module to be removed.
112      */

113     public void internalRemove( final ObjectName JavaDoc objectName )
114     {
115         final String JavaDoc name = Util.getName( objectName );
116
117         getOldApplicationsConfigMBean().removeLifecycleModuleByName( name );
118     }
119 }
120
121
122
123
Popular Tags