Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2008-02-21 18:25:18 -0500
committereutarass2008-02-21 18:25:18 -0500
commit521178c66ba2989ab837a9d7bb1c4a75216cfde2 (patch)
tree712d92bd8ef1fd4860d8f56f8a9b905bb2f216c8 /examples/org.eclipse.tm.tcf.examples.daytime
parent39964814a5c76b9c259bb2f670cb84e4d299abef (diff)
downloadorg.eclipse.tcf-521178c66ba2989ab837a9d7bb1c4a75216cfde2.tar.gz
org.eclipse.tcf-521178c66ba2989ab837a9d7bb1c4a75216cfde2.tar.xz
org.eclipse.tcf-521178c66ba2989ab837a9d7bb1c4a75216cfde2.zip
In order to comply with naming conventions at Eclipse, plugins, packages, etc. are renamed from com.windriver.* to org.eclipse.tm.*
Copyright notices are updated to include year 2008.
Diffstat (limited to 'examples/org.eclipse.tm.tcf.examples.daytime')
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/.classpath7
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/.project28
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/META-INF/MANIFEST.MF11
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/about.html28
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/build.properties6
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/plugin.xml9
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/Activator.java49
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/DaytimeServiceProxy.java64
-rw-r--r--examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/IDaytimeService.java42
9 files changed, 244 insertions, 0 deletions
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/.classpath b/examples/org.eclipse.tm.tcf.examples.daytime/.classpath
new file mode 100644
index 000000000..021596729
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/.project b/examples/org.eclipse.tm.tcf.examples.daytime/.project
new file mode 100644
index 000000000..d9c4d399a
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.tm.tcf.examples.daytime</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/META-INF/MANIFEST.MF b/examples/org.eclipse.tm.tcf.examples.daytime/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..ebe2c8a77
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Examples Plug-in
+Bundle-SymbolicName: org.eclipse.tm.tcf.examples.daytime;singleton:=true
+Bundle-Version: 0.2.0
+Bundle-Activator: org.eclipse.tm.internal.tcf.examples.daytime.Activator
+Bundle-Vendor: Eclipse.org
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.tm.tcf
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.tm.internal.tcf.examples.daytime
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/about.html b/examples/org.eclipse.tm.tcf.examples.daytime/about.html
new file mode 100644
index 000000000..6c5b3615b
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>January 10, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/build.properties b/examples/org.eclipse.tm.tcf.examples.daytime/build.properties
new file mode 100644
index 000000000..2d5759904
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/plugin.xml b/examples/org.eclipse.tm.tcf.examples.daytime/plugin.xml
new file mode 100644
index 000000000..4611c0a05
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/plugin.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension point="org.eclipse.tm.tcf.startup">
+ <class name="org.eclipse.tm.internal.tcf.examples.daytime.DaytimeServiceProxy"/>
+ </extension>
+
+</plugin>
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/Activator.java b/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/Activator.java
new file mode 100644
index 000000000..1d2b74ae8
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/Activator.java
@@ -0,0 +1,49 @@
+package org.eclipse.tm.internal.tcf.examples.daytime;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.tm.tcf.examples.daytime";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+}
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/DaytimeServiceProxy.java b/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/DaytimeServiceProxy.java
new file mode 100644
index 000000000..066fea0a2
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/DaytimeServiceProxy.java
@@ -0,0 +1,64 @@
+package org.eclipse.tm.internal.tcf.examples.daytime;
+
+import org.eclipse.tm.tcf.core.Command;
+import org.eclipse.tm.tcf.protocol.IChannel;
+import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.protocol.Protocol;
+
+
+public class DaytimeServiceProxy implements IDaytimeService {
+
+ private final IChannel channel;
+
+ DaytimeServiceProxy(IChannel channel) {
+ this.channel = channel;
+ }
+
+ /**
+ * Return service name, as it appears on the wire - a TCF name of the service.
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /**
+ * The method translates arguments to JSON string and sends the command message
+ * to remote server. When response arrives, it is translated from JSON to
+ * Java object, which are used to call call-back object.
+ *
+ * The translation (marshaling) is done by using utility class Command.
+ */
+ public IToken getTimeOfDay(String tz, final DoneGetTimeOfDay done) {
+ return new Command(channel, this, "getTimeOfDay", new Object[]{ tz }) {
+ @Override
+ public void done(Exception error, Object[] args) {
+ String str = null;
+ if (error == null) {
+ assert args.length == 3;
+ error = toError(args[0], args[1]);
+ str = (String)args[2];
+ }
+ done.doneGetTimeOfDay(token, error, str);
+ }
+ }.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.tm.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));
+ }
+ });
+ }
+}
diff --git a/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/IDaytimeService.java b/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/IDaytimeService.java
new file mode 100644
index 000000000..cc8edbb30
--- /dev/null
+++ b/examples/org.eclipse.tm.tcf.examples.daytime/src/org/eclipse/tm/internal/tcf/examples/daytime/IDaytimeService.java
@@ -0,0 +1,42 @@
+package org.eclipse.tm.internal.tcf.examples.daytime;
+
+import org.eclipse.tm.tcf.protocol.IService;
+import org.eclipse.tm.tcf.protocol.IToken;
+
+/**
+ * IDaytimeService allows retrieving the time of day from a remote system.
+ */
+public interface IDaytimeService extends IService {
+
+ /**
+ * This service name, as it appears on the wire - a TCF name of the service.
+ */
+ public static final String NAME = "Daytime";
+
+ /**
+ * Retrieve the time of day from remote system.
+ * The method sends the command to remote server and returns -
+ * it does not wait for the server response. Instead a client should provide
+ * a call-back object that will be called when the server answers the command
+ * or when the command is aborted by communication error.
+ * @param tz - time zone name.
+ * @param done - a call-back object.
+ * @return a handle for the pending command. The handle can be used to cancel the command,
+ * and to match responses to requests - if same call-back object is used for
+ * multiple requests.
+ */
+ IToken getTimeOfDay(String tz, DoneGetTimeOfDay done);
+
+ /**
+ * Call-back interface for getTimeOfDay() command.
+ */
+ interface DoneGetTimeOfDay {
+ /**
+ * This method is called when getTimeOfDay() command is completed.
+ * @param token - pending command handle.
+ * @param error - null if the command is successful.
+ * @param str - a String of the form "01 MAR 2006 11:25:12 CET"
+ */
+ void doneGetTimeOfDay(IToken token, Exception error, String str);
+ }
+}

Back to the top