[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| [ecf-dev] OSGi remote services example code (now using declarative	services!) | 
Hi Folks,
Existing Examples Updated
I've updated the remote services hello world example to use the new OSGi 
remote services standard.  The service host is in bundle 
org.eclipse.ecf.examples.remoteservices.hello.host and the consumer is 
in org.eclipse.ecf.examples.remoteservices.hello.consumer.  (BTW, some 
of you might be wondering why I'm using the terminology 'host' and 
'consumer' rather than 'server' and 'client'.  The reason for this is
a) OSGi servers and clients can be either service hosts and/or 
consumers, so 'server' and 'client' would be ambiguous;
b) the OSGI 4.2 remote services spec uses host and consumer
Now, the example hello.host is simpler, because the ECF container is 
created automagically by the distribution system when the remote service 
is registered.
New Examples Using ECF Remote Services + DS
I also created two new example projects that use declarative services 
(DS) to build the hello world host and client.
In case of host, the example application uses DS (and xml) to register 
the remote service.  This is nice because it reduces/simplifies the host 
(very little java code...rather just a little xml).
In case of consumer, the proxy, once discovered is injected by DS into 
application code (rather than using e.g. a ServiceTracker).  This is 
really very cool, as it takes away all the ServiceTracker code necessary 
to get a remote service proxy.  At runtime, the service proxy is 
injected by DS directly into an application component.  This makes the 
code for the client *very* small/simple as well.
These two new projects are in CVS:
CVS path:  /cvsroot/rt
module (host):  
org.eclipse.ecf/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.ds.host
module (consumer):  
org.eclipse.ecf/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.ds.consumer
I've also added it to the project set files included in the releng 
project.  See here for info on getting projects using the project set 
files: http://www.eclipse.org/ecf/dev_resources.php
Remote Services and DS working together (as modules)
The new DS host and consumer projects highlights a very nice feature of 
OSGi remote services and DS...that either/both mechanisms for service 
registration (host) and service lookup/access (consumer) work 
interchangably...so those that wish to do things in java (e.g. to 
control all aspects) can do so, and those that wish to use declarative 
structures for service registration and lookup can do so.  Both 
declarative and programmatic structures can be used simultaneously if 
desired.
Asynchronous Access to Remote Services
A very nice feature of ECF (relative to other implementations of OSGi 
remote services)...that I will be blogging about eventually...is that 
ECF remote services supports asynchronous access to a remote service, in 
addition to 'normal' synchronous/blocking access via the proxy.  This is 
very nice, because it gives the *client* application programmer options 
for how to invoke what could be blocking remote service method calls. 
ECF's IRemoteService interface allows asynchronous calling 
patterns...both callbacks/listeners and futures.  So clients can call an 
arbitarary remote method synchronously (i.e. via proxy), or 
asynchronously depending upon the desired/expected behavior.  This is 
all done via the ECF remote services API, so it's provider and transport 
independent, and it's also done completely within the OSGi remote 
services specification.
Scott