Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-07-28 13:56:45 -0400
committerUwe Stieber2012-07-28 13:56:45 -0400
commit0ee581187cf4096e802a7d49bd74ecd2d3ee6bcf (patch)
tree0368da51a7a8abc6bc9b58a0c149c95c93d8a2da /examples
parent62bf327a2f65043b3dcd5c262ea3b15ee25a6c06 (diff)
downloadorg.eclipse.tcf-0ee581187cf4096e802a7d49bd74ecd2d3ee6bcf.tar.gz
org.eclipse.tcf-0ee581187cf4096e802a7d49bd74ecd2d3ee6bcf.tar.xz
org.eclipse.tcf-0ee581187cf4096e802a7d49bd74ecd2d3ee6bcf.zip
Examples: Update daytime example to use the service provider extension point to register the service
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.tcf.examples.daytime/plugin.xml7
-rw-r--r--examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProvider.java38
-rw-r--r--examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProxy.java24
3 files changed, 46 insertions, 23 deletions
diff --git a/examples/org.eclipse.tcf.examples.daytime/plugin.xml b/examples/org.eclipse.tcf.examples.daytime/plugin.xml
index aa8e245fb..244405f19 100644
--- a/examples/org.eclipse.tcf.examples.daytime/plugin.xml
+++ b/examples/org.eclipse.tcf.examples.daytime/plugin.xml
@@ -2,8 +2,11 @@
<?eclipse version="3.2"?>
<plugin>
- <extension point="org.eclipse.tcf.startup">
- <class name="org.eclipse.tcf.internal.examples.daytime.DaytimeServiceProxy"/>
+<!-- TCF service provider contributions -->
+ <extension point="org.eclipse.tcf.serviceProviders">
+ <serviceProvider
+ class="org.eclipse.tcf.internal.examples.daytime.DaytimeServiceProvider">
+ </serviceProvider>
</extension>
</plugin>
diff --git a/examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProvider.java b/examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProvider.java
new file mode 100644
index 000000000..09e7c1b63
--- /dev/null
+++ b/examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProvider.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.internal.examples.daytime;
+
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IService;
+import org.eclipse.tcf.protocol.IServiceProvider;
+
+/**
+ * Daytime service provider implementation.
+ */
+public class DaytimeServiceProvider implements IServiceProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IServiceProvider#getLocalService(org.eclipse.tcf.protocol.IChannel)
+ */
+ public IService[] getLocalService(IChannel channel) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IServiceProvider#getServiceProxy(org.eclipse.tcf.protocol.IChannel, java.lang.String)
+ */
+ public IService getServiceProxy(IChannel channel, String service_name) {
+ if (IDaytimeService.NAME.equals(service_name)) {
+ return new DaytimeServiceProxy(channel);
+ }
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProxy.java b/examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProxy.java
index 72dd6ddd9..ccbd02b74 100644
--- a/examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProxy.java
+++ b/examples/org.eclipse.tcf.examples.daytime/src/org/eclipse/tcf/internal/examples/daytime/DaytimeServiceProxy.java
@@ -14,9 +14,10 @@ package org.eclipse.tcf.internal.examples.daytime;
import org.eclipse.tcf.core.Command;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.protocol.Protocol;
-
+/**
+ * Daytime service proxy implementation.
+ */
public class DaytimeServiceProxy implements IDaytimeService {
private final IChannel channel;
@@ -53,23 +54,4 @@ public class DaytimeServiceProxy implements IDaytimeService {
}
}.token;
}
-
- static {
- /*
- * Make Daytime Service proxy available to all potential clients by creating
- * the proxy object every time a TCF communication channel is opened.
- * Note: extension point "org.eclipse.tcf.startup" is used to load this class
- * at TCF startup time, so proxy factory is properly activated even if nobody
- * import directly from this plugin.
- */
- Protocol.addChannelOpenListener(new Protocol.ChannelOpenListener() {
-
- public void onChannelOpen(IChannel channel) {
- // Check if remote server provides Daytime service
- if (channel.getRemoteService(IDaytimeService.NAME) == null) return;
- // Create service proxy
- channel.setServiceProxy(IDaytimeService.class, new DaytimeServiceProxy(channel));
- }
- });
- }
}

Back to the top