8
I want to use GWT's RequestFactory for all client-server communication, if possible. My understanding is that you have to map /gwtServlet to RequestFactoryServlet in your web.xml, and then use @Service annotations to tell the RequestFactoryServlet how to map client-side requests to their appropriate services.
Can someone provide a complete code example of this process, both on the client- and on the server-side? I'd like to send a Widget object from the client side to a WidgetProcessor service on the server-side:
public class Widget {
// This is a domain object (POJO).
}
public class WidgetProcessor {
public void processWidget(Widget w) {
// Inspect the Widget. If certain properties contain certain
// values, place it on a queue. Else "process" the Widget
// and persist it to a DB.
if(w.containsSpecialValues())
QueueManager.sendToQueue(w);
else {
// Process widget...
WidgetDAO.save(w);
}
}
}
In a non-GWT context, I would just define a WidgetProcessorServlet, map it to /processWidget, and make it look like:
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
WidgetProcessor widgetProcessor = new WidgetProcessor();
widgetProcessor.processWidget(getWidgetFromRequest(request));
}
How does this work in RequestFactory-land? Thanks in advance.