Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-01-06 07:32:57 +0000
committerUwe Stieber2012-01-06 07:32:57 +0000
commit8ec4bd3f1ca98b91c1dc56775f8a81c16d73589c (patch)
treef9b5b721cc910ee3fa77afc43159dc1a5ef46b62
parent42c35c53b42f48e975a73d4fc22d247a7656067b (diff)
downloadorg.eclipse.tcf-8ec4bd3f1ca98b91c1dc56775f8a81c16d73589c.tar.gz
org.eclipse.tcf-8ec4bd3f1ca98b91c1dc56775f8a81c16d73589c.tar.xz
org.eclipse.tcf-8ec4bd3f1ca98b91c1dc56775f8a81c16d73589c.zip
Target Explorer: Add contexts service implementation
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/META-INF/MANIFEST.MF4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/build.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/plugin.xml13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/interfaces/IContexts.java99
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ContextsProxy.java86
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ServiceProvider.java37
6 files changed, 240 insertions, 2 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/META-INF/MANIFEST.MF
index d9a7c5455..59b4f3063 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/META-INF/MANIFEST.MF
@@ -6,6 +6,8 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.tcf.te.tcf.services.contexts.activator.CoreBundleActivator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
- org.eclipse.tcf.te.runtime;bundle-version="1.0.0"
+ org.eclipse.tcf.te.runtime;bundle-version="1.0.0",
+ org.eclipse.tcf;bundle-version="1.0.0",
+ org.eclipse.tcf.core;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/build.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/build.properties
index 41eb6ade2..6f20375d6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/build.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/build.properties
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/plugin.xml
new file mode 100644
index 000000000..905c516cf
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+<!-- TCF service provider contributions -->
+ <extension point="org.eclipse.tcf.serviceProviders">
+ <serviceProvider
+ class="org.eclipse.tcf.te.tcf.services.contexts.internal.ServiceProvider"
+ id="org.eclipse.tcf.te.tcf.services.contexts.serviceProvider">
+ </serviceProvider>
+ </extension>
+
+</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/interfaces/IContexts.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/interfaces/IContexts.java
new file mode 100644
index 000000000..f9bec85d1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/interfaces/IContexts.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.te.tcf.services.contexts.interfaces;
+
+import org.eclipse.tcf.protocol.IService;
+
+/**
+ * TCF contexts service.
+ */
+public interface IContexts extends IService {
+
+ /**
+ * The service name.
+ */
+ public static final String NAME = "Contexts"; //$NON-NLS-1$
+
+ /**
+ * Context handler delegate.
+ */
+ public interface IDelegate {
+
+ /**
+ * Checks if the delegate can handle the context identified by the
+ * given id.
+ *
+ * @param contextID The context id. Must not be <code>null</code>.
+ * @return <code>True</code> if the delegate can handle the context id, <code>false</code> otherwise.
+ */
+ public boolean canHandle(String contextID);
+
+ /**
+ * Returns the name of the context identified by the given id.
+ *
+ * @param contextID The context id. Must not be <code>null</code>.
+ * @return The name of the context, or <code>null</code> if the context does not exist
+ * or is not handled by this delegate.
+ */
+ public String getName(String contextID);
+
+ /**
+ * Checks if the context identified by the given id is available. Available in this
+ * context means other clients can access data for this context.
+ *
+ * @param contextID The context id. Must not be <code>null</code>.
+ * @return <code>True</code> if the context is available, <code>false</code> otherwise.
+ */
+ public boolean isAvailable(String contextID);
+
+ /**
+ * Client call back interface for makeAvailable().
+ */
+ public interface DoneMakeAvailable {
+ /**
+ * Called when context has been made available.
+ *
+ * @param error The error description if the operation failed, <code>null</code> if succeeded.
+ */
+ void doneMakeAvailable(Exception error);
+ }
+
+ /**
+ * Attempt to make the context identified by the given id available to other
+ * clients.
+ *
+ * @param contextID The context id. Must not be <code>null</code>.
+ * @param done The call back interface called when the operation is completed. Must not be <code>null</code>.
+ */
+ public void makeAvailable(String contextID, DoneMakeAvailable done);
+ }
+
+ /**
+ * Returns the first delegate that can handle the given context ID.
+ *
+ * @param contextID The context id. Must not be <code>null</code>.
+ * @return The delegate or <code>null</code>.
+ */
+ public IDelegate getDelegate(String contextID);
+
+ /**
+ * Adds the given context handler delegate to the service.
+ *
+ * @param delegate The context handler delegate. Must not be <code>null</code>.
+ */
+ public void addDelegate(IDelegate delegate);
+
+ /**
+ * Removes the given context handler delegate from the service.
+ *
+ * @param delegate The context handler delegate. Must not be <code>null</code>.
+ */
+ public void removeDelegate(IDelegate delegate);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ContextsProxy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ContextsProxy.java
new file mode 100644
index 000000000..07b5a114d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ContextsProxy.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.te.tcf.services.contexts.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContexts;
+
+/**
+ * Contexts service proxy implementation.
+ */
+public class ContextsProxy implements IContexts {
+ // The channel instance the proxy is using
+ /* default */ final IChannel channel;
+
+ // The list of context handler delegates
+ private final List<IContexts.IDelegate> delegates = new ArrayList<IContexts.IDelegate>();
+
+ /**
+ * Constructor.
+ *
+ * @param channel The channel. Must not be <code>null</code>.
+ */
+ public ContextsProxy(IChannel channel) {
+ Assert.isNotNull(channel);
+ this.channel = channel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IService#getName()
+ */
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContexts#getDelegate(java.lang.String)
+ */
+ @Override
+ public IDelegate getDelegate(String contextID) {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(contextID);
+
+ // Make a snapshot of the registered delegates
+ IContexts.IDelegate[] candidates = delegates.toArray(new IContexts.IDelegate[delegates.size()]);
+ for (IContexts.IDelegate candidate : candidates) {
+ if (candidate.canHandle(contextID)) {
+ return candidate;
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContexts#addDelegate(org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContexts.IDelegate)
+ */
+ @Override
+ public void addDelegate(IDelegate delegate) {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(delegate);
+ if (!delegates.contains(delegate)) delegates.add(delegate);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContexts#removeDelegate(org.eclipse.tcf.te.tcf.services.contexts.interfaces.IContexts.IDelegate)
+ */
+ @Override
+ public void removeDelegate(IDelegate delegate) {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(delegate);
+ delegates.remove(delegate);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ServiceProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ServiceProvider.java
new file mode 100644
index 000000000..baba1a511
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.services.contexts/src/org/eclipse/tcf/te/tcf/services/contexts/internal/ServiceProvider.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.te.tcf.services.contexts.internal;
+
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IService;
+import org.eclipse.tcf.protocol.IServiceProvider;
+
+/**
+ * TCF contexts service provider implementation.
+ */
+public class ServiceProvider implements IServiceProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IServiceProvider#getLocalService(org.eclipse.tcf.protocol.IChannel)
+ */
+ @Override
+ public IService[] getLocalService(IChannel channel) {
+ return new IService[] { new ContextsProxy(channel) };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IServiceProvider#getServiceProxy(org.eclipse.tcf.protocol.IChannel, java.lang.String)
+ */
+ @Override
+ public IService getServiceProxy(IChannel channel, String service_name) {
+ return null;
+ }
+
+}

Back to the top