JAX-RS To Metamug Resource

In this example we will see how a resource is written in JAX-RS and compare with the equivalent in Metamug.

Java API for RESTful Web Services (JAX-RS)

The current standard for writing REST APIs in java is JAX-RS. Though the popular spring framework follows its own annotations.

You can find multiple implementation for the standard.

and many others.

The folllowing example demonstrates how a typical GET request

import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

public class UserService {

    public Response getUsers(
        @QueryParam("name") String name,
        @QueryParam("quant") int quantity,
        @QueryParam("desc") String description) {

        return Response
           .entity("{ itemName :" + name + ", itemQuantity : " + quantity
            + ", itemDescription :" + description + " }").build();



Metamug Resource

The same resource can be written in metamug as follows.

<?xml version="1.0" encoding="UTF-8" ?>
<Resource xmlns="http://xml.metamug.net/resource/1.0" v="1.0">
    <Request method="GET">
            select $name "itemName", $quant "itemQuantity", $desc "itemDescription"

Check the resource file docs for usage


But JAX-RS REST resources are not so simple.

Every resource in JAX-RS is backed by

Here is an example for this in spring boot