[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Remoting with ECF (with REST) in Eclipse RCP?

Hi Scott,

Sorry for my late.

Le 6 avril 2012 16:59, Scott Lewis <slewis@xxxxxxxxxxxxx> a écrit :
Hello Angelo,


On 4/6/2012 12:21 AM, Angelo zerr wrote:
Hi Scott,

At first thanks to have posting message in my blog http://angelozerr.wordpress.com/2012/04/05/eclipse_spring_step0/
As you have read, I would like support Remoting on our Eclipse RCP/RAP with Spring DM and I have studied CXF DOSGi with REST and it works well.
An important thing is that our Eclipse RCP must support Fat Client/Client Serveur (Remoting).

[Scott]  I'm not sure what you mean by this.  Of course ECF allows 'peer-to-peer' remoting (i.e. remote service hosts can also be remote service hosts...if that's what you meant.

It was just to introduce my post, that I have told that. I know that ECF is remoting:)


So I want just

* add remoting exporter bundle on server side (ex:with CXF DOSGi, I retrieve the services implementation and I expose the service with REST just with Spring configuration (none code)).

[Scott]  This should be completely possible...as long as Spring follows the OSGi standards here for registering OSGi services (and I cannot imagine that they don't).

When I see ECF samples, there is a lot of Java code to do in the Activator. In my case I would like just using Spring file to declare the client and server side.
The ECF Spring support problem is client side (not server side). On client side if you configure an URL of the server and you start the client BEFORE the server, the Spring bean cannot be created.
That's is the first problem (I will try to fix that if we decide to use ECF in our project).

The second problem is that ECF seems not support JAX-RS (just REST). As I said you, I don't want code something. I give you how I do that with CXF and I hope you will understand my need.

1) UserService with JAX-RS :

------------------------------------------------------------------
package fr.opensagres.services;

import java.util.Collection;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/user")
public interface UserService {

    @GET
    @Path("/findAll")
    @Produces(MediaType.APPLICATION_JSON)
    Collection<User> findAll();

}
------------------------------------------------------------------

2) REST exporter bundle (server side)

On server side I have a bundle which declares Spring file to export the UserService with REST like this:

------------------------------------------------------------------
<osgi:reference id="userService" interface="fr.opensagres.services.UserService" />
   
<osgi:service interface="fr.opesagres.services.UserService">
        <osgi:service-properties>
            <entry key="service.exported.interfaces" value="*" />
            <entry key="service.exported.configs" value="org.apache.cxf.rs" />
            <entry key="service.exported.intents" value="HTTP" />
            <entry key="org.apache.cxf.rs.address" value="http://localhost:9090/xxxx" />
            <entry key="org.apache.cxf.rs.databinding" value="jaxb" />
        </osgi:service-properties>
        <ref bean="userService" />
</osgi:service>
------------------------------------------------------------------

I can access my service with http://localhost:9090/xxxx/user/findAll and it returns list of User as JSON format.

3) REST importer bundle (client side)

On client side, I could use RSA but I don't want do that because URL of the server are hard-coded on the XML file.
So I use Spring support for CXF which provides REST client :

------------------------------------------------------------------
<jaxrs:client id="restClient" address="http://localhost:9090/xxxx"
        serviceClass="fr.opensagres.services.UserService" inheritHeaders="true">
    </jaxrs:client>.
<osgi:service ref="restClient" interface=""fr.opensagres.services.UserService" />
------------------------------------------------------------------

And that's all! No need to code something with Java code. Using JAX-RS annotations gives us the capability not to code some REST server/client component.



* add remoting importer bundle on client side. (ex: with CXF DOSGi, I retrieve the services with REST client and I register the service in the OSGi registry just with Spring configuration (none code)).

[Scott]  Same here.



I have seen that ECF supports REST and you suggested me to use it. I'm OK, but do you think it's possible with ECF to manage my case?

[Scott]  ECF does have a rest API...and we also now have a Restlet-based provider (it's not jax-based annotation, but it is annotation-based).

https://github.com/ECF/RestletProvider



With REST, I want add JAX-RS annotation in my interface services and do nothing with code (don't want code REST client/server service).

[Scott]  If you want to add a JAX-RS-based provider, you could certainly do so.   We have not created one yet, but as the restlet provider shows, with ECF's provider architecture and with remote service admin (RSA), it's a straightforward dev activity.

Thanks,

Scott, I would like finish my articles with remoting with CXF DOSGi which works well. If you think I can do teh same thing with ECF with just some XML declaration, I will be happy to use ECF and improves perhaps the ECF Spring support.

Regards Angelo
 

Scott



_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev