Java Reference
In-Depth Information
Adding REST to our Ticket example
With all the configurations in place, we can now add a simple REST web service to
our Ticket Web Service project that will provide the same functionalities of our
SOAP web service.
So add a new class to your project and name it TicketRESTService . The code for
this is as follows:
package
com.packtpub.as7development.chapter8.webservice;
import java.util.*;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import
com.packtpub.as7development.chapter8.ejb.TheatreBox;
import
com.packtpub.as7development.chapter8.model.Seat;
@Path("/seat")
@RequestScoped
public class TicketRESTService {
@Inject TheatreBox service;
@Inject TheatreInfoBean infoBean;
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Seat> getSeatList() {
return infoBean.getSeatList();
}
Search WWH ::




Custom Search