[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[ecf-dev] My first steap with ECF with Restlet
|
Hi Scott,
At first time for your information I have written several articles about remoting with CXF DOSGi at
http://angelozerr.wordpress.com/about/eclipse_spring/eclipse_spring_dosgi/
I know it's not ECF topic but if you can it should be cool if you can read to know what I need, on other words : just add some annotations in my interface services (in my case JAX-RS) and that's all!
----------------------------------------------------------------------------------------------
package fr.opensagres.services;
import java.util.Collection;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.jaxb.PageAdapter;
import org.springframework.data.domain.jaxb.PageableAdapter;
import fr.opensagres.domain.User;
@Path("/user")
public interface UserService {
@POST
@Path("/findAllPage")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@XmlJavaTypeAdapter(PageAdapter.class)
Page<User> findAll(
@XmlJavaTypeAdapter(PageableAdapter.class) Pageable pageable);
}
----------------------------------------------------------------------------------------------
My service has one parameter where Pageable is Spring Data structure which is an interface (and not a Pojo!). It returns Page structure which is too an interface.
I have done that with sucess with CXF DOSGi. As you suggested me to use ECF, I have started to study ECF with Restlet.
I have cloned the whole projects
https://github.com/ECF/RestletProvider and start to play with them.
1) TargetPlatform with ECF, Restlet and Servlet API.
Thoses projects have several dependencies and to resolve this problem I have created a Target Platform P2 with ECF, Restlet and RAP (to have Jetty server+Servlet API). I think it should be cool if in your git ECF Restlet you provide this Target Paltform.
2) Restlet RSA Server.launch
I think it should be cool in your Git description to speak about URL to access to the service with Web Browser.
I have launch Restlet RSA Server.launch and after debugging the code I have noticed that I can access to my service with the URL
http://localhost:8080/hello which displays:
-------------------------------------------------------------------------------------------
Hello RESTful OSGi World
-------------
Why this URL? I don't know why?
IHelloResource uses restlet annotation lie this:
-----------------------------------------------------
public interface IHelloResource {
@Get("txt")
public String sayHello();
@Get("html")
public String getDocument();
}-----------------------------------------
Where "hello" path is declared?
After studying that, I notice that it is declared in the hellow.xml :
-----------------------------------------
<property name="paths" type="String">
/hello
</property>
-----------------------------------------
I told that because I think it should be cool if you describe the URL in your Git description and explains why /hello is used?
3) Restlet Hello Consumer.launch
After that I launch the client side "Restlet Hello Consumer.launch" and there is none error and nothing is displayed on the console (my IHelloService is never found).
I don't understand how it can work? You have never declared a Rest Client like with the URL
http://localhost:8080/hello ?
4) What I don't like with Restlet.
On client side, I cannot tell anytthing because I don't understand how it works.
On server side, you have the implementation of the service like this:
-----------------------------------------
public class HelloResource extends ServerResource implements IHelloResource {
@Get("txt")
public String sayHello() {
return "Hello RESTful OSGi World";
}
...
-----------------------------------------
4.1) ServerResource dependency : Your service must extends Restlet ServerResource class, so your implementation has dependencies to restlet. If you wish change remoting mode (eg : ECF REST -> DOSGi CXF), you need to keep Restlet dependencies and I find it's shame.
4.2) HelloResourceProvider must be defined :
-----------------------------------------
public class HelloResourceProvider extends ResourceProvider {
@Override
protected Finder createFinder(Context context) {
return new Finder(context, HelloResource.class);
}
}
-----------------------------------------
I think it's complex task to manage remoting. With DOSGi CXF you need just uses JAX-RS annotations. With ECF Restlet you need uses Restlet annotations+extends ServerResource+create ResourceProvider.
None offense with my comment. I tell you just why (for the moment), I prefer CXF DOSGi than ECF Restlet.
Regards Angelo