[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] JaxRS provider

Hi Folks,

I've completed a first cut at an ECF Remote Services client provider based upon JaxRS.

Specifically I ended up implementing using the jersey implementation in Orbit, as libs and all dependencies have already been 'bundleized' and exist in orbit, and it's a popular JaxRS implementation. The repo with both bundles along with an initial example is here [1].

It's broken up into two bundles: 1) org.eclipse.ecf.provider.jaxrs.client; and 2) org.eclipse.ecf.provider.jersey.client. 1 only has dependencies on the javax.ws.rs.* packages, which means it can be reused with *any* spec compliant implementation of JaxRS. Most of the actual remote service distribution provider code is here, although it's actually pretty small. 2 is the jersey-specific implementation and essentially just has code to configure Jersey (e.g. for supporting json, etc).

IMHO the cool thing about this provider is that it will/does work with remote services exposed by non-jersey, non-osgi, even non-java servers. It supports arbitrary arguments and return type serialization via both xml and/or json.

Here's a simple example:

1) I setup an example running on tomcat (no OSGi) and exposing a xml and rest-based service on tomcat.
2) I created a new service API bundle with
a) An interface: ISampleService [2] with the same jax-rs (standardized) annotations as were present on the server resource class. It doesn't have to be the same class as used on the server (or even from the same package), it just needs to be an interface that has the same class and method annotations.
b) A model class (or any model classes) used in 'a'. Here's the example [3].
The only dependencies in this service API bundle are to the javax.ws.rs.* annotation types and to 'b'.
3) I created a simple consumer of the ISampleService [4] using a service tracker calls a couple of the ISampleService remote service methods. In this bundle I also created a EDEF file (to discover the ISampleService remote service) called helloserviceendpointdescription.xml [5]. My intention is to create some utilities to automate the creation of EDEF so that it's unnecessary to hand-craft it.

Using the new ECF Endpoint Discovery view [6]

1) read the EDEF from 3, which discovers the ISampleService, creates the remote service proxy (from the ISampleService class) and like any OSGi service the proxy registration calls the test consumer's addingService method.
2) The addingService impl makes a couple of calls, which get turned into http/https calls with java params serialized and injected into the url, and the return value deserialized and returned as an instance of an appropriate java object. All this happens/is implemented by the jersey jax-rs impl, so that the call looks to the server just like any other http/REST client.

This is pretty cool, as it means that it's very very simple to take any remote service that can be described by jax-rs annotations and turn it into an OSGi remote service, with all the dynamics, API versioning support, use of any OSGi service injection technology (spring, ds, dm, etc., etc). And it will work the same way on any OSGi framework.

My intention is to create a wiki-based tutorial describing the above once I get the chance, as well as create some more examples, and EDEF utility code. Please let me know if you would like to participate/contribute in this.


[1] https://github.com/ECF/JaxRSProviders
[2] https://github.com/ECF/JaxRSProviders/blob/master/test/bundles/com.mycorp.examples.resteasy.hello/src/com/javacodegeeks/resteasy/ISampleService.java
[3] https://github.com/ECF/JaxRSProviders/blob/master/test/bundles/com.mycorp.examples.resteasy.hello/src/com/javacodegeeks/resteasy/model/Employee.java
[4] https://github.com/ECF/JaxRSProviders/tree/master/test/bundles/com.mycorp.examples.resteasy.hello.test
[5] https://github.com/ECF/JaxRSProviders/blob/master/test/bundles/com.mycorp.examples.resteasy.hello.test/helloserviceendpointdescription.xml
[6] https://www.eclipse.org/ecf/NewAndNoteworthy_3.10.0.html

On 8/16/2015 11:21 AM, Scott Lewis wrote:
Hi Folks,

I wanted to let everyone know that I've implemented and started testing two new ECF Remote Services distribution providers:

[1] One based upon Hazelcast [3]
[2] One based upon Jax REST Services [4]. Since JaxRS is a specification with multiple impls (e.g. resteasy, jersey, restlet, etc) I have structured things so that a number of providers can/could be created, and I've started testing one I've created based upon resteasy [5]

The initial impls are done for both 1 and 2, and I'm working on test and example code. If anyone would like to contribute/participate in these impls, help with making them more useful, and/or create other providers (e.g. based upon jersey, restlet, etc), please say so.

BTW, also update the no-OSGi ServiceRegistry examples [6] to use ECF 3.10.1.


[1] https://github.com/ECF/HazelcastProvider
[2] https://github.com/ECF/JaxRSProviders
[3] http://hazelcast.org/
[4] https://jax-rs-spec.java.net/
[5] http://resteasy.jboss.org/
[6] https://github.com/ECF/ServiceRegistry
ecf-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit