Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-03-25 05:18:31 +0000
committerslewis2014-03-25 05:18:31 +0000
commitd98dae958184637ab767fb9566fe07b58031ba8d (patch)
tree2dccee2b6fe8afbd7dfed61395e036fea1cf112c
parent5b5e004b91e6dca670fd3e53594f40bae5b0887c (diff)
downloadorg.eclipse.ecf-d98dae958184637ab767fb9566fe07b58031ba8d.tar.gz
org.eclipse.ecf-d98dae958184637ab767fb9566fe07b58031ba8d.tar.xz
org.eclipse.ecf-d98dae958184637ab767fb9566fe07b58031ba8d.zip
Initial checkin of c.m.e.t.async and c.m.e.t.consumer.ds.async example
java8/completablefuture examples Change-Id: Ie6dc00121ba25063a69bda257f6b2743d8ed8894
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/.classpath7
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/.gitignore1
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/.project28
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.pde.core.prefs3
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/META-INF/MANIFEST.MF9
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/build.properties4
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeService.java26
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeServiceAsync.java23
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.classpath7
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.gitignore1
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.project33
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.pde.core.prefs3
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/META-INF/MANIFEST.MF10
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/OSGI-INF/timeservicecomponentasync.xml5
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/build.properties6
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/src/com/mycorp/examples/timeservice/consumer/ds/async/TimeServiceComponentAsync.java24
18 files changed, 204 insertions, 0 deletions
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/.classpath b/examples/bundles/com.mycorp.examples.timeservice.async/.classpath
new file mode 100644
index 000000000..eca7bdba8
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/.gitignore b/examples/bundles/com.mycorp.examples.timeservice.async/.gitignore
new file mode 100644
index 000000000..5e56e040e
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/.project b/examples/bundles/com.mycorp.examples.timeservice.async/.project
new file mode 100644
index 000000000..62d0c40c5
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.mycorp.examples.timeservice.async</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/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..0c68a61dc
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.pde.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..f29e940a0
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/META-INF/MANIFEST.MF b/examples/bundles/com.mycorp.examples.timeservice.async/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..41f0c112c
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF RS Example Timeservice Async API
+Bundle-SymbolicName: com.mycorp.examples.timeservice.async
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse.org - ECF
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Export-Package: com.mycorp.examples.timeservice;version="2.0.0"
+Bundle-ActivationPolicy: lazy
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/build.properties b/examples/bundles/com.mycorp.examples.timeservice.async/build.properties
new file mode 100644
index 000000000..34d2e4d2d
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeService.java b/examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeService.java
new file mode 100644
index 000000000..4149d5bb0
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeService.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Composent, Inc. 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: Scott Lewis - initial API and implementation
+ ******************************************************************************/
+package com.mycorp.examples.timeservice;
+
+/**
+ * Example OSGi service for retrieving current time in milliseconds from January
+ * 1, 1970.
+ *
+ */
+public interface ITimeService {
+
+ /**
+ * Get current time.
+ *
+ * @return Long current time in milliseconds since Jan 1, 1970. Will not
+ * return <code>null</code>.
+ */
+ public Long getCurrentTime();
+
+}
diff --git a/examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeServiceAsync.java b/examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeServiceAsync.java
new file mode 100644
index 000000000..299871f70
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.async/src/com/mycorp/examples/timeservice/ITimeServiceAsync.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Composent, Inc. 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: Scott Lewis - initial API and implementation
+ ******************************************************************************/
+package com.mycorp.examples.timeservice;
+
+import java.util.concurrent.CompletableFuture;
+
+public interface ITimeServiceAsync {
+
+ /**
+ * Get current time using Java 8 {@link CompletableFuture}.
+ *
+ * @return CompletableFuture<Long> The future value time in milliseconds since Jan 1, 1970. Will not
+ * return <code>null</code>.
+ */
+ public CompletableFuture<Long> getCurrentTimeAsync();
+
+}
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.classpath b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.classpath
new file mode 100644
index 000000000..eca7bdba8
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.gitignore b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.gitignore
new file mode 100644
index 000000000..5e56e040e
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.project b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.project
new file mode 100644
index 000000000..b08382269
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.mycorp.examples.timeservice.consumer.ds.async</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>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</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/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..0c68a61dc
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.pde.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..f29e940a0
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/META-INF/MANIFEST.MF b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..1f3a05e60
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Async
+Bundle-SymbolicName: com.mycorp.examples.timeservice.consumer.ds.async
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: MYCORP
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Import-Package: com.mycorp.examples.timeservice;version="2.0.0"
+Service-Component: OSGI-INF/timeservicecomponentasync.xml
+Bundle-ActivationPolicy: lazy
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/OSGI-INF/timeservicecomponentasync.xml b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/OSGI-INF/timeservicecomponentasync.xml
new file mode 100644
index 000000000..2e13191e2
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/OSGI-INF/timeservicecomponentasync.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" enabled="true" name="com.mycorp.examples.timeservice.consumer.ds.async">
+ <implementation class="com.mycorp.examples.timeservice.consumer.ds.async.TimeServiceComponentAsync"/>
+ <reference bind="bindTimeService" cardinality="1..n" interface="com.mycorp.examples.timeservice.ITimeServiceAsync" name="ITimeServiceAsync" policy="dynamic"/>
+</scr:component> \ No newline at end of file
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/build.properties b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/build.properties
new file mode 100644
index 000000000..67f08c89b
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/build.properties
@@ -0,0 +1,6 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/timeservicecomponentasync.xml,\
+ OSGI-INF/
+source.. = src/
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/src/com/mycorp/examples/timeservice/consumer/ds/async/TimeServiceComponentAsync.java b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/src/com/mycorp/examples/timeservice/consumer/ds/async/TimeServiceComponentAsync.java
new file mode 100644
index 000000000..8a038f9f4
--- /dev/null
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds.async/src/com/mycorp/examples/timeservice/consumer/ds/async/TimeServiceComponentAsync.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Composent, Inc. 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: Scott Lewis - initial API and implementation
+ ******************************************************************************/
+package com.mycorp.examples.timeservice.consumer.ds.async;
+
+import java.util.concurrent.CompletableFuture;
+
+import com.mycorp.examples.timeservice.ITimeServiceAsync;
+
+public class TimeServiceComponentAsync {
+
+ void bindTimeService(ITimeServiceAsync timeService) {
+ System.out.println("Discovered ITimeServiceAsync via DS");
+ // Get the CompletableFuture...no blocking here
+ CompletableFuture<Long> cf = timeService.getCurrentTimeAsync();
+ // print out time when done...no blocking anywhere!
+ cf.thenAccept((time) -> System.out.println("Remote time is: " + time));
+ }
+}

Back to the top