Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import com.codahale.metrics.annotation.Timed;
import io.dropwizard.hibernate.UnitOfWork;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import java.util.List;
/**
* Created by harshvardhan on 12/07/18.
*/
@Path("/resource")
@Produces(MediaType.APPLICATION_JSON)
public class MyResource {
private InfoDao infoDao;
public MyResource(InfoDao infoDao) {
this.infoDao = infoDao;
}
@GET
@Timed
@Path("/getName")
public String getName() {
return "Harsh";
}
@POST
@Timed
@Path("/postName")
public String postName(String name) {
System.out.println("Name given by : "+name);
return "Ok";
}
@GET
@Timed
@UnitOfWork
@Path("/findAllEmp")
public List<Info> findAllEmp() {
System.out.println("All Emp : "+infoDao.findAll());
return infoDao.findAll();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment