1 19 20 package org.netbeans.modules.websvc.registry.netbeans; 21 22 import java.io.File ; 23 24 import org.openide.ErrorManager; 25 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 26 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 27 28 29 34 public final class SJSASVersion { 35 36 private static String REGISTRY_JARS_8_0_AND_8_1_BETA [] = { 37 "/lib/j2ee.jar", 38 "/lib/jaxrpc-api.jar", 39 "/lib/jaxrpc-spi.jar", 40 "/lib/jaxrpc-impl.jar", 41 "/lib/endorsed/xercesImpl.jar", 42 "/lib/endorsed/dom.jar", 43 "/lib/endorsed/xalan.jar", 44 "/lib/activation.jar", 45 "/lib/mail.jar", 46 "/lib/xsdlib.jar", 47 "/lib/relaxngDatatype.jar", 48 "/lib/commons-logging.jar", 49 "/lib/namespace.jar", 50 "/lib/jaxr-impl.jar", 51 "/lib/saaj-api.jar", 52 "/lib/saaj-impl.jar", 53 "/lib/jax-qname.jar" 54 }; 55 56 private static String REGISTRY_JARS_8_1 [] = { 57 "/lib/j2ee.jar", 58 "/lib/jaxrpc-api.jar", 59 "/lib/jaxrpc-spi.jar", 60 "/lib/jaxrpc-impl.jar", 61 "/lib/xercesImpl.jar", 62 "/lib/dom.jar", 63 "/lib/xalan.jar", 64 "/lib/activation.jar", 65 "/lib/mail.jar", 66 "/lib/xsdlib.jar", 67 "/lib/relaxngDatatype.jar", 68 "/lib/commons-logging.jar", 69 "/lib/namespace.jar", 70 "/lib/jaxr-impl.jar", 71 "/lib/saaj-api.jar", 72 "/lib/saaj-impl.jar", 73 "/lib/jax-qname.jar" 74 }; 75 76 private static String SAX_PARSER_IMPL_8_0 = "org.apache.xerces.jaxp.SAXParserFactoryImpl"; private static String SAX_PARSER_IMPL_8_1 = "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"; 79 public static final SJSASVersion APPSERVER_VERSION_8_0 = new SJSASVersion( 81 "8.0", REGISTRY_JARS_8_0_AND_8_1_BETA, SAX_PARSER_IMPL_8_0); 83 public static final SJSASVersion APPSERVER_VERSION_8_1_BETA = new SJSASVersion( 85 "8.1 beta", REGISTRY_JARS_8_0_AND_8_1_BETA, SAX_PARSER_IMPL_8_1); 87 public static final SJSASVersion APPSERVER_VERSION_8_1 = new SJSASVersion( 89 "8.1", REGISTRY_JARS_8_1, SAX_PARSER_IMPL_8_1); 91 public static final SJSASVersion APPSERVER_VERSION_UNKNOWN = new SJSASVersion( 93 "unknown", REGISTRY_JARS_8_1, SAX_PARSER_IMPL_8_1); 95 private String sjsasVersion; 96 private String [] registryRuntimeLibraries; 97 private String saxParserImplClass; 98 99 private SJSASVersion(String version, String [] registryRuntimeLibs, String saxParserImplClass) { 100 if(version == null) { 101 throw new NullPointerException ("Null Application Server Version is not allowed."); 102 } 103 104 this.sjsasVersion = version; 105 this.registryRuntimeLibraries = registryRuntimeLibs; 106 this.saxParserImplClass = saxParserImplClass; 107 } 108 109 public String toString() { 110 return sjsasVersion; 111 } 112 113 public boolean equals(Object obj) { 114 SJSASVersion target = (SJSASVersion) obj; 115 return sjsasVersion.equals(target.sjsasVersion); 116 } 117 118 public int hashCode() { 119 return sjsasVersion.hashCode(); 120 } 121 122 public String [] getRegistryRuntimeLibraries() { 123 return registryRuntimeLibraries; 124 } 125 126 public String getSaxParserImplClass() { 127 return saxParserImplClass; 128 } 129 130 136 public static SJSASVersion getSJSAppServerVersion() { 137 SJSASVersion version = APPSERVER_VERSION_UNKNOWN; String serverInstanceIDs[] = Deployment.getDefault().getServerInstanceIDs (); 139 J2eePlatform platform = null; 140 for (int i = 0; i < serverInstanceIDs.length; i++) { 141 J2eePlatform p = Deployment.getDefault().getJ2eePlatform (serverInstanceIDs [i]); 142 if (p != null && p.isToolSupported ("wscompile")) { 143 platform = p; 144 break; 145 } 146 } 147 File asInstallRoot = platform == null ? null : platform.getPlatformRoots () [0]; 148 if(asInstallRoot != null && asInstallRoot.exists()) { 149 File sunDomain11Dtd = new File (asInstallRoot, "lib/dtds/sun-domain_1_1.dtd"); if(sunDomain11Dtd.exists()) { 151 File endorsedXerces = new File (asInstallRoot, "lib/endorsed/xercesImpl.jar"); 152 if(endorsedXerces.exists()) { 153 version = APPSERVER_VERSION_8_1_BETA; 155 } else { 156 version = APPSERVER_VERSION_8_1; 158 } 159 } else { 160 version = APPSERVER_VERSION_8_0; 162 } 163 } 164 165 if(APPSERVER_VERSION_UNKNOWN.equals(version)) { 166 ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, 167 "Cannot determine version of installed Sun Java System Application Server."); 168 } 169 170 return version; 171 } 172 } 173 | Popular Tags |