WS Practical No.7
WS Practical No.7
Practical No.7
Index.html :
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
</body>
</html>
college7facadeREST.java :
package service;
import com.abc.College7;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
/**
*
* @author Administrator
*/
@Stateless
Name: Onkar Jagadale
Roll No: 8242/ TYCS-A
@Path("com.abc.college7")
public class College7FacadeREST extends AbstractFacade<College7> {
@PersistenceContext(unitName = "Rest_CRUDPU")
private EntityManager em;
public College7FacadeREST() {
super(College7.class);
}
@POST
@Override
@Consumes({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public void create(College7 entity) {
super.create(entity);
}
@PUT
@Path("{id}")
@Consumes({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public void edit(@PathParam("id") Integer id, College7 entity) {
super.edit(entity);
}
@DELETE
@Path("{id}")
public void remove(@PathParam("id") Integer id) {
super.remove(super.find(id));
}
@GET
@Path("{id}")
@Produces({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public College7 find(@PathParam("id") Integer id) {
return super.find(id);
}
Name: Onkar Jagadale
Roll No: 8242/ TYCS-A
@GET
@Override
@Produces({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public List<College7> findAll() {
return super.findAll();
}
@GET
@Path("{from}/{to}")
@Produces({MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON})
public List<College7> findRange(@PathParam("from") Integer from,
@PathParam("to") Integer to) {
return super.findRange(new int[]{from, to});
}
@GET
@Path("count")
@Produces(MediaType.TEXT_PLAIN)
public String countREST() {
return String.valueOf(super.count());
}
@Override
protected EntityManager getEntityManager() {
return em;
}
}
Name: Onkar Jagadale
Roll No: 8242/ TYCS-A
OUTPUT :