Publishing a new REST service

  1. Extend the Servlet.
  2. Overwrite the init() method.


public class MyRestServlet extends RestServlet {

	public void init() throws ServletException {
		// addService(key, value);
		// key: Mapping string for the server to find a service object and method.
		// value: implementation from the service
		addService(Echo.class.getName(), new EchoImpl ());
		// The string is to lower case!
		// key = 'service.' + class-name without package
		addService("service.echo", new EchoImpl ());