KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > ConfigChangeFactory


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  * ConfigChangeFactory.java
26  *
27  * Created on February 19, 2004, 9:41 AM
28  */

29
30 package com.sun.enterprise.config;
31
32 import com.sun.enterprise.config.ConfigException;
33 import com.sun.enterprise.config.impl.ConfigAddImpl;
34 import com.sun.enterprise.config.impl.ConfigUpdateImpl;
35 import com.sun.enterprise.config.impl.ConfigSetImpl;
36 import com.sun.enterprise.config.impl.ConfigDeleteImpl;
37
38 import com.sun.enterprise.config.util.LoggerHelper;
39
40 /**
41  * This factory has static methods to create
42  * Configchange objects from a configbean.
43  * It creates specific ConfigChange Interfaces
44  * using the implementations from the impl package.
45  *
46  * This factory is used by the configcontext while
47  * generating config change objects during its operation.
48  *
49  * This factory can also be used by other modules to
50  * generate configChange objects that can be serialized
51  * and reapplied in a different VM
52  *
53  * @author sridatta
54  */

55 public class ConfigChangeFactory {
56   
57     /**
58      * creates a ConfigAdd object based on the parameters.
59      * This method should be used only if the configbean
60      * for the xpath already exists
61      *
62      * @return ConfigAdd object that can be applied to a different context.
63      * @param ctx from where the config bean needs to be taken
64      * @param xpath of the config bean to be used for creating configAdd
65      * @throws ConfigException
66      */

67   public static ConfigAdd createConfigAdd(ConfigContext ctx, String JavaDoc xpath) throws ConfigException {
68       try {
69         return new ConfigAddImpl(ctx, xpath);
70       } catch(ConfigException ce) {
71           LoggerHelper.info("ConfigChangeFactory.createConfigAdd: Error creating config Add", ce);
72           throw ce;
73       }
74   }
75   
76   /**
77    * This method is to be used is the config add is to be created
78    * for a config bean that is still not added to the tree
79    * @param parentXpath
80    * @param childXpath
81    * @param name
82    * @param cb
83    * @return
84    */

85   public static ConfigAdd createConfigAdd(String JavaDoc parentXpath,
86                             String JavaDoc childXpath,
87                             String JavaDoc name,
88                             ConfigBean cb) {
89     return new ConfigAddImpl(parentXpath, childXpath, name, cb);
90   }
91   
92   /**
93    * creates a ConfigUpdate given old and new value
94    * @param xpath
95    * @param attrName
96    * @param oldValue
97    * @param newValue
98    * @return
99    */

100   public static ConfigUpdate createConfigUpdate(String JavaDoc xpath,
101                             String JavaDoc attrName,
102                             String JavaDoc oldValue,
103                             String JavaDoc newValue) {
104        return new ConfigUpdateImpl(xpath, attrName, oldValue, newValue);
105   }
106
107   /**
108    * creates a ConfigSet
109    * @return
110    */

111   public static ConfigSet createConfigSet(String JavaDoc parentXpath,
112                             String JavaDoc name,
113                             Object JavaDoc cb,
114                             Object JavaDoc[] cbArray) {
115        return new ConfigSetImpl(parentXpath, name, cb, cbArray);
116   }
117   
118   /**
119    * creates a configdelete
120    */

121   public static ConfigDelete createConfigDelete(String JavaDoc xpath) {
122       return new ConfigDeleteImpl(xpath);
123   }
124 }
125
Popular Tags