You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by mc...@apache.org on 2009/07/24 09:00:11 UTC

svn commit: r797342 - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core: GeronimoLaunchConfigurationDelegate.java GeronimoServerBehaviourDelegate.java

Author: mcconne
Date: Fri Jul 24 07:00:11 2009
New Revision: 797342

URL: http://svn.apache.org/viewvc?rev=797342&view=rev
Log:
GERONIMODEVTOOLS-575 Handle scenario where there is a failure on the GEP side during setup of the Launch Configuration -- Thanks to Delos Dai for the patch !!

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoLaunchConfigurationDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoLaunchConfigurationDelegate.java?rev=797342&r1=797341&r2=797342&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoLaunchConfigurationDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoLaunchConfigurationDelegate.java Fri Jul 24 07:00:11 2009
@@ -42,15 +42,21 @@
  */
 public class GeronimoLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
-	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
-	 *      org.eclipse.core.runtime.IProgressMonitor)
-	 */
-	public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
-
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
+     *      java.lang.String, org.eclipse.debug.core.ILaunch,
+     *      org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+        if (configuration.hasAttribute(GeronimoServerBehaviourDelegate.ERROR_SETUP_LAUNCH_CONFIGURATION)){
+            //get error flag from configuration if it's set in setLaunchConfiguration
+            String errorMessage = configuration.getAttribute(GeronimoServerBehaviourDelegate.ERROR_SETUP_LAUNCH_CONFIGURATION,"");
+            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, errorMessage, null));
+        }
+        
 		IServer server = ServerUtil.getServer(configuration);
 		if (server == null) {
 			throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, Messages.missingServer, null));

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java?rev=797342&r1=797341&r2=797342&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/GeronimoServerBehaviourDelegate.java Fri Jul 24 07:00:11 2009
@@ -94,36 +94,52 @@
 
 	protected transient IDebugEventSetListener processListener;
 
+    public static final String ERROR_SETUP_LAUNCH_CONFIGURATION = "errorInSetupLaunchConfiguration";
+
 	abstract protected ClassLoader getContextClassLoader();
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#setupLaunchConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy,
-	 *      org.eclipse.core.runtime.IProgressMonitor)
-	 */
-	public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy wc, IProgressMonitor monitor) throws CoreException {
-		if (isRemote())// No launch for remote servers.
-			return;
 
-		wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, getRuntimeClass());
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.wst.server.core.model.ServerBehaviourDelegate#setupLaunchConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy,
+     *      org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy wc, IProgressMonitor monitor) throws CoreException {
+        if (isRemote())// No launch for remote servers.
+            return;
 
-		GeronimoRuntimeDelegate runtime = getRuntimeDelegate();
+        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, getRuntimeClass());
 
-		IVMInstall vmInstall = runtime.getVMInstall();
-		if (vmInstall != null)
-			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
+        GeronimoRuntimeDelegate runtime = getRuntimeDelegate();
 
-		setupLaunchClasspath(wc, vmInstall);
+        IVMInstall vmInstall = runtime.getVMInstall();
+        if (vmInstall != null)
+            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, JavaRuntime.newJREContainerPath(vmInstall).toPortableString());
+
+        String existingProgArgs = null;
+        wc.setAttribute(ERROR_SETUP_LAUNCH_CONFIGURATION, (String)null);
+        
+        try{
+            setupLaunchClasspath(wc, vmInstall);
+            existingProgArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
+        }catch (CoreException e){
+            // Throwing a CoreException at this time will not accomplish anything useful as WTP will 
+            // will essentially ignore it. Instead set a flag in the configuration that can 
+            // subsequently be checked when an attempt is made to launch the server in 
+            // GeronimoLaunchConfigurationDelegate.launch(). At that point a CoreException will be
+            // thrown that WTP will handle properly and will display an error dialog which is 
+            // exactly what we want the GEP user to see.
+            wc.setAttribute(ERROR_SETUP_LAUNCH_CONFIGURATION, e.getMessage());
+        }
+        String serverProgArgs = getServerDelegate().getConsoleLogLevel();
+        if (existingProgArgs == null || existingProgArgs.indexOf(serverProgArgs) < 0) {
+            wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, serverProgArgs);
+        }
+        
+        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, getServerDelegate().getVMArgs());
+    }
 
-		String existingProgArgs = wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
-		String serverProgArgs = getServerDelegate().getConsoleLogLevel();
-		if (existingProgArgs == null || existingProgArgs.indexOf(serverProgArgs) < 0) {
-			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, serverProgArgs);
-		}
-		
-		wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, getServerDelegate().getVMArgs());
-	}
 
 	/**
 	 * @param launch