Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-05-05 16:47:01 -0400
committerslewis2015-05-05 16:47:01 -0400
commite818b9dcca08dfff50836dfff532ffaa14fe6da4 (patch)
tree99f203b67efb479912e55e3dbcfc0938fb407c68
parent92d4bb508f54533a90aa90ee3d1bdde028b9794d (diff)
downloadorg.eclipse.ecf-e818b9dcca08dfff50836dfff532ffaa14fe6da4.tar.gz
org.eclipse.ecf-e818b9dcca08dfff50836dfff532ffaa14fe6da4.tar.xz
org.eclipse.ecf-e818b9dcca08dfff50836dfff532ffaa14fe6da4.zip
Enhanced timeservice remote service examples to report undiscovery (e.g.
triggered by host shutdown) Change-Id: Ie1becf5f12f5237e5b569c5ccdac5f29d95b21e5
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds/OSGI-INF/timeservicecomponent.xml2
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer.ds/src/com/mycorp/examples/timeservice/consumer/ds/TimeServiceComponent.java9
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java2
3 files changed, 9 insertions, 4 deletions
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/OSGI-INF/timeservicecomponent.xml b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/OSGI-INF/timeservicecomponent.xml
index 007eb84a6..86a235fe1 100644
--- a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/OSGI-INF/timeservicecomponent.xml
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/OSGI-INF/timeservicecomponent.xml
@@ -1,5 +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">
<implementation class="com.mycorp.examples.timeservice.consumer.ds.TimeServiceComponent"/>
- <reference bind="bindTimeService" cardinality="1..1" interface="com.mycorp.examples.timeservice.ITimeService" name="ITimeService" policy="dynamic"/>
+ <reference bind="bindTimeService" cardinality="1..1" interface="com.mycorp.examples.timeservice.ITimeService" name="ITimeService" policy="dynamic" unbind="unbindTimeService"/>
</scr:component>
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/src/com/mycorp/examples/timeservice/consumer/ds/TimeServiceComponent.java b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/src/com/mycorp/examples/timeservice/consumer/ds/TimeServiceComponent.java
index 1cfcbe927..cbcb004a6 100644
--- a/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/src/com/mycorp/examples/timeservice/consumer/ds/TimeServiceComponent.java
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.ds/src/com/mycorp/examples/timeservice/consumer/ds/TimeServiceComponent.java
@@ -12,10 +12,15 @@ import com.mycorp.examples.timeservice.ITimeService;
public class TimeServiceComponent {
+ // Called by DS upon ITimeService discovery
void bindTimeService(ITimeService timeService) {
- // Invoke synchronously
- System.out.println("Discovered ITimeService via DS");
+ System.out.println("Discovered ITimeService via DS. Instance="+timeService);
// Call the service and print out result!
System.out.println("Current time is: " + timeService.getCurrentTime());
}
+
+ // Called by DS upon ITimeService undiscovery
+ void unbindTimeService(ITimeService timeService) {
+ System.out.println("Undiscovered ITimeService via DS. Instance="+timeService);
+ }
}
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java b/examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java
index c5379915b..130e649a7 100644
--- a/examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java
+++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java
@@ -68,7 +68,7 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer<ITim
public void removedService(ServiceReference<ITimeService> reference,
ITimeService service) {
- // do nothing
+ System.out.println("ITimeService undiscovered!");
}
}

Back to the top