commit | e818b9dcca08dfff50836dfff532ffaa14fe6da4 | [log] [tgz] |
---|---|---|
author | slewis <slewis@composent.com> | Tue May 05 13:47:01 2015 -0700 |
committer | slewis <slewis@composent.com> | Tue May 05 13:47:01 2015 -0700 |
tree | 99f203b67efb479912e55e3dbcfc0938fb407c68 | |
parent | 92d4bb508f54533a90aa90ee3d1bdde028b9794d [diff] |
Enhanced timeservice remote service examples to report undiscovery (e.g. triggered by host shutdown) Change-Id: Ie1becf5f12f5237e5b569c5ccdac5f29d95b21e5
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 007eb84..86a235f 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 1cfcbe9..cbcb004 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 @@ 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 c537991..130e649 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 void removedService(ServiceReference<ITimeService> reference, ITimeService service) { - // do nothing + System.out.println("ITimeService undiscovered!"); } }