1 19 package org.netbeans.modules.j2ee.weblogic9.j2ee; 20 21 import java.io.*; 22 import java.net.*; 23 import java.util.*; 24 import java.awt.Image ; 25 26 import javax.enterprise.deploy.spi.*; 27 28 import org.openide.*; 29 import org.openide.filesystems.*; 30 import org.openide.modules.InstalledFileLocator; 31 import org.openide.util.*; 32 import org.netbeans.api.java.platform.JavaPlatform; 33 import org.netbeans.spi.project.libraries.*; 34 import org.netbeans.modules.j2ee.deployment.common.api.*; 35 import org.netbeans.modules.j2ee.deployment.devmodules.api.*; 36 import org.netbeans.modules.j2ee.deployment.plugins.api.*; 37 38 import org.netbeans.modules.j2ee.weblogic9.*; 39 40 46 public class WLJ2eePlatformFactory extends J2eePlatformFactory { 47 48 public J2eePlatformImpl getJ2eePlatformImpl(DeploymentManager dm) { 49 assert WLDeploymentManager.class.isAssignableFrom(dm.getClass()) : this + " cannot create platform for unknown deployment manager:" + dm; 50 return new J2eePlatformImplImpl((WLDeploymentManager)dm); 51 } 52 53 private static class J2eePlatformImplImpl extends J2eePlatformImpl { 54 55 private static final String J2EE_API_DOC = "docs/javaee5-doc-api.zip"; private static final Set MODULE_TYPES = new HashSet(); 57 static { 58 MODULE_TYPES.add(J2eeModule.EAR); 59 MODULE_TYPES.add(J2eeModule.WAR); 60 MODULE_TYPES.add(J2eeModule.EJB); 61 } 64 65 private static final Set SPEC_VERSIONS = new HashSet(); 66 static { 67 SPEC_VERSIONS.add(J2eeModule.J2EE_14); 68 } 69 70 private String platformRoot; 72 73 private LibraryImplementation[] libraries = null; 74 75 78 private static final String ICON = "org/netbeans/modules/" + "j2ee/weblogic9/resources/16x16.gif"; 81 85 WLDeploymentManager dm; 86 87 public J2eePlatformImplImpl(WLDeploymentManager dm) { 88 this.dm = dm; 89 } 90 91 public boolean isToolSupported(String toolName) { 92 if (J2eePlatform.TOOL_WSGEN.equals(toolName) || J2eePlatform.TOOL_WSIMPORT.equals(toolName)) { 93 return true; 94 } 95 if (J2eePlatform.TOOL_JSR109.equals(toolName)) { 96 return false; } 98 return false; 99 } 100 101 public File[] getToolClasspathEntries(String toolName) { 102 File[] cp = new File[0]; 103 if (J2eePlatform.TOOL_WSGEN.equals(toolName) || J2eePlatform.TOOL_WSIMPORT.equals(toolName)) { 104 cp = new File[] { new File(getPlatformRoot(), "server/lib/weblogic.jar") }; } 106 return cp; 107 } 108 109 public Set getSupportedSpecVersions() { 110 return SPEC_VERSIONS; 111 } 112 113 public java.util.Set getSupportedModuleTypes() { 114 return MODULE_TYPES; 115 } 116 117 public Set getSupportedJavaPlatformVersions() { 118 Set versions = new HashSet(); 119 versions.add("1.4"); versions.add("1.5"); return versions; 122 } 123 124 public JavaPlatform getJavaPlatform() { 125 return null; 126 } 127 128 public java.io.File [] getPlatformRoots() { 129 return new File[]{new File(getPlatformRoot())}; 130 } 131 132 public LibraryImplementation[] getLibraries() { 133 if (libraries == null) { 134 initLibraries(); 135 } 136 return libraries; 137 } 138 139 private void initLibraries() { 140 141 LibraryImplementation library = new J2eeLibraryTypeProvider(). 143 createLibrary(); 144 145 library.setName(NbBundle.getMessage(WLJ2eePlatformFactory.class, 147 "LIBRARY_NAME")); 149 try { 151 List list = new ArrayList(); 152 list.add(fileToUrl(new File(getPlatformRoot(), "server/lib/weblogic.jar"))); 154 library.setContent(J2eeLibraryTypeProvider. 155 VOLUME_TYPE_CLASSPATH, list); 156 File j2eeDoc = InstalledFileLocator.getDefault().locate(J2EE_API_DOC, null, false); 157 if (j2eeDoc != null) { 158 list = new ArrayList(); 159 list.add(fileToUrl(j2eeDoc)); 160 library.setContent(J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC, list); 161 } 162 } catch (MalformedURLException e) { 163 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e); 164 } 165 166 libraries = new LibraryImplementation[1]; 167 libraries[0] = library; 168 } 169 170 176 public Image getIcon() { 177 return Utilities.loadImage(ICON); 178 } 179 180 186 public String getDisplayName() { 187 return NbBundle.getMessage(WLJ2eePlatformFactory.class, "PLATFORM_NAME"); } 189 190 198 private URL fileToUrl(File file) throws MalformedURLException { 199 URL url = file.toURI().toURL(); 200 if (FileUtil.isArchiveFile(url)) { 201 url = FileUtil.getArchiveRoot(url); 202 } 203 return url; 204 } 205 206 private String getPlatformRoot() { 207 if (platformRoot == null) 208 platformRoot = dm.getInstanceProperties().getProperty(WLPluginProperties.SERVER_ROOT_ATTR); 209 210 return platformRoot; 211 } 212 } 213 214 } 215 | Popular Tags |