KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > impl > ConfigAddImpl


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
28  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
29
30  *
31
32  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
33
34  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
35
36  * All rights reserved.
37
38  */

39
40 package com.sun.enterprise.config.impl;
41
42
43
44 import java.io.Serializable JavaDoc;
45
46 import java.util.HashMap JavaDoc;
47
48 import java.util.Set JavaDoc;
49
50 import java.util.Iterator JavaDoc;
51
52
53
54 import com.sun.enterprise.config.ConfigBean;
55 import com.sun.enterprise.config.ConfigContext;
56 import com.sun.enterprise.config.util.LoggerHelper;
57 import com.sun.enterprise.config.util.ConfigXPathHelper;
58 import com.sun.enterprise.config.ConfigException;
59 import java.io.IOException JavaDoc;
60
61
62 /**
63
64  * A configuration change for an element. Holds xpath, list of changed
65
66  * attributes, their old and new values.
67
68  */

69
70 public class ConfigAddImpl extends ConfigChangeImpl implements com.sun.enterprise.config.ConfigAdd, Serializable JavaDoc {
71
72
73
74     private ConfigBean cb;
75
76     private String JavaDoc name;
77
78     
79
80     public String JavaDoc getConfigChangeType() {
81
82         return TYPE_ADD;
83
84     }
85
86     
87
88     public ConfigAddImpl(String JavaDoc parentXpath, String JavaDoc childXpath, String JavaDoc name, ConfigBean cb) {
89
90         this.xpath = childXpath;
91
92         this.cb = cb;
93
94         this.name = name;
95
96         this.parentXpath = parentXpath;
97
98     }
99     
100     public ConfigAddImpl(ConfigContext ctx, String JavaDoc xpath) throws ConfigException {
101         this.cb = (ConfigBean) ctx.getRootConfigBean().clone();
102         this.xpath = xpath;
103         this.name = ConfigXPathHelper.getLastNodeName(xpath);
104         this.parentXpath = ConfigXPathHelper.getParentXPath(xpath);
105     }
106
107     public ConfigBean getConfigBean() {
108
109         return cb;
110
111     }
112
113     
114
115     public String JavaDoc getName() {
116
117         return name;
118
119     }
120
121     /**
122      * Serializes this object in a synchronized block. This is
123      * necessary since schema2beans is not thread safe.
124      *
125      * Refer to bug: 6177778
126      */

127     private void writeObject(java.io.ObjectOutputStream JavaDoc out)
128             throws IOException JavaDoc {
129
130         synchronized (this) {
131             out.writeObject(cb);
132             out.writeObject(name);
133         }
134     }
135
136     /**
137      * De-serializes this object in a synchronized block. This is
138      * necessary since schema2beans is not thread safe.
139      *
140      * Refer to bug: 6177778
141      */

142     private void readObject(java.io.ObjectInputStream JavaDoc in)
143             throws IOException JavaDoc, ClassNotFoundException JavaDoc {
144
145         synchronized (this) {
146             cb = (ConfigBean) in.readObject();
147             name = (String JavaDoc) in.readObject();
148         }
149     }
150
151     public String JavaDoc toString() {
152
153         String JavaDoc ret = cb.toString() + ":add to xpath=" + getParentXPath() +"\n"
154
155                         + "childXPath = " + getXPath();
156
157         return ret;
158
159     }
160
161 }
162
163
Popular Tags