You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2016/02/17 23:24:22 UTC
svn commit: r1730959 - in
/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal:
JVMDebuggerConnection.java SlingLaunchpadBehaviour.java
Author: rombert
Date: Wed Feb 17 22:24:22 2016
New Revision: 1730959
URL: http://svn.apache.org/viewvc?rev=1730959&view=rev
Log:
SLING-3605 - Debug based on bundles deployed on the server
Better progress reporting and cancellation support
Modified:
sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java
sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java?rev=1730959&r1=1730958&r2=1730959&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/JVMDebuggerConnection.java Wed Feb 17 22:24:22 2016
@@ -24,6 +24,7 @@ import java.util.Map;
import org.apache.sling.ide.eclipse.core.ISlingLaunchpadConfiguration;
import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
import org.apache.sling.ide.eclipse.core.launch.SourceReferenceResolver;
+import org.apache.sling.ide.eclipse.core.progress.ProgressUtils;
import org.apache.sling.ide.osgi.OsgiClient;
import org.apache.sling.ide.osgi.OsgiClientException;
import org.apache.sling.ide.osgi.SourceReference;
@@ -31,6 +32,7 @@ import org.eclipse.core.runtime.CoreExce
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@@ -55,6 +57,9 @@ public class JVMDebuggerConnection {
boolean connectInDebugMode(ILaunch launch, IServer iServer, IProgressMonitor monitor)
throws CoreException {
+
+ long start = System.currentTimeMillis();
+
this.launch = launch;
boolean success = false;
IVMConnector connector = null;
@@ -104,20 +109,27 @@ public class JVMDebuggerConnection {
}
// 2. add the other modules deployed on server
+ ProgressUtils.advance(monitor, 10); // 20/50
+
SourceReferenceResolver resolver = Activator.getDefault().getSourceReferenceResolver();
if ( resolver != null ) {
try {
- for ( SourceReference reference : osgiClient.findSourceReferences() ) {
+ List<SourceReference> references = osgiClient.findSourceReferences();
+ SubMonitor subMonitor = SubMonitor.convert(monitor, "Resolving source references", 29).setWorkRemaining(references.size());
+ for ( SourceReference reference : references ) {
try {
IRuntimeClasspathEntry classpathEntry = resolver.resolve(reference);
if ( classpathEntry != null ) {
classpathEntries.add(classpathEntry);
}
+ ProgressUtils.advance(subMonitor, 1);
+
} catch (CoreException e) {
// don't fail the debug launch for artifact resolution errors
Activator.getDefault().getPluginLogger().warn("Failed resolving source reference", e);
}
}
+ subMonitor.done(); // 49/50
} catch (OsgiClientException e1) {
throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, e1.getMessage(), e1));
}
@@ -132,12 +144,13 @@ public class JVMDebuggerConnection {
sourceLocator.initializeParticipants();
launch.setSourceLocator(sourceLocator);
- monitor.worked(1);
-
// connect to remote VM
try{
- connector.connect(connectMap, monitor, launch);
+ connector.connect(connectMap, monitor, launch); // 50/50
success = true;
+
+ long elapsedMillis = System.currentTimeMillis() - start;
+ Activator.getDefault().getPluginLogger().tracePerformance("Debug connection to {0}", elapsedMillis, iServer.getName());
} catch(Exception e) {
throw new CoreException(new Status(IStatus.ERROR, "org.apache.sling.ide.eclipse.wst",
"could not establish debug connection to "+iServer.getHost()+" : "+debugPort, e));
Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java?rev=1730959&r1=1730958&r2=1730959&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java Wed Feb 17 22:24:22 2016
@@ -49,6 +49,7 @@ import org.eclipse.core.runtime.IProgres
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.core.IJavaProject;
@@ -82,7 +83,7 @@ public class SlingLaunchpadBehaviour ext
boolean success = false;
Result<ResourceProxy> result = null;
- monitor.beginTask("Starting server", 7);
+ monitor = SubMonitor.convert(monitor, "Starting server", 10).setWorkRemaining(50);
Repository repository;
RepositoryInfo repositoryInfo;
@@ -99,11 +100,12 @@ public class SlingLaunchpadBehaviour ext
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
- monitor.worked(2); // 2/7 done
+ monitor.worked(10); // 10/50 done
try {
if (getServer().getMode().equals(ILaunchManager.DEBUG_MODE)) {
debuggerConnection = new JVMDebuggerConnection(client);
+
success = debuggerConnection.connectInDebugMode(launch, getServer(), monitor);
monitor.worked(5); // 7/7 done
@@ -114,15 +116,15 @@ public class SlingLaunchpadBehaviour ext
result = command.execute();
success = result.isSuccess();
- monitor.worked(1); // 3/7 done
+ monitor.worked(10); // 20/50 done
try {
EmbeddedArtifactLocator artifactLocator = Activator.getDefault().getArtifactLocator();
installBundle(monitor, client, artifactLocator.loadToolingSupportBundle(),
- EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME); // 5/7 done
+ EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME); // 35/50 done
installBundle(monitor, client, artifactLocator.loadSourceSupportBundle(),
- EmbeddedArtifactLocator.SUPPORT_SOURCE_BUNDLE_SYMBOLIC_NAME); // 7/7 done
+ EmbeddedArtifactLocator.SUPPORT_SOURCE_BUNDLE_SYMBOLIC_NAME); // 50/50 done
} catch ( IOException | OsgiClientException e) {
Activator.getDefault().getPluginLogger()
@@ -140,6 +142,9 @@ public class SlingLaunchpadBehaviour ext
}
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message));
}
+ } catch ( CoreException | RuntimeException e ) {
+ setServerState(IServer.STATE_STOPPED);
+ throw e;
} finally {
monitor.done();
}
@@ -150,7 +155,7 @@ public class SlingLaunchpadBehaviour ext
Version remoteVersion = client.getBundleVersion(bundleSymbolicName);
- monitor.worked(1);
+ monitor.worked(7);
final Version embeddedVersion = new Version(bundle.getOsgiFriendlyVersion());
@@ -167,7 +172,7 @@ public class SlingLaunchpadBehaviour ext
launchpadServer.setBundleVersion(bundleSymbolicName, remoteVersion,
monitor);
- monitor.worked(1);
+ monitor.worked(8);
}
// TODO refine signature