KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > j2ee > PlatformImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.sun.ide.j2ee;
21
22 import java.awt.Image JavaDoc;
23 import java.io.File JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.net.MalformedURLException JavaDoc;
26 import java.net.URL JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.HashSet JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Set JavaDoc;
31 import org.netbeans.api.java.platform.JavaPlatform;
32 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
33 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
34 import org.openide.ErrorManager;
35 import org.openide.filesystems.FileUtil;
36 import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider;
37 import org.netbeans.modules.j2ee.deployment.plugins.api.J2eePlatformImpl;
38 import org.netbeans.spi.project.libraries.LibraryImplementation;
39 import org.openide.util.NbBundle;
40 import org.openide.util.Utilities;
41
42 /**
43  */

44 public class PlatformImpl extends J2eePlatformImpl {
45     
46     private static final Set JavaDoc/*<Object>*/ MODULE_TYPES = new HashSet JavaDoc();
47     private static final Set JavaDoc/*<String>*/ SPEC_VERSIONS = new HashSet JavaDoc();
48     private static final Set JavaDoc/*<String>*/ SPEC_VERSIONS_WITH_5 = new HashSet JavaDoc();
49     // Appserver version strings.
50
private static final String JavaDoc APPSERVER_VERSION_9_1 = "9.1"; // NOI18N
51
private static final String JavaDoc APPSERVER_VERSION_9 = "9.0"; // NOI18N
52
private static final String JavaDoc APPSERVER_VERSION_8_1 = "8.1"; // NOI18N
53
private static final String JavaDoc APPSERVER_VERSION_8_2 = "8.2"; // NOI18N
54
private static final String JavaDoc APPSERVER_VERSION_UNKNOWN = "unknown"; // NOI18N
55
private String JavaDoc version = APPSERVER_VERSION_UNKNOWN; // NOI18N
56
private static final String JavaDoc J2EE_14_JAR = "lib/j2ee.jar"; //NOI18N
57
private static final String JavaDoc JAVA_EE_JAR = "lib/javaee.jar"; //NOI18N
58
private static final String JavaDoc JSF_API_JAR = "lib/jsf-api.jar"; //NOI18N
59
private static final String JavaDoc JSF_IMPL_JAR = "lib/jsf-impl.jar"; //NOI18N
60
private static final String JavaDoc JAX_QNAME_JAR = "lib/jax-qname.jar"; //NOI18N
61
private static final String JavaDoc JAXRPC_API_JAR = "lib/jaxrpc-api.jar"; //NOI18N
62
private static final String JavaDoc JAXRPC_IMPL_JAR = "lib/jaxrpc-impl.jar"; //NOI18N
63
private static final String JavaDoc JAXR_API_JAR = "lib/jaxr-api.jar"; //NOI18N
64
private static final String JavaDoc JAXR_IMPL_JAR = "lib/jaxr-impl.jar"; //NOI18N
65
private static final String JavaDoc SAAJ_API_JAR = "lib/saaj-api.jar"; //NOI18N
66
private static final String JavaDoc SAAJ_IMPL_JAR = "lib/saaj-impl.jar"; //NOI18N
67

68     private static final String JavaDoc ACTIVATION_JAR = "lib/activation.jar"; //NOI18N
69
private static final String JavaDoc TAGS_JAR = "lib/appserv-tags.jar"; //NOI18N
70
private static final String JavaDoc MAIL_JAR = "lib/mail.jar"; //NOI18N
71
private static final String JavaDoc JSTL_JAR = "lib/appserv-jstl.jar"; //NOI18N
72

73     // appserver jars
74
private static final String JavaDoc APPSERV_WS_JAR = "lib/appserv-ws.jar"; //NOI18N
75
private static final String JavaDoc TOOLS_JAR = "lib/tools.jar"; //NOI18N
76

77     // jwsdp jars
78
private static final String JavaDoc JWSDP_JAR = "lib/appserv-ws-update.jar"; //NOI18N
79
private static final String JavaDoc JAXWSA_API_JAR = "lib/jaxwsa-api.jar"; //NOI18N
80
private static final String JavaDoc JAXWSA_RI_JAR = "lib/jaxwsa-ri.jar"; //NOI18N
81

82     // wsit jars
83
private static final String JavaDoc WEBSERVICES_RT_JAR = "lib/webservices-rt.jar"; //NOI18N
84
private static final String JavaDoc WEBSERVICES_TOOLS_JAR = "lib/webservices-tools.jar"; //NOI18N
85

86     private static final String JavaDoc[] TRUSTSTORE_LOCATION = new String JavaDoc[] {
87         "config/cacerts.jks" //NOI18N
88
};
89     
90     private static final String JavaDoc[] KEYSTORE_CLIENT_LOCATION = new String JavaDoc[] {
91         "config/keystore.jks" //NOI18N
92
};
93     
94     private static final String JavaDoc[] TRUSTSTORE_CLIENT_LOCATION = new String JavaDoc[] {
95         "config/cacerts.jks" //NOI18N
96
};
97     
98     private static final String JavaDoc PERSISTENCE_PROV_TOPLINK = "oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider"; //NOI18N
99
private static final String JavaDoc PERSISTENCE_PROV_TOPLINK_DEFAULT = "toplinkPersistenceProviderIsDefault"; //NOI18N
100

101     private static String JavaDoc CONST_LOCATION = "LOCATION"; // NOI18N
102
private static String JavaDoc CONST_DOMAIN = "DOMAIN"; // NOI18N
103

104     static {
105         MODULE_TYPES.add(J2eeModule.WAR);
106         MODULE_TYPES.add(J2eeModule.EAR);
107         MODULE_TYPES.add(J2eeModule.EJB);
108         MODULE_TYPES.add(J2eeModule.CONN);
109         MODULE_TYPES.add(J2eeModule.CLIENT);
110         SPEC_VERSIONS.add(J2eeModule.J2EE_14);
111         SPEC_VERSIONS.add(J2eeModule.J2EE_13);
112         SPEC_VERSIONS_WITH_5.add(J2eeModule.JAVA_EE_5);
113         SPEC_VERSIONS_WITH_5.add(J2eeModule.J2EE_14);
114         SPEC_VERSIONS_WITH_5.add(J2eeModule.J2EE_13);
115     }
116     
117     private final File JavaDoc root;
118     private final DeploymentManagerProperties dmProps;
119     private LibraryImplementation[] libraries;
120     
121     /** Creates a new instance of PlatformImpl */
122     public PlatformImpl(File JavaDoc root, DeploymentManagerProperties dmProps) {
123         this.dmProps = dmProps;
124         this.root = root;
125     }
126     
127     /** Returns error message for an invalid platform or an empty string
128      * for a valid platform.
129      */

130     public String JavaDoc isValidPlatformRoot(File JavaDoc platformRoot) {
131         String JavaDoc result = "";
132         if(platformRoot == null || "".equals(platformRoot.getPath())) {
133             result = "Install directory cannot be empty.";
134         } else if(!platformRoot.exists()) {
135             result = "Directory '" + platformRoot.getAbsolutePath() + "' does not exist.";
136         } else {
137             version = getAppServerVersion(platformRoot);
138             File JavaDoc testF = new File JavaDoc(platformRoot, "bin"); // NOI18N
139
if(!testF.exists()) {
140                 result = "'" + platformRoot.getAbsolutePath() + "' is not a SJSAS 8.1 installation directory.";
141             } //else if(APPSERVER_VERSION_8_0.equals(PlatformImpl.getAppServerVersion(platformRoot))) {
142
// result = "<html>SJSAS 8.0 or 8.0 update 1 cannot be used. Please use SJSAS 8.1.</html>";
143
//} //else {
144
// passed all tests
145
//}
146

147             testF = new File JavaDoc(platformRoot, "lib"); // NOI18N
148
if(!testF.exists()) {
149                 result = "'" + platformRoot.getAbsolutePath() + "' is not a SJSAS 8.1 installation directory.";
150             }
151         }
152         
153         return result;
154     }
155     
156     /** Attempt to discern the application server who's root directory was passed in.
157      *
158      * 9.0 uses sun-domain_1_0.dtd
159      * 8.1 uses sun-domain_1_1.dtd (also includes the 1_0 version for backwards compatibility)
160      *
161      */

162     public String JavaDoc getAppServerVersion(File JavaDoc asInstallRoot) {
163         version = APPSERVER_VERSION_UNKNOWN; // NOI18N
164

165         if(asInstallRoot != null && asInstallRoot.exists()) {
166             File JavaDoc sunDomain11Dtd = new File JavaDoc(asInstallRoot, "lib/dtds/sun-domain_1_1.dtd"); // NOI18N
167
//now test for AS 9 (J2EE 5.0) which should work for this plugin
168
File JavaDoc as9 = new File JavaDoc((asInstallRoot)+"/lib/dtds/sun-web-app_2_5-0.dtd");
169             if(as9.exists()){
170                 version = APPSERVER_VERSION_9;
171                 
172             } else if(sunDomain11Dtd.exists()) {
173                 version = APPSERVER_VERSION_8_1;
174             }
175         }
176         return version;
177     }
178     
179     private void initLibraries() {
180         List JavaDoc<LibraryImplementation> libs = new ArrayList JavaDoc<LibraryImplementation>();
181         if ("".equals(isValidPlatformRoot(root))) { // NOI18N
182
try {
183                 List JavaDoc<URL JavaDoc> sources = dmProps.getSources();
184                 List JavaDoc<URL JavaDoc> javadoc = dmProps.getJavadocs();
185                 J2eeLibraryTypeProvider lp = new J2eeLibraryTypeProvider();
186                 LibraryImplementation lib = lp.createLibrary();
187                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "j2ee14")); // NOI18N
188
List JavaDoc l = new ArrayList JavaDoc();
189                 File JavaDoc ff = (new File JavaDoc(root, JAVA_EE_JAR));
190                 if (!ff.exists()){
191                     l.add(fileToUrl(new File JavaDoc(root, J2EE_14_JAR)));
192                 } else{
193                     l.add(fileToUrl(ff));//In case we would have a glassfish for now
194
}
195                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
196                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, sources);
197                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, javadoc);
198                 libs.add(lib);
199                 
200                 lib = lp.createLibrary();
201                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "jsf11")); // NOI18N
202

203                 l = new ArrayList JavaDoc();
204                 l.add(fileToUrl(new File JavaDoc(root, JSF_API_JAR)));
205                 l.add(fileToUrl(new File JavaDoc(root, JSF_IMPL_JAR)));
206                 // l.add(fileToUrl(new File(root, COMMON_LOGGING_JAR)));
207
l.add(fileToUrl(new File JavaDoc(root, ACTIVATION_JAR)));
208                 l.add(fileToUrl(new File JavaDoc(root, TAGS_JAR)));
209                 l.add(fileToUrl(new File JavaDoc(root, MAIL_JAR)));
210                 l.add(fileToUrl(new File JavaDoc(root, JSTL_JAR)));
211                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
212                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, sources);
213                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, javadoc);
214                 libs.add(lib);
215                 
216                 // JWSDP
217
lib = lp.createLibrary();
218                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "jwsdp")); // NOI18N
219
l = new ArrayList JavaDoc();
220                 l.add(fileToUrl(new File JavaDoc(root, JWSDP_JAR)));
221                 l.add(fileToUrl(new File JavaDoc(root, JAXWSA_API_JAR)));
222                 l.add(fileToUrl(new File JavaDoc(root, JAXWSA_RI_JAR)));
223                 
224                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
225                 libs.add(lib);
226
227                 // WSIT - just add additional libraries to the above
228
lib = lp.createLibrary();
229                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "wsit")); // NOI18N
230
l.add(fileToUrl(new File JavaDoc(root, WEBSERVICES_TOOLS_JAR)));
231                 l.add(fileToUrl(new File JavaDoc(root, WEBSERVICES_RT_JAR)));
232
233                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
234                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, sources);
235                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, javadoc);
236                 libs.add(lib);
237                 
238                 lib = lp.createLibrary();
239                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "jaxqname")); // NOI18N
240

241                 l = new ArrayList JavaDoc();
242                 l.add(fileToUrl(new File JavaDoc(root, JAX_QNAME_JAR)));
243                 l.add(fileToUrl(new File JavaDoc(root, "lib/endorsed/jaxp-api.jar")));
244                 
245                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
246                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, sources);
247                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, javadoc);
248                 libs.add(lib);
249                 
250                 lib = lp.createLibrary();
251                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "jaxrpc11")); // NOI18N
252

253                 l = new ArrayList JavaDoc();
254                 l.add(fileToUrl(new File JavaDoc(root, APPSERV_WS_JAR)));
255                 l.add(fileToUrl(new File JavaDoc(root, JAXRPC_API_JAR)));
256                 l.add(fileToUrl(new File JavaDoc(root, JAXRPC_IMPL_JAR)));
257                 // l.add(fileToUrl(new File(root, COMMON_LOGGING_JAR)));
258
lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
259                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, sources);
260                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, javadoc);
261                 libs.add(lib);
262                 
263                 lib = lp.createLibrary();
264                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "jaxr10")); // NOI18N
265

266                 l = new ArrayList JavaDoc();
267                 l.add(fileToUrl(new File JavaDoc(root, JAXR_API_JAR)));
268                 l.add(fileToUrl(new File JavaDoc(root, JAXR_IMPL_JAR)));
269                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
270                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, sources);
271                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, javadoc);
272                 libs.add(lib);
273                 
274                 lib = lp.createLibrary();
275                 lib.setName(NbBundle.getMessage(PlatformImpl.class, "saaj12")); // NOI18N
276

277                 l = new ArrayList JavaDoc();
278                 l.add(fileToUrl(new File JavaDoc(root, SAAJ_API_JAR)));
279                 l.add(fileToUrl(new File JavaDoc(root, SAAJ_IMPL_JAR)));
280                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, l);
281                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, sources);
282                 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, javadoc);
283                 libs.add(lib);
284             } catch(IOException JavaDoc e) {
285                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
286             }
287         }
288         libraries = (LibraryImplementation[])libs.toArray(new LibraryImplementation[libs.size()]);
289     }
290     
291     /**
292      * Return platform's libraries.
293      *
294      * @return platform's libraries.
295      */

296     public LibraryImplementation[] getLibraries() {
297         if (libraries == null) {
298             initLibraries();
299         }
300         return libraries.clone();
301     }
302     
303     public void notifyLibrariesChanged() {
304         initLibraries();
305         firePropertyChange(PROP_LIBRARIES, null, libraries);
306     }
307     
308     /**
309      * Return platform's display name.
310      *
311      * @return platform's display name.
312      */

313     public String JavaDoc getDisplayName() {
314         return dmProps.getDisplayName();
315     }
316     
317     /**
318      * Return platform's icon.
319      *
320      * @return platform's icon.
321      */

322     public Image JavaDoc getIcon() {
323         return Utilities.loadImage("org/netbeans/modules/j2ee/sun/ide/resources/ServerInstanceIcon.png"); // NOI18N;
324
}
325     
326     /**
327      * Return platform's root directories. This will be mostly server's installation
328      * directory.
329      *
330      * @return platform's root directories.
331      */

332     public File JavaDoc[] getPlatformRoots() {
333         return new File JavaDoc [] {root};
334     }
335     
336     /**
337      * Return classpath for the specified tool.
338      *
339      * @param toolName tool's name e.g. "wscompile".
340      * @return classpath for the specified tool.
341      */

342     public File JavaDoc[] getToolClasspathEntries(String JavaDoc toolName) {
343         if (J2eePlatform.TOOL_WSCOMPILE.equals(toolName)) {
344             if (isValidPlatformRoot(root).equals("")) {
345                 return new File JavaDoc[] {
346                     new File JavaDoc(root, "lib/j2ee.jar"), //NOI18N
347
new File JavaDoc(root, "lib/saaj-api.jar"), //NOI18N
348
new File JavaDoc(root, "lib/saaj-impl.jar"), //NOI18N
349
new File JavaDoc(root, "lib/jaxrpc-api.jar"), //NOI18N
350
new File JavaDoc(root, "lib/jaxrpc-impl.jar"), //NOI18N
351
new File JavaDoc(root, "lib/endorsed/jaxp-api.jar"),//NOI18N
352
new File JavaDoc(root, APPSERV_WS_JAR), // possibly for AS 9
353
new File JavaDoc(root, WEBSERVICES_TOOLS_JAR), // possibly for AS 9.1
354
new File JavaDoc(root, WEBSERVICES_RT_JAR), // possibly for AS 9.1
355
};
356             }
357         }
358         if (J2eePlatform.TOOL_APP_CLIENT_RUNTIME.equals(toolName)) { //NOI18N
359
if (isValidPlatformRoot(root).equals("")) {
360                 return new File JavaDoc[] {
361                     
362                     // 8.2 only -- not in GF based servers
363
new File JavaDoc(root, "lib/dom.jar"), //NOI18N
364
new File JavaDoc(root, "lib/xalan.jar"), //NOI18N
365
new File JavaDoc(root, "lib/xercesImpl.jar"), //NOI18N
366

367                     // Shared by all
368
new File JavaDoc(root, "lib/appserv-rt.jar"), //NOI18N
369

370                     // GF V1U1 and V2 -- not in 8.2
371
new File JavaDoc(root, "lib/javaee.jar"), //NOI18N
372

373                     // 8.2 -- api's included in javaee.jar
374
new File JavaDoc(root, "lib/j2ee.jar"), //NOI18N
375

376                     // GF V2 -- not present in other environments
377
new File JavaDoc(root, "lib/jmac-api.jar"), // NOI18N
378

379                     // Shared
380
new File JavaDoc(root, "lib/appserv-ext.jar"), //NOI18N
381
new File JavaDoc(root, "lib/mail.jar"), // NOI18N
382
new File JavaDoc(root, "lib/activation.jar"), // NOI18N
383

384                     // GF V2 -- not present in other environments
385
new File JavaDoc(root, "lib/webservices-rt.jar"), //NOI18N
386
new File JavaDoc(root, "lib/webservices-tools.jar"), //NOI18N
387

388                     // GF V1U1 and V2 -- not present in 8.2
389
new File JavaDoc(root, "lib/appserv-ws.jar"), //NOI18N
390

391                     // 8.2 -- not present in GF V1U1 or GF v2
392
new File JavaDoc(root, "lib/jaxrpc-impl.jar"), //NOI18N
393
new File JavaDoc(root, "lib/saaj-impl.jar"), //NOI18N
394
new File JavaDoc(root, "lib/jaxr-impl.jar"), //NOI18N
395
new File JavaDoc(root, "lib/relaxngDatatype.jar"), //NOI18N
396
new File JavaDoc(root, "lib/xsdlib.jar"), //NOI18N
397

398                     // Shared
399
new File JavaDoc(root, "lib/appserv-cmp.jar"), //NOI18N
400

401                     // GF V1U1 and V2 -- not present in 8.2
402
new File JavaDoc(root, "javadb/lib/derbyclient.jar"), //NOI18N
403
new File JavaDoc(root, "lib/toplink-essentials.jar"), //NOI18N
404
new File JavaDoc(root, "lib/dbschema.jar"), //NOI18N
405

406                     // Shared
407
new File JavaDoc(root, "lib/appserv-admin.jar"), //NOI18N
408
new File JavaDoc(root, "lib/install/applications/jmsra/imqjmsra.jar"), //NOI18N, standalone JMS
409
new File JavaDoc(root, "lib/fscontext.jar"), //NOI18N
410

411                     // GF V1U1 and GF V2
412
new File JavaDoc(root, "lib/dtds"), //NOI18N
413
new File JavaDoc(root, "lib/schemas"), //NOI18N
414
};
415             }
416         }
417         if (J2eePlatform.TOOL_KEYSTORE.equals(toolName)) {
418             if (isValidPlatformRoot(root).equals("")) { //NOI18N
419
File JavaDoc keyStoreLoc = new File JavaDoc(new File JavaDoc(dmProps.getInstanceProperties().getProperty(CONST_LOCATION)), //NOI18N
420
dmProps.getInstanceProperties().getProperty(CONST_DOMAIN) + File.separator + KEYSTORE_CLIENT_LOCATION[0]); //NOI18N
421
return new File JavaDoc[] {
422                     keyStoreLoc
423                 };
424             }
425         }
426         if (J2eePlatform.TOOL_KEYSTORE_CLIENT.equals(toolName)) {
427             if (isValidPlatformRoot(root).equals("")) { //NOI18N
428
File JavaDoc keyStoreClientLoc = new File JavaDoc(new File JavaDoc(dmProps.getInstanceProperties().getProperty(CONST_LOCATION)), //NOI18N
429
dmProps.getInstanceProperties().getProperty(CONST_DOMAIN) + File.separator + KEYSTORE_CLIENT_LOCATION[0]); //NOI18N
430
return new File JavaDoc[] {
431                     keyStoreClientLoc
432                 };
433             }
434         }
435         if (J2eePlatform.TOOL_TRUSTSTORE.equals(toolName)) {
436             if (isValidPlatformRoot(root).equals("")) { //NOI18N
437
File JavaDoc trustStoreLoc = new File JavaDoc(new File JavaDoc(dmProps.getInstanceProperties().getProperty(CONST_LOCATION)), //NOI18N
438
dmProps.getInstanceProperties().getProperty(CONST_DOMAIN) + File.separator + TRUSTSTORE_LOCATION[0]); //NOI18N
439
return new File JavaDoc[] {
440                     trustStoreLoc
441                 };
442             }
443         }
444         if (J2eePlatform.TOOL_TRUSTSTORE_CLIENT.equals(toolName)) {
445             if (isValidPlatformRoot(root).equals("")) { //NOI18N
446
File JavaDoc trustStoreClientLoc = new File JavaDoc(new File JavaDoc(dmProps.getInstanceProperties().getProperty(CONST_LOCATION)), //NOI18N
447
dmProps.getInstanceProperties().getProperty(CONST_DOMAIN) + File.separator + TRUSTSTORE_CLIENT_LOCATION[0]); //NOI18N
448
return new File JavaDoc[] {
449                     trustStoreClientLoc
450                 };
451             }
452         }
453         if (J2eePlatform.TOOL_WSGEN.equals(toolName) || J2eePlatform.TOOL_WSIMPORT.equals(toolName)) {
454             File JavaDoc jwsdpJar = new File JavaDoc(root, JWSDP_JAR); //NOI18N
455
File JavaDoc wsToolsJar = new File JavaDoc(root, WEBSERVICES_TOOLS_JAR); //NOI18N
456

457             if (wsToolsJar.exists()) { // WSIT installed on top
458
if (isValidPlatformRoot(root).equals("")) {
459                     return new File JavaDoc[] {
460                         new File JavaDoc(root, WEBSERVICES_TOOLS_JAR), // NOI18N
461
new File JavaDoc(root, WEBSERVICES_RT_JAR), // NOI18N
462
new File JavaDoc(root, TOOLS_JAR), //NOI18N
463
new File JavaDoc(root, JSTL_JAR), //NOI18N
464
new File JavaDoc(root, JAVA_EE_JAR), //NOI18N
465
new File JavaDoc(root, APPSERV_WS_JAR), //NOI18N
466
new File JavaDoc(root, MAIL_JAR), //NOI18N
467
new File JavaDoc(root, ACTIVATION_JAR) //NOI18N
468
};
469                 }
470             } else if (jwsdpJar.exists()) { // JWSDP installed on top
471
if (isValidPlatformRoot (root).equals("")) {
472                     return new File JavaDoc[] {
473                         new File JavaDoc(root, JWSDP_JAR), //NOI18N
474
new File JavaDoc(root, JAXWSA_API_JAR), //NOI18N
475
new File JavaDoc(root, JAXWSA_RI_JAR), //NOI18N
476
new File JavaDoc(root, TOOLS_JAR), //NOI18N
477
new File JavaDoc(root, JSTL_JAR), //NOI18N
478
new File JavaDoc(root, JAVA_EE_JAR), //NOI18N
479
new File JavaDoc(root, APPSERV_WS_JAR), //NOI18N
480
new File JavaDoc(root, MAIL_JAR), //NOI18N
481
new File JavaDoc(root, ACTIVATION_JAR) //NOI18N
482
};
483                 }
484             } else { // regular appserver
485
if (isValidPlatformRoot (root).equals("")) {
486                     return new File JavaDoc[] {
487                         new File JavaDoc(root, TOOLS_JAR), //NOI18N
488
new File JavaDoc(root, JSTL_JAR), //NOI18N
489
new File JavaDoc(root, JAVA_EE_JAR), //NOI18N
490
new File JavaDoc(root, APPSERV_WS_JAR), //NOI18N
491
new File JavaDoc(root, MAIL_JAR), //NOI18N
492
new File JavaDoc(root, ACTIVATION_JAR) //NOI18N
493
};
494                 }
495             }
496         }
497         return null;
498     }
499     
500     /**
501      * Specifies whether a tool of the given name is supported by this platform.
502      *
503      * @param toolName tool's name e.g. "wscompile".
504      * @return <code>true</code> if platform supports tool of the given name,
505      * <code>false</code> otherwise.
506      */

507     public boolean isToolSupported(String JavaDoc toolName) {
508         if (J2eePlatform.TOOL_WSCOMPILE.equals(toolName)
509         || J2eePlatform.TOOL_APP_CLIENT_RUNTIME.equals(toolName)) {
510             return true;
511         }
512         if (!APPSERVER_VERSION_8_1.equals(version) &&
513                 !APPSERVER_VERSION_8_2.equals(version)) { // we want this to work for 9.1 as well
514
if (J2eePlatform.TOOL_WSGEN.equals(toolName)) {
515                 return true;
516             }
517             if (J2eePlatform.TOOL_WSIMPORT.equals(toolName)) {
518                 return true;
519             }
520             if (J2eePlatform.TOOL_JSR109.equals(toolName)) {
521                 return true;
522             }
523             if (J2eePlatform.TOOL_JWSDP.equals(toolName) && (new File JavaDoc(root, JWSDP_JAR).exists())) {
524                 return true;
525             }
526             if (J2eePlatform.TOOL_WSIT.equals(toolName) && (new File JavaDoc(root, WEBSERVICES_TOOLS_JAR).exists())) {
527                 return true;
528             }
529             if (J2eePlatform.TOOL_KEYSTORE.equals(toolName)) {
530                 return true;
531             }
532             if (J2eePlatform.TOOL_KEYSTORE_CLIENT.equals(toolName)) {
533                 return true;
534             }
535             if (J2eePlatform.TOOL_TRUSTSTORE.equals(toolName)) {
536                 return true;
537             }
538             if (J2eePlatform.TOOL_TRUSTSTORE_CLIENT.equals(toolName)) {
539                 return true;
540             }
541             // Test if server has the JAX-WS Tester capability
542
if ("jaxws-tester".equals(toolName)) { //NOI18N
543
return true;
544             }
545
546             //Persistence Provoiders
547
if(PERSISTENCE_PROV_TOPLINK.equals(toolName)){
548                 return true;
549             }
550             if (PERSISTENCE_PROV_TOPLINK_DEFAULT.equals(toolName)) {
551                 return true;
552             }
553             
554             if ("org.hibernate.ejb.HibernatePersistence".equals(toolName) || //NOI18N
555
"kodo.persistence.PersistenceProviderImpl".equals(toolName)) { //NOI18N
556
return true;
557             }
558             
559         }
560         return false;
561     }
562     
563     /**
564      * Return a list of supported J2EE specification versions. Use J2EE specification
565      * versions defined in the {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule}
566      * class.
567      *
568      * @return list of supported J2EE specification versions.
569      */

570     public Set JavaDoc/*<String>*/ getSupportedSpecVersions() {
571         
572         if(APPSERVER_VERSION_9.equals(version)){
573             return SPEC_VERSIONS_WITH_5;
574         } else
575             return SPEC_VERSIONS;
576     }
577     
578     /**
579      * Return a list of supported J2EE module types. Use module types defined in the
580      * {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule}
581      * class.
582      *
583      * @return list of supported J2EE module types.
584      */

585     public Set JavaDoc/*<Object>*/ getSupportedModuleTypes() {
586         return MODULE_TYPES;
587     }
588     
589     public Set JavaDoc/*<String>*/ getSupportedJavaPlatformVersions() {
590         Set JavaDoc versions = new HashSet JavaDoc();
591         versions.add("1.4"); // NOI18N
592
versions.add("1.5"); // NOI18N
593
return versions;
594     }
595     
596     public JavaPlatform getJavaPlatform() {
597         // TODO
598
return null;
599     }
600     
601     private URL JavaDoc fileToUrl(File JavaDoc file) throws MalformedURLException JavaDoc {
602         URL JavaDoc url = file.toURI().toURL();
603         if (FileUtil.isArchiveFile(url)) {
604             url = FileUtil.getArchiveRoot(url);
605         }
606         return url;
607     }
608     
609     /* return the string within quotes
610      **/

611     private String JavaDoc quotedString(String JavaDoc s){
612         return "\""+s+"\"";
613     }
614     public String JavaDoc getToolProperty(String JavaDoc toolName, String JavaDoc propertyName) {
615         if (J2eePlatform.TOOL_APP_CLIENT_RUNTIME.equals(toolName)) {
616             if (J2eePlatform.TOOL_PROP_MAIN_CLASS.equals(propertyName)) {
617                 return "com.sun.enterprise.appclient.Main"; // NOI18N
618
}
619             if (J2eePlatform.TOOL_PROP_MAIN_CLASS_ARGS.equals(propertyName)) {
620                 return "-client ${dist.jar} ${j2ee.appclient.tool.args}"; // NOI18N
621
}
622             if (J2eePlatform.TOOL_PROP_JVM_OPTS.equals(propertyName)) {
623                 StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
624                 sb.append("-Dcom.sun.aas.configRoot=").append(quotedString(new File JavaDoc(root, "config").getAbsolutePath())); // NOI18N
625
sb.append(" -Dcom.sun.aas.installRoot=").append(quotedString(root.getAbsolutePath())); // NOI18N
626
sb.append(" -Dcom.sun.aas.imqLib=").append(quotedString(new File JavaDoc(root, "imq/lib").getAbsolutePath())); // NOI18N
627
sb.append(" -Djava.security.policy=").append(quotedString(new File JavaDoc(root, "lib/appclient/client.policy").getAbsolutePath())); // NOI18N
628
sb.append(" -Djava.security.auth.login.config=").append(quotedString(new File JavaDoc(root, "lib/appclient/appclientlogin.conf").getAbsolutePath())); // NOI18N
629
sb.append(" -Djava.endorsed.dirs=").append(quotedString(new File JavaDoc(root, "lib/endorsed").getAbsolutePath())); // NOI18N
630
sb.append(" -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"); // NOI18N
631
sb.append(" -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); // NOI18N
632
sb.append(" -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"); // NOI18N
633
sb.append(" -Dorg.xml.sax.parser=org.xml.sax.helpers.XMLReaderAdapter"); // NOI18N
634
sb.append(" -Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser"); // NOI18N
635
sb.append(" -Djava.util.logging.manager=com.sun.enterprise.server.logging.ACCLogManager"); // NOI18N
636
return sb.toString();
637             }
638             if ("j2ee.appclient.args".equals(propertyName)) { // NOI18N
639
return "-configxml " + quotedString(new File JavaDoc(dmProps.getLocation(), dmProps.getDomainName() + "/config/sun-acc.xml").getAbsolutePath()); // NOI18N
640
}
641         }
642         return null;
643     }
644 }
645
Popular Tags