Open RIAP protocol deployed on a Java application server

I have deployed our Restlet services to the Jetty Java Application Server using the ServerServlet engine . Some of the services are called from the GWT interface, but I will also need to call them directly from our server logic.

Restlet RIAP system seems ideal for you, but I'm not sure how to use it. It seems I need to hold onto the context of the Restlet component somehow.

I found one post which stated that the RiapServerHelper is useful for this . But I haven't found any documentation on how to use this. Any examples would be helpful.

+2


source to share


1 answer


The RiapServerHelper class is a server connector implementation. You don't need to explicitly use it.

To use RIAP, you need to implement all the entities of your application as usual (server resource, application ...). The difference occurs when applications are connected to the component's virtual hosts. Resources that need to be accessed via RIAP must also connect to the internal router as follows:

Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);

MyApplication app = new MyApplication();
component.getDefaultHost().attachDefault(app);
component.getInternalRouter().attachDefault(app);

      

Note that you do not need to specify the RIAP protocol for the component. It is supported by default.

Accessing application resources via RIAP is then easy, as you can use Restlet client support as with other protocols:



Request request = new Request(Method.GET, "riap://component/ping");
Response response = getContext().getClientDispatcher().handle(request);
Representation repr = response.getEntity();

      

or

ClientResource cr = new ClientResource("riap://component/ping");
Representation repr = cr.get();

      

You can see more details at http://wiki.restlet.org/docs_1.1/13-restlet/27-restlet/48-restlet/86-restlet/45-restlet.html .

Hope that answers your question. Thierry

+6


source







All Articles