The Get Service demo is a simple bundle, which calls the Time Service registered by the Register Service and by the Register Service Factory demos.
The JAR of the Get Service demo is getservice.jar in the demo/bundles directory.
The source files of the demo are located in the demo/framework/basics/getservice directory of the Framework Professional Edition Package . If you have changed the source of the demo, to recompile and repack it use the mkgs script.
The Get Service demo is included in the demo/framework/basics/install.txt install script. For more information about installing demos via install scripts, refer to General Rules for Demos.
The Get Service demo contains a single class - demo.basics.getservice.GetService.
It is a bundle activator which refers to the Time Service of the Register Service
or Register Service Factory demo.
When the Get Service demo bundle is started, it gets the TimeService
service and calls its method. It sends the results to the OSGi Log service and
to the framework console via the log utility of the ProSyst
Util Bundle.
. . .
log = new Log(bc);
log.setDebug(true);
log.setPrintOnConsole(true);
timeRef = bc.getServiceReference(TimeService.class.getName());
if (timeRef != null) {
timeService = (TimeService) bc.getService(timeRef);
}
if (timeService == null) {
log.info("[GetServiceDemo] TimeService NOT found!");
return;
}
log.info("[GetServiceDemo] TimeService found: " |