Skip to content

Instantly share code, notes, and snippets.

@john-nash-rs
Last active July 12, 2018 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-nash-rs/658cb4755a232a3b9bc860b3bafb0e0f to your computer and use it in GitHub Desktop.
Save john-nash-rs/658cb4755a232a3b9bc860b3bafb0e0f to your computer and use it in GitHub Desktop.
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