1 19 20 package org.netbeans.modules.tomcat5; 21 22 import java.awt.Image ; 23 import java.io.File ; 24 import java.util.ArrayList ; 25 import java.util.HashSet ; 26 import java.util.List ; 27 import java.util.Set ; 28 import org.netbeans.api.java.platform.JavaPlatform; 29 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 30 import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider; 31 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 32 import org.netbeans.modules.j2ee.deployment.plugins.api.J2eePlatformImpl; 33 import org.netbeans.modules.tomcat5.util.TomcatProperties; 34 import org.netbeans.spi.project.libraries.LibraryImplementation; 35 import org.openide.util.NbBundle; 36 import org.openide.util.Utilities; 37 38 43 public class TomcatPlatformImpl extends J2eePlatformImpl { 44 45 private static final String WSCOMPILE_LIBS[] = new String [] { 46 "jaxrpc/lib/jaxrpc-api.jar", "jaxrpc/lib/jaxrpc-impl.jar", "jaxrpc/lib/jaxrpc-spi.jar", "saaj/lib/saaj-api.jar", "saaj/lib/saaj-impl.jar", "jwsdp-shared/lib/mail.jar", "jwsdp-shared/lib/activation.jar" }; 54 55 private static final String JWSDP_LIBS[] = new String [] { 56 "fastinfoset/lib/FastInfoset.jar", "jaxb/lib/jaxb1-impl.jar", "jaxb/lib/jaxb-impl.jar", "jaxb/lib/jaxb-api.jar", "jaxb/lib/jaxb-xjc.jar", "jaxws/lib/jaxws-api.jar", "jaxws/lib/jaxws-rt.jar", "jaxws/lib/jaxws-tools.jar", "jaxws/lib/jsr181-api.jar", "jaxws/lib/jsr250-api.jar", "saaj/lib/saaj-api.jar", "saaj/lib/saaj-impl.jar", "sjsxp/lib/sjsxp.jar", "sjsxp/lib/jsr173_api.jar", "jwsdp-shared/lib/activation.jar", "jwsdp-shared/lib/jaas.jar", "jwsdp-shared/lib/jta-spec1_0_1.jar", "jwsdp-shared/lib/mail.jar", "jwsdp-shared/lib/relaxngDatatype.jar", "jwsdp-shared/lib/resolver.jar", "jwsdp-shared/lib/xmlsec.jar", "jwsdp-shared/lib/xsdlib.jar" }; 80 81 private static final String WSIT_LIBS[] = new String [] { 82 "shared/lib/webservices-rt.jar", "shared/lib/webservices-tools.jar" }; 85 86 private static final String JWSDP_WSGEN_LIBS[] = new String [] { 87 "jaxws/lib/jaxws-tools.jar", "jaxws/lib/jaxws-rt.jar", "sjsxp/lib/sjsxp.jar", "jaxb/lib/jaxb-xjc.jar", "saaj/lib/saaj-impl.jar", "saaj/lib/saaj-api.jar", "jwsdp-shared/lib/relaxngDatatype.jar", "jwsdp-shared/lib/resolver.jar" }; 96 97 private static final String JWSDP_WSIMPORT_LIBS[] = new String [] { 98 "jaxws/lib/jaxws-tools.jar", "jaxws/lib/jaxws-rt.jar", "sjsxp/lib/sjsxp.jar", "jaxb/lib/jaxb-xjc.jar", "jwsdp-shared/lib/relaxngDatatype.jar", "jwsdp-shared/lib/resolver.jar" }; 105 106 private static final String WSIT_WSIMPORT_LIBS[] = new String [] { 107 "shared/lib/webservices-rt.jar", "shared/lib/webservices-tools.jar" }; 110 111 private static final String WSIT_WSGEN_LIBS[] = new String [] { 112 "shared/lib/webservices-rt.jar", "shared/lib/webservices-tools.jar" }; 115 116 private static final String [] KEYSTORE_LOCATION = new String [] { 117 "xws-security/etc/server-keystore.jks" }; 119 120 private static final String [] TRUSTSTORE_LOCATION = new String [] { 121 "xws-security/etc/server-truststore.jks" }; 123 124 private static final String [] KEYSTORE_CLIENT_LOCATION = new String [] { 125 "xws-security/etc/client-keystore.jks" }; 127 128 private static final String [] TRUSTSTORE_CLIENT_LOCATION = new String [] { 129 "xws-security/etc/client-truststore.jks" }; 131 132 private static final String ICON = "org/netbeans/modules/tomcat5/resources/tomcat5instance.png"; 134 private String displayName; 135 private TomcatProperties tp; 136 private TomcatManager manager; 137 138 private List libraries = new ArrayList (); 139 140 141 public TomcatPlatformImpl(TomcatManager manager) { 142 this.manager = manager; 143 this.tp = manager.getTomcatProperties(); 144 displayName = tp.getDisplayName(); 145 146 J2eeLibraryTypeProvider libProvider = new J2eeLibraryTypeProvider(); 147 LibraryImplementation lib = libProvider.createLibrary(); 148 lib.setName(NbBundle.getMessage(TomcatPlatformImpl.class, "LBL_lib_name", displayName)); 149 loadLibraries(lib); 150 libraries.add(lib); 151 } 152 153 public void notifyLibrariesChanged() { 154 LibraryImplementation lib = (LibraryImplementation)libraries.get(0); 155 loadLibraries(lib); 156 firePropertyChange(PROP_LIBRARIES, null, libraries); 157 } 158 159 public LibraryImplementation[] getLibraries() { 160 return (LibraryImplementation[])libraries.toArray(new LibraryImplementation[libraries.size()]); 161 } 162 163 public String getDisplayName() { 164 return displayName; 165 } 166 167 public Image getIcon() { 168 return Utilities.loadImage(ICON); 169 } 170 171 public File [] getPlatformRoots() { 172 if (tp.getCatalinaBase() != null) { 173 return new File [] {tp.getCatalinaHome(), tp.getCatalinaBase()}; 174 } else { 175 return new File [] {tp.getCatalinaHome()}; 176 } 177 } 178 179 public File [] getToolClasspathEntries(String toolName) { 180 if (J2eePlatform.TOOL_WSCOMPILE.equals(toolName)) { 182 if (isToolSupported(J2eePlatform.TOOL_WSCOMPILE)) { 183 File [] retValue = new File [WSCOMPILE_LIBS.length]; 184 File homeDir = tp.getCatalinaHome(); 185 for (int i = 0; i < WSCOMPILE_LIBS.length; i++) { 186 retValue[i] = new File (homeDir, WSCOMPILE_LIBS[i]); 187 } 188 return retValue; 189 } 190 } 191 if (J2eePlatform.TOOL_WSGEN.equals(toolName)) { 193 if (isToolSupported(J2eePlatform.TOOL_WSGEN)) { 194 if (isToolSupported(J2eePlatform.TOOL_WSIT)) { 195 File [] retValue = new File [WSIT_WSGEN_LIBS.length]; 196 File homeDir = tp.getCatalinaHome(); 197 for (int i = 0; i < WSIT_WSGEN_LIBS.length; i++) { 198 retValue[i] = new File (homeDir, WSIT_WSGEN_LIBS[i]); 199 } 200 return retValue; 201 } else { 202 File [] retValue = new File [JWSDP_WSGEN_LIBS.length]; 203 File homeDir = tp.getCatalinaHome(); 204 for (int i = 0; i < JWSDP_WSGEN_LIBS.length; i++) { 205 retValue[i] = new File (homeDir, JWSDP_WSGEN_LIBS[i]); 206 } 207 return retValue; 208 } 209 } 210 } 211 if (J2eePlatform.TOOL_WSIMPORT.equals(toolName)) { 213 if (isToolSupported(J2eePlatform.TOOL_WSIMPORT)) { 214 if (isToolSupported(J2eePlatform.TOOL_WSIT)) { 215 File [] retValue = new File [WSIT_WSIMPORT_LIBS.length]; 216 File homeDir = tp.getCatalinaHome(); 217 for (int i = 0; i < WSIT_WSIMPORT_LIBS.length; i++) { 218 retValue[i] = new File (homeDir, WSIT_WSIMPORT_LIBS[i]); 219 } 220 return retValue; 221 } else { 222 File [] retValue = new File [JWSDP_WSIMPORT_LIBS.length]; 223 File homeDir = tp.getCatalinaHome(); 224 for (int i = 0; i < JWSDP_WSIMPORT_LIBS.length; i++) { 225 retValue[i] = new File (homeDir, JWSDP_WSIMPORT_LIBS[i]); 226 } 227 return retValue; 228 } 229 } 230 } 231 if (J2eePlatform.TOOL_JWSDP.equals(toolName)) { 233 if (isToolSupported(J2eePlatform.TOOL_WSIT)) { 234 return getToolClasspathEntries(J2eePlatform.TOOL_WSIT); 235 } else { 236 if (isToolSupported(J2eePlatform.TOOL_JWSDP)) { 237 File [] retValue = new File [JWSDP_LIBS.length]; 238 File homeDir = tp.getCatalinaHome(); 239 for (int i = 0; i < JWSDP_LIBS.length; i++) { 240 retValue[i] = new File (homeDir, JWSDP_LIBS[i]); 241 } 242 return retValue; 243 } 244 } 245 } 246 if (J2eePlatform.TOOL_KEYSTORE.equals(toolName)) { 248 if (isToolSupported(J2eePlatform.TOOL_KEYSTORE)) { 249 File [] retValue = new File [KEYSTORE_LOCATION.length]; 250 File homeDir = tp.getCatalinaHome(); 251 for (int i = 0; i < KEYSTORE_LOCATION.length; i++) { 252 retValue[i] = new File (homeDir, KEYSTORE_LOCATION[i]); 253 } 254 return retValue; 255 } 256 } 257 if (J2eePlatform.TOOL_TRUSTSTORE.equals(toolName)) { 259 if (isToolSupported(J2eePlatform.TOOL_TRUSTSTORE)) { 260 File [] retValue = new File [TRUSTSTORE_LOCATION.length]; 261 File homeDir = tp.getCatalinaHome(); 262 for (int i = 0; i < TRUSTSTORE_LOCATION.length; i++) { 263 retValue[i] = new File (homeDir, TRUSTSTORE_LOCATION[i]); 264 } 265 return retValue; 266 } 267 } 268 if (J2eePlatform.TOOL_KEYSTORE_CLIENT.equals(toolName)) { 269 if (isToolSupported(J2eePlatform.TOOL_KEYSTORE_CLIENT)) { 270 File [] retValue = new File [KEYSTORE_CLIENT_LOCATION.length]; 271 File homeDir = tp.getCatalinaHome(); 272 for (int i = 0; i < KEYSTORE_CLIENT_LOCATION.length; i++) { 273 retValue[i] = new File (homeDir, KEYSTORE_CLIENT_LOCATION[i]); 274 } 275 return retValue; 276 } 277 } 278 if (J2eePlatform.TOOL_TRUSTSTORE_CLIENT.equals(toolName)) { 280 if (isToolSupported(J2eePlatform.TOOL_TRUSTSTORE_CLIENT)) { 281 File [] retValue = new File [TRUSTSTORE_CLIENT_LOCATION.length]; 282 File homeDir = tp.getCatalinaHome(); 283 for (int i = 0; i < TRUSTSTORE_CLIENT_LOCATION.length; i++) { 284 retValue[i] = new File (homeDir, TRUSTSTORE_CLIENT_LOCATION[i]); 285 } 286 return retValue; 287 } 288 } 289 if (J2eePlatform.TOOL_WSIT.equals(toolName)) { 291 if (isToolSupported(J2eePlatform.TOOL_WSIT)) { 292 File [] retValue = new File [WSIT_LIBS.length]; 293 File homeDir = tp.getCatalinaHome(); 294 for (int i = 0; i < WSIT_LIBS.length; i++) { 295 retValue[i] = new File (homeDir, WSIT_LIBS[i]); 296 } 297 return retValue; 298 } 299 } 300 return null; 301 } 302 303 public boolean isToolSupported(String toolName) { 304 if (J2eePlatform.TOOL_WSCOMPILE.equals(toolName)) { 306 File homeDir = tp.getCatalinaHome(); 307 for (int i = 0; i < WSCOMPILE_LIBS.length; i++) { 308 if (!new File (homeDir, WSCOMPILE_LIBS[i]).exists()) { 309 return false; 310 } 311 } 312 return true; 313 } 314 if (J2eePlatform.TOOL_WSGEN.equals(toolName)) { 315 File homeDir = tp.getCatalinaHome(); 316 boolean wsit = isToolSupported(J2eePlatform.TOOL_WSIT); 317 if (wsit) { 318 for (int i = 0; i < WSIT_WSGEN_LIBS.length; i++) { 319 if (!new File (homeDir, WSIT_WSGEN_LIBS[i]).exists()) { 320 return false; 321 } 322 } 323 } else { 324 for (int i = 0; i < JWSDP_WSGEN_LIBS.length; i++) { 325 if (!new File (homeDir, JWSDP_WSGEN_LIBS[i]).exists()) { 326 return false; 327 } 328 } 329 } 330 return true; 331 } 332 if (J2eePlatform.TOOL_WSIMPORT.equals(toolName)) { 333 File homeDir = tp.getCatalinaHome(); 334 boolean wsit = isToolSupported(J2eePlatform.TOOL_WSIT); 335 if (wsit) { 336 for (int i = 0; i < WSIT_WSIMPORT_LIBS.length; i++) { 337 if (!new File (homeDir, WSIT_WSIMPORT_LIBS[i]).exists()) { 338 return false; 339 } 340 } 341 } else { 342 for (int i = 0; i < JWSDP_WSIMPORT_LIBS.length; i++) { 343 if (!new File (homeDir, JWSDP_WSIMPORT_LIBS[i]).exists()) { 344 return false; 345 } 346 } 347 } 348 return true; 349 } 350 if (J2eePlatform.TOOL_JWSDP.equals(toolName)) { 351 352 if (isToolSupported(J2eePlatform.TOOL_WSIT)) { 353 return true; 354 } 355 356 File homeDir = tp.getCatalinaHome(); 357 for (int i = 0; i < JWSDP_LIBS.length; i++) { 358 if (!new File (homeDir, JWSDP_LIBS[i]).exists()) { 359 return false; 360 } 361 } 362 return true; 363 } 364 if (J2eePlatform.TOOL_KEYSTORE.equals(toolName)) { 365 File homeDir = tp.getCatalinaHome(); 366 for (int i = 0; i < KEYSTORE_LOCATION.length; i++) { 367 if (!new File (homeDir, KEYSTORE_LOCATION[i]).exists()) { 368 return false; 369 } 370 } 371 return true; 372 } 373 if (J2eePlatform.TOOL_TRUSTSTORE.equals(toolName)) { 374 File homeDir = tp.getCatalinaHome(); 375 for (int i = 0; i < TRUSTSTORE_LOCATION.length; i++) { 376 if (!new File (homeDir, TRUSTSTORE_LOCATION[i]).exists()) { 377 return false; 378 } 379 } 380 return true; 381 } 382 if (J2eePlatform.TOOL_KEYSTORE_CLIENT.equals(toolName)) { 383 File homeDir = tp.getCatalinaHome(); 384 for (int i = 0; i < KEYSTORE_CLIENT_LOCATION.length; i++) { 385 if (!new File (homeDir, KEYSTORE_CLIENT_LOCATION[i]).exists()) { 386 return false; 387 } 388 } 389 return true; 390 } 391 if (J2eePlatform.TOOL_TRUSTSTORE_CLIENT.equals(toolName)) { 392 File homeDir = tp.getCatalinaHome(); 393 for (int i = 0; i < TRUSTSTORE_CLIENT_LOCATION.length; i++) { 394 if (!new File (homeDir, TRUSTSTORE_CLIENT_LOCATION[i]).exists()) { 395 return false; 396 } 397 } 398 return true; 399 } 400 if (J2eePlatform.TOOL_WSIT.equals(toolName)) { 401 File homeDir = tp.getCatalinaHome(); 402 for (int i = 0; i < WSIT_LIBS.length; i++) { 403 if (!new File (homeDir, WSIT_LIBS[i]).exists()) { 404 return false; 405 } 406 } 407 return true; 408 } 409 if (J2eePlatform.TOOL_JSR109.equals(toolName)) { 410 return false; 411 } 412 413 if ("jaxws-tester".equals(toolName)) { return true; 416 } 417 418 return false; 419 } 420 421 public Set getSupportedModuleTypes() { 422 Set moduleTypes = new HashSet (1); 423 moduleTypes.add(J2eeModule.WAR); 424 return moduleTypes; 425 } 426 427 public Set getSupportedSpecVersions() { 428 Set specVersions = new HashSet (3); 429 specVersions.add(J2eeModule.J2EE_13); 430 specVersions.add(J2eeModule.J2EE_14); 431 if (manager.isTomcat60()) { 432 specVersions.add(J2eeModule.JAVA_EE_5); 433 } 434 return specVersions; 435 } 436 437 public Set getSupportedJavaPlatformVersions() { 438 Set versions = new HashSet (); 439 versions.add("1.4"); versions.add("1.5"); return versions; 442 } 443 444 public JavaPlatform getJavaPlatform() { 445 return tp.getJavaPlatform(); 446 } 447 448 450 private void loadLibraries(LibraryImplementation lib) { 451 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH, tp.getClasses()); 452 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, tp.getJavadocs()); 453 lib.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_SRC, tp.getSources()); 454 } 455 } 456 | Popular Tags |