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.