Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2012-04-27 16:08:05 +0000
committerEugene Tarassov2012-04-27 16:08:05 +0000
commita6242b7a5291b625f95cc50bf1fe431ca77a2dcc (patch)
tree5dfb934bc20b433313f1f305701937b607496490 /plugins
parentdaa87170c440faefa19c2208416dc696656958f9 (diff)
downloadorg.eclipse.tcf-a6242b7a5291b625f95cc50bf1fe431ca77a2dcc.tar.gz
org.eclipse.tcf-a6242b7a5291b625f95cc50bf1fe431ca77a2dcc.tar.xz
org.eclipse.tcf-a6242b7a5291b625f95cc50bf1fe431ca77a2dcc.zip
TCF Debugger: OSGi service definition: IValueAddService
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tcf.debug/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java32
-rw-r--r--plugins/org.eclipse.tcf/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.tcf/src/org/eclipse/tcf/Activator.java3
-rw-r--r--plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/OSGIServices.java72
-rw-r--r--plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/services/IValueAddService.java48
6 files changed, 155 insertions, 6 deletions
diff --git a/plugins/org.eclipse.tcf.debug/META-INF/MANIFEST.MF b/plugins/org.eclipse.tcf.debug/META-INF/MANIFEST.MF
index 7aae56cda..fbfea7181 100644
--- a/plugins/org.eclipse.tcf.debug/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.tcf.debug/META-INF/MANIFEST.MF
@@ -11,6 +11,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.core.filesystem;bundle-version="1.3.0"
Import-Package: org.eclipse.tcf.core;version="1.0.0",
+ org.eclipse.tcf.osgi;version="1.0.0",
+ org.eclipse.tcf.osgi.services;version="1.0.0",
org.eclipse.tcf.protocol;version="1.0.0",
org.eclipse.tcf.services;version="1.0.0",
org.eclipse.tcf.util;version="1.0.0"
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java
index 19f7a3032..824d8cf55 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java
@@ -32,6 +32,9 @@ import org.eclipse.tcf.internal.debug.Activator;
import org.eclipse.tcf.internal.debug.model.ITCFConstants;
import org.eclipse.tcf.internal.debug.model.TCFLaunch;
import org.eclipse.tcf.internal.debug.model.TCFMemoryRegion;
+import org.eclipse.tcf.osgi.OSGIServices;
+import org.eclipse.tcf.osgi.services.IValueAddService;
+import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.JSON;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IMemoryMap;
@@ -71,6 +74,7 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
super(props);
}
+ @Override
public String toString() {
StringBuffer bf = new StringBuffer();
Map<String,Object> props = getProperties();
@@ -280,6 +284,7 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
* Create new TCF launch object.
* @return new TCFLaunch object
*/
+ @Override
public ILaunch getLaunch(final ILaunchConfiguration configuration, final String mode) throws CoreException {
return new TCFTask<ILaunch>() {
int cnt;
@@ -315,14 +320,31 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
null));
}
if (monitor != null) monitor.beginTask("Launching TCF debugger session", task_cnt); //$NON-NLS-1$
- final String id =
- configuration.getAttribute(ATTR_USE_LOCAL_AGENT, true) ?
- local_id : configuration.getAttribute(ATTR_PEER_ID, "");
- Protocol.invokeLater(new Runnable() {
+ final String id = configuration.getAttribute(ATTR_USE_LOCAL_AGENT, true) ? local_id : configuration.getAttribute(ATTR_PEER_ID, "");
+
+ Runnable runnable = new Runnable() {
public void run() {
((TCFLaunch)launch).launchTCF(mode, id);
if (monitor != null) monitor.done();
}
- });
+ };
+
+ // If the id is not a redirection path of itself, and a value-add service is registered,
+ // ask the value-add service for the redirection path
+ if (id.indexOf('/') <= 0 && OSGIServices.getValueAddService() != null) {
+ IPeer peer = Protocol.getLocator().getPeers().get(id);
+ if (peer == null) {
+ Protocol.invokeLater(runnable);
+ } else {
+ OSGIServices.getValueAddService().getRedirectionPath(peer, new IValueAddService.DoneGetRedirectionPath() {
+ public void doneGetRedirectionPath(Throwable error, String redirectionPath) {
+ ((TCFLaunch)launch).launchTCF(mode, error == null ? redirectionPath : id);
+ if (monitor != null) monitor.done();
+ }
+ });
+ }
+ } else {
+ Protocol.invokeLater(runnable);
+ }
}
}
diff --git a/plugins/org.eclipse.tcf/META-INF/MANIFEST.MF b/plugins/org.eclipse.tcf/META-INF/MANIFEST.MF
index 18f1f8b82..d4dd32162 100644
--- a/plugins/org.eclipse.tcf/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.tcf/META-INF/MANIFEST.MF
@@ -12,4 +12,6 @@ Require-Bundle: org.eclipse.core.runtime
Bundle-Activator: org.eclipse.tcf.Activator
Import-Package: org.eclipse.tcf.core;version="1.0.0",
org.eclipse.tcf.protocol;version="1.0.0"
-Export-Package: org.eclipse.tcf.ssl;version="1.0.0"
+Export-Package: org.eclipse.tcf.ssl;version="1.0.0",
+ org.eclipse.tcf.osgi;version="1.0.0",
+ org.eclipse.tcf.osgi.services;version="1.0.0"
diff --git a/plugins/org.eclipse.tcf/src/org/eclipse/tcf/Activator.java b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/Activator.java
index 978da4652..aa187a7e1 100644
--- a/plugins/org.eclipse.tcf/src/org/eclipse/tcf/Activator.java
+++ b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/Activator.java
@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.core.ChannelTCP;
import org.eclipse.tcf.internal.nls.TcfPluginMessages;
+import org.eclipse.tcf.osgi.OSGIServices;
import org.eclipse.tcf.protocol.ILogger;
import org.eclipse.tcf.protocol.IServiceProvider;
import org.eclipse.tcf.protocol.Protocol;
@@ -79,6 +80,7 @@ public class Activator extends Plugin {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
+ OSGIServices.getInstance().start(context);
debug = Platform.inDebugMode();
TRACE = "true".equals(Platform.getDebugOption("org.eclipse.tcf/debug")); //$NON-NLS-1$
@@ -127,6 +129,7 @@ public class Activator extends Plugin {
public void stop(BundleContext context) throws Exception {
context.removeBundleListener(bundle_listener);
queue.shutdown();
+ OSGIServices.getInstance().stop(context);
plugin = null;
super.stop(context);
}
diff --git a/plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/OSGIServices.java b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/OSGIServices.java
new file mode 100644
index 000000000..030e4e807
--- /dev/null
+++ b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/OSGIServices.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.osgi;
+
+import org.eclipse.tcf.osgi.services.IValueAddService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * OSGi service manager implementation.
+ */
+public class OSGIServices implements BundleActivator {
+ // Reference to the value-add service tracker
+ private ServiceTracker<IValueAddService, IValueAddService> valueAddServiceTracker = null;
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static OSGIServices instance = new OSGIServices();
+ }
+
+ /**
+ * Constructor.
+ */
+ /* default */ OSGIServices() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of the extension point manager.
+ */
+ public static OSGIServices getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ /*
+ * Register the service tracker for the value-add service.
+ */
+ valueAddServiceTracker = new ServiceTracker<IValueAddService, IValueAddService>(context, IValueAddService.class, null);
+ valueAddServiceTracker.open();
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ valueAddServiceTracker.close();
+ valueAddServiceTracker = null;
+ }
+
+ /**
+ * Returns the value-add service if registered.
+ *
+ * @return The value-add service instance or <code>null</code>.
+ */
+ public static IValueAddService getValueAddService() {
+ return getInstance().valueAddServiceTracker != null ? getInstance().valueAddServiceTracker.getService() : null;
+ }
+}
diff --git a/plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/services/IValueAddService.java b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/services/IValueAddService.java
new file mode 100644
index 000000000..0febb5c3e
--- /dev/null
+++ b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/osgi/services/IValueAddService.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.osgi.services;
+
+import org.eclipse.tcf.protocol.IPeer;
+
+/**
+ * A service whose purpose is to provide value-add related information for a
+ * given peer.
+ */
+public interface IValueAddService {
+
+ /**
+ * Returns the redirection path to use for the given peer. The redirection
+ * path is encoded as string where the id's to redirect the communication
+ * through, are separated by '/'.
+ * <p>
+ * If there are no value-adds to redirect through, the passed in peer id is
+ * returned as is.
+ * <p>
+ * If there are value-add's to redirect through, the passed in peer id will
+ * be prefixed with the value-add id's to redirect through.
+ *
+ * @param peerId The peer id. Must not be <code>null</code>.
+ * @param done The client callback. Must not be <code>null</code>.
+ */
+ public void getRedirectionPath(IPeer peer, DoneGetRedirectionPath done);
+
+ /**
+ * Client call back interface for getRedirectionPath(...).
+ */
+ interface DoneGetRedirectionPath {
+ /**
+ * Called when the redirection path has been fully determined.
+ *
+ * @param error The error description if operation failed, <code>null</code> if succeeded.
+ * @param redirectionPath The redirection path or <code>null</code>.
+ */
+ void doneGetRedirectionPath(Throwable error, String redirectionPath);
+}
+}

Back to the top