KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > transform > elements > JavaConfig


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  * JavaConfig.java
26  *
27  * Created on August 4, 2003, 2:04 PM
28  */

29
30 package com.sun.enterprise.tools.upgrade.transform.elements;
31
32 /**
33  *
34  * @author prakash
35  */

36 import org.w3c.dom.Document JavaDoc;
37 import org.w3c.dom.Element JavaDoc;
38 import org.w3c.dom.NodeList JavaDoc;
39 import org.w3c.dom.Node JavaDoc;
40 import com.sun.enterprise.tools.upgrade.transform.ElementToObjectMapper;
41 //Added for CR 6283805
42
import java.util.List JavaDoc;
43 import java.util.StringTokenizer JavaDoc;
44
45 public class JavaConfig extends BaseElement {
46
47     //Added for CR 6283805
48
private java.util.List JavaDoc exludedJarList = null;
49
50     /** Creates a new instance of Element */
51     public JavaConfig() {
52     }
53     /**
54      * element - java-config
55      * parentSource - parent server of element
56      * parentResult - domain
57      */

58     public void transform(Element JavaDoc element, Element JavaDoc parentSource, Element JavaDoc parentResult){
59         // There is always a security service in result as well as source
60
NodeList JavaDoc javaConfs = parentResult.getElementsByTagName("java-config");
61         Element JavaDoc javaConf = null;
62         if(javaConfs.getLength() == 0){
63             NodeList JavaDoc config = parentResult.getElementsByTagName("config");
64             javaConf = parentResult.getOwnerDocument().createElement("java-config");
65             java.util.Vector JavaDoc notToTransferAttrList = new java.util.Vector JavaDoc();
66             notToTransferAttrList.add("classpath-suffix");
67             //Added for CR 6283805
68
notToTransferAttrList.add("classpath-prefix");
69             notToTransferAttrList.add("java-home");
70             // server-classpth should be parsed and should be appended to the target. FIX IT
71
notToTransferAttrList.add("server-classpath");
72             this.transferAttributes(element, javaConf, notToTransferAttrList);
73             //Added for CR 6283805
74
this.updateClassPathAttributes(element,javaConf);
75             this.appendElementToParent((Element JavaDoc)config.item(0),javaConf);
76         }else {
77             javaConf = (Element JavaDoc)javaConfs.item(0);
78             java.util.Vector JavaDoc notToTransferAttrList = new java.util.Vector JavaDoc();
79             notToTransferAttrList.add("classpath-suffix");
80             //Added for CR 6283805
81
notToTransferAttrList.add("classpath-prefix");
82             notToTransferAttrList.add("java-home");
83             notToTransferAttrList.add("server-classpath");
84             this.transferAttributes(element, javaConf, notToTransferAttrList);
85             //Added for CR 6283805
86
this.updateClassPathAttributes(element,javaConf);
87         }
88         super.transform(element, parentSource, javaConf);
89     }
90
91     //START - Added for CR 6283805
92
private void updateClassPathAttributes(Element JavaDoc source, Element JavaDoc target){
93         // update classpath-suffix
94
String JavaDoc cpSuffix = source.getAttribute("classpath-suffix");
95         if((cpSuffix != null) && (!cpSuffix.trim().equals(""))){
96             String JavaDoc cpToAppend = getClassPathStringToAppend(cpSuffix);
97             if(cpToAppend != null){
98                 String JavaDoc targetCP = target.getAttribute("classpath-suffix");
99                 if((targetCP == null) || (targetCP.trim().equals(""))){
100                     target.setAttribute("classpath-suffix", cpToAppend);
101                 }else{
102                     targetCP = targetCP+"${path.separator}"+cpToAppend;
103                     target.setAttribute("classpath-suffix", targetCP);
104                 }
105             }
106         }
107         //${com.sun.aas.installRoot}/lib/install/applications/jmsra/imqjmsra.jar${path.separator}${com.sun.aas.imqLib}/jaxm-api.jar${path.separator}${com.sun.aas.imqLib}/fscontext.jar${path.separator}${com.sun.aas.antLib}/ant.jar${path.separator}${com.sun.aas.hadbRoot}/lib/hadbjdbc4.jar${path.separator}${com.sun.aas.jdmkHome}/lib/jdmkrt.jar${path.separator}${com.sun.aas.mfwkHome}/lib/mfwk_instrum_tk.jar:C:/Softwares/SunStud/AppServer7/lib/appserv-ideplugin.jar;C:/Softwares/SunStud/MessageQueue3.5/imq/lib/imq.jar;C:/Softwares/SunStud/MessageQueue3.5/imq/lib/jaxm-api.jar;C:/Softwares/SunStud/MessageQueue3.5/imq/lib/imqadmin.jar;C:/Softwares/SunStud/MessageQueue3.5/imq/lib/imqutil.jar;C:/Softwares/SunStud/MessageQueue3.5/imq/lib/fscontext.jar;C:/Softwares/SunStud/MessageQueue3.5/imq/lib/providerutil.jar
108
// update classpath-prefix
109
String JavaDoc cpPrefix = source.getAttribute("classpath-prefix");
110         if((cpPrefix != null) && (!cpPrefix.trim().equals(""))){
111             String JavaDoc cpToAppend = getClassPathStringToAppend(cpPrefix);
112             if(cpToAppend != null){
113                 String JavaDoc targetCP = target.getAttribute("classpath-prefix");
114                 if((targetCP == null) || (targetCP.trim().equals(""))){
115                     target.setAttribute("classpath-prefix", cpToAppend);
116                 }else{
117                     targetCP = targetCP+"${path.separator}"+cpToAppend;
118                     target.setAttribute("classpath-prefix", targetCP);
119                 }
120             }
121         }
122             
123         //Added for CR 6363158
124
//Should not be transformed in the 9.0 target file
125
// update server-classpath
126
/*String cpServer = source.getAttribute("server-classpath");
127         if((cpServer != null) && (!cpServer.trim().equals(""))){
128             String cpToAppend = getClassPathStringToAppend(cpServer);
129             if(cpToAppend != null){
130                 String targetCP = target.getAttribute("server-classpath");
131                 if((targetCP == null) || (targetCP.trim().equals(""))){
132                     target.setAttribute("server-classpath", cpToAppend);
133                 }else{
134                     targetCP = targetCP+"${path.separator}"+cpToAppend;
135                     target.setAttribute("server-classpath", targetCP);
136                 }
137             }
138         }*/

139     }
140     private String JavaDoc getClassPathStringToAppend(String JavaDoc sourceCPString){
141         if(sourceCPString == null)
142             return null;
143         java.util.StringTokenizer JavaDoc tokenizer = new java.util.StringTokenizer JavaDoc(sourceCPString,System.getProperty("path.separator"));
144         String JavaDoc cpToAppend = null;
145         if(this.exludedJarList == null)
146             this.buildExcludedJarList();
147         while(tokenizer.hasMoreTokens()){
148             String JavaDoc token = tokenizer.nextToken();
149             if(this.isValidClassPathElement(token)){
150                 if(cpToAppend == null){
151                     cpToAppend = token;
152                 }else{
153                     cpToAppend = cpToAppend+"${path.separator}"+token;
154                 }
155             }
156         }
157         return cpToAppend;
158     }
159     private boolean isValidClassPathElement(String JavaDoc cp){
160         // compare the cp with
161
for(int i=0; i < this.exludedJarList.size(); i++){
162             if(cp.indexOf((String JavaDoc)this.exludedJarList.get(i)) != -1)
163                 return false;
164         }
165         return true;
166     }
167     private void buildExcludedJarList(){
168         if(this.exludedJarList !=null)
169             return;
170         this.exludedJarList = new java.util.ArrayList JavaDoc();
171         this.exludedJarList.add("pbclient42RE.jar");
172         this.exludedJarList.add("sax.jar");
173         this.exludedJarList.add("xalan.jar");
174         this.exludedJarList.add("dom.jar");
175         this.exludedJarList.add("dom4j.jar");
176         this.exludedJarList.add("xercesImpl.jar");
177         this.exludedJarList.add("jaxp-api.jar");
178         this.exludedJarList.add("jaxrpc-api.jar");
179         this.exludedJarList.add("xmlsec.jar");
180         this.exludedJarList.add("saaj-api.jar");
181         this.exludedJarList.add("jaxrpc-impl.jar");
182         this.exludedJarList.add("jaxrpc-spi.jar");
183         this.exludedJarList.add("common-logging.jar");
184         this.exludedJarList.add("saaj-impl.jar");
185         this.exludedJarList.add("mail.jar");
186         this.exludedJarList.add("activation.jar");
187         this.exludedJarList.add("jaas.jar");
188         this.exludedJarList.add("jdk_logging.jar");
189         this.exludedJarList.add("servlet.jar");
190         this.exludedJarList.add("xsltc.jar");
191         this.exludedJarList.add("relaxngDatatype.jar");
192         this.exludedJarList.add("xsdlib.jar");
193         this.exludedJarList.add("jakarta-log4j.jar");
194         this.exludedJarList.add("namespace.jar");
195         this.exludedJarList.add("appserv-rt.jar");
196         this.exludedJarList.add("jmxremote_optional.jar");
197         this.exludedJarList.add("rmissl.jar");
198         this.exludedJarList.add("appserv-tags.jar");
199         this.exludedJarList.add("jsf-api.jar");
200         this.exludedJarList.add("activation.jar");
201         this.exludedJarList.add("appserv-upgrade.jar");
202         this.exludedJarList.add("jsf-impl.jar");
203         this.exludedJarList.add("admin-cli.jar");
204         this.exludedJarList.add("appservLauncher.jar");
205         this.exludedJarList.add("j2ee-svc.jar");
206         this.exludedJarList.add("j2ee.jar");
207         this.exludedJarList.add("sun-appserv-ant.jar");
208         this.exludedJarList.add("jaxr-api.jar");
209         this.exludedJarList.add("appserv-admin.jar");
210         this.exludedJarList.add("jaxr-impl.jar");
211         this.exludedJarList.add("appserv-assemblytool.jar");
212         this.exludedJarList.add("jaxrpc-api.jar");
213         this.exludedJarList.add("appserv-cmp.jar");
214         this.exludedJarList.add("commons-launcher.jar");
215         this.exludedJarList.add("appserv-ext.jar");
216         this.exludedJarList.add("commons-logging.jar");
217         this.exludedJarList.add("jhall.jar");
218         this.exludedJarList.add("appserv-jstl.jar");
219         this.exludedJarList.add("deployhelp.jar");
220         this.exludedJarList.add("jmxremote.jar");
221         this.exludedJarList.add("relaxngDatatype.jar");
222         this.exludedJarList.add("jaxb-api.jar");
223         this.exludedJarList.add("jaxb-impl.jar");
224         this.exludedJarList.add("jaxb-libs.jar");
225         this.exludedJarList.add("jaxb-xjc.jar");
226         this.exludedJarList.add("jax-qname.jar");
227         this.exludedJarList.add("namespace.jar");
228         //this.exludedJarList.add("pbclient42RE.jar");
229
//this.exludedJarList.add("pbclient42RE.jar");
230
//this.exludedJarList.add("pbclient42RE.jar");
231
//this.exludedJarList.add("pbclient42RE.jar");
232
//this.exludedJarList.add("pbclient42RE.jar");
233
//this.exludedJarList.add("pbclient42RE.jar");
234

235     }
236     //END - Added for CR 6283805
237
}
238
Popular Tags