Author: rob.stryker(a)jboss.com
Date: 2008-02-03 20:21:52 -0500 (Sun, 03 Feb 2008)
New Revision: 6102
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
Log:
JBIDE-1292 - fix. involved digging deeper and using more official launching API.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2008-02-03
15:51:12 UTC (rev 6101)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/AbstractJBossLaunchConfigType.java 2008-02-04
01:21:52 UTC (rev 6102)
@@ -7,7 +7,6 @@
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -31,7 +30,7 @@
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
public abstract class AbstractJBossLaunchConfigType extends
AbstractJavaLaunchConfigurationDelegate {
- protected static final String SERVER_ID = "server-id";
+ public static final String SERVER_ID = "server-id";
// we have no need to do anything in pre-launch check
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode,
IProgressMonitor monitor) throws CoreException {
@@ -125,31 +124,29 @@
list.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new
Path(getServerHome(jbs)).append(relative)));
}
+ @Deprecated
protected static ArrayList<String>
convertClasspath(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall vmInstall) {
+ addJREEntry(cp, vmInstall);
+ return convertClasspath(cp);
+ }
+
+ protected static void addJREEntry(ArrayList<IRuntimeClasspathEntry> cp, IVMInstall
vmInstall) {
if (vmInstall != null) {
- try {
- cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
- new Path(JavaRuntime.JRE_CONTAINER).append(
- "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")
- .append(vmInstall.getName()),
- IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
- } catch (CoreException e) {
- IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
- "Unexpected Exception converting launch classpath: ", e);
- JBossServerCorePlugin.getDefault().getLog().log(s);
- }
-
- IPath jrePath = new Path(vmInstall.getInstallLocation()
- .getAbsolutePath());
- if (jrePath != null) {
- IPath toolsPath = jrePath.append("lib").append("tools.jar");
- if (toolsPath.toFile().exists()) {
- cp.add(JavaRuntime
- .newArchiveRuntimeClasspathEntry(toolsPath));
- }
+ try {
+ cp.add(JavaRuntime.newRuntimeContainerClasspathEntry(
+ new Path(JavaRuntime.JRE_CONTAINER)
+ .append(vmInstall.getVMInstallType().getId()).append(vmInstall.getName()),
+// "org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType")
+ IRuntimeClasspathEntry.BOOTSTRAP_CLASSES));
+ } catch (CoreException e) {
+ IStatus s = new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
+ "Unexpected Exception converting launch classpath: ", e);
+ JBossServerCorePlugin.getDefault().getLog().log(s);
}
}
-
+ }
+
+ protected static ArrayList<String>
convertClasspath(ArrayList<IRuntimeClasspathEntry> cp) {
Iterator<IRuntimeClasspathEntry> cpi = cp.iterator();
ArrayList<String> list = new ArrayList<String>();
while (cpi.hasNext()) {
@@ -188,4 +185,12 @@
public static String getServerHome(JBossServer jbs) {
return jbs.getServer().getRuntime().getLocation().toOSString();
}
+
+ public IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException
{
+ String serverId = configuration.getAttribute(SERVER_ID, (String)null);
+ JBossServer jbs = findJBossServer(serverId);
+ IJBossServerRuntime jbrt = findJBossServerRuntime(jbs.getServer());
+ return jbrt.getVM();
+ }
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-02-03
15:51:12 UTC (rev 6101)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/launch/JBossServerStartupLaunchConfiguration.java 2008-02-04
01:21:52 UTC (rev 6102)
@@ -38,6 +38,7 @@
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.StandardClasspathProvider;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.internal.ServerType;
@@ -49,7 +50,6 @@
public class JBossServerStartupLaunchConfiguration extends AbstractJBossLaunchConfigType
{
protected static final char[] INVALID_CHARS = new char[] {'\\', '/',
':', '*', '?', '"', '<', '>',
'|', '\0', '@', '&'};
-
private static final String LAUNCH_TYPE =
"org.jboss.ide.eclipse.as.core.server.startupConfiguration";
private static final String DEFAULTS_SET = "jboss.defaults.been.set";
private static final String START_JAR_LOC = "bin" + Path.SEPARATOR +
"run.jar";
@@ -64,28 +64,21 @@
public static void setupLaunchConfiguration(
ILaunchConfigurationWorkingCopy workingCopy, IServer server) throws CoreException {
- ensureDefaultsSet(workingCopy, server);
+ if(!workingCopy.getAttributes().containsKey(DEFAULTS_SET)) {
+ forceDefaultsSet(workingCopy, server);
+ }
}
- public static void ensureDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server)
throws CoreException {
- if(!wc.getAttributes().containsKey(DEFAULTS_SET)) {
- JBossServer jbs = findJBossServer(server.getId());
- IJBossServerRuntime jbrt = findJBossServerRuntime(server);
- String serverHome = getServerHome(jbs);
-
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
getDefaultArgs(jbs));
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
getDefaultVMArgs(jbs));
-
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
START_MAIN_TYPE);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
- ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
- addCPEntry(classpath, jbs, START_JAR_LOC);
- ArrayList<String> runtimeClassPaths = convertClasspath(classpath,
jbrt.getVM());
- String cpKey = IJavaLaunchConfigurationConstants.ATTR_CLASSPATH;
- wc.setAttribute(cpKey, runtimeClassPaths);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
- wc.setAttribute(DEFAULTS_SET, true);
- }
+ public static void forceDefaultsSet(ILaunchConfigurationWorkingCopy wc, IServer server)
throws CoreException {
+ JBossServer jbs = findJBossServer(server.getId());
+ String serverHome = getServerHome(jbs);
+
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
getDefaultArgs(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
getDefaultVMArgs(jbs));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
START_MAIN_TYPE);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, serverHome +
Path.SEPARATOR + "bin");
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
"org.jboss.ide.eclipse.as.core.launch.classpathProvider");
+ wc.setAttribute(DEFAULTS_SET, true);
}
public static String getDefaultArgs(JBossServer jbs) throws CoreException {
@@ -182,4 +175,29 @@
return wc;
}
+
+ public static class StartupClasspathProvider extends StandardClasspathProvider {
+
+ public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration
configuration) throws CoreException {
+ boolean useDefault =
configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
true);
+ if (useDefault) {
+ return computeUnresolvedDefaultClasspath(configuration);
+ }
+ // recover persisted classpath
+ return recoverRuntimePath(configuration,
IJavaLaunchConfigurationConstants.ATTR_CLASSPATH);
+ }
+
+ protected IRuntimeClasspathEntry[]
computeUnresolvedDefaultClasspath(ILaunchConfiguration configuration) throws CoreException
{
+ String serverId = configuration.getAttribute(SERVER_ID, (String)null);
+ JBossServer jbs = findJBossServer(serverId);
+ IJBossServerRuntime jbrt = findJBossServerRuntime(jbs.getServer());
+ ArrayList<IRuntimeClasspathEntry> classpath = new
ArrayList<IRuntimeClasspathEntry>();
+ addCPEntry(classpath, jbs, START_JAR_LOC);
+ addJREEntry(classpath, jbrt.getVM());
+ return (IRuntimeClasspathEntry[]) classpath
+ .toArray(new IRuntimeClasspathEntry[classpath.size()]);
+ }
+
+ }
+
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-02-03 15:51:12 UTC (rev
6101)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2008-02-04 01:21:52 UTC (rev
6102)
@@ -464,4 +464,11 @@
</facet>
</default-facets>
</extension>
+ <extension
+ point="org.eclipse.jdt.launching.classpathProviders">
+ <classpathProvider
+
class="org.jboss.ide.eclipse.as.core.server.internal.launch.JBossServerStartupLaunchConfiguration$StartupClasspathProvider"
+ id="org.jboss.ide.eclipse.as.core.launch.classpathProvider">
+ </classpathProvider>
+ </extension>
</plugin>