Class ProductsResource
- java.lang.Object
-
- ejava.examples.ejbwar.inventory.rs.ProductsResource
-
@Path("/products") public class ProductsResource extends Object
This class implements the JAX-RS interface for the injected inventory management EJB logic.
-
-
Field Summary
Fields Modifier and Type Field Description private InventoryMgmtEJB
ejb
private static org.slf4j.Logger
logger
private javax.ws.rs.core.Request
request
private javax.ws.rs.core.UriInfo
uriInfo
-
Constructor Summary
Constructors Constructor Description ProductsResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.Response
createProduct(String name, Integer quantity, Double price, String category)
Creates a productjavax.ws.rs.core.Response
deleteProduct(int id)
Deletes the product identified.javax.ws.rs.core.Response
findProductsByName(String name, int offset, int limit)
Returns a simple list of products that match provided namejavax.ws.rs.core.Response
getProduct(int id)
Returns a specific productjavax.ws.rs.core.Response
updateProduct(int id, Product product)
Updates a product with the values of the object passed in
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
ejb
@Inject private InventoryMgmtEJB ejb
-
request
@Context private javax.ws.rs.core.Request request
-
uriInfo
@Context private javax.ws.rs.core.UriInfo uriInfo
-
-
Method Detail
-
createProduct
@POST @Path("") @Consumes("application/x-www-form-urlencoded") @Produces({"application/xml","application/json"}) @JsonbAnnotation public javax.ws.rs.core.Response createProduct(@FormParam("name") String name, @FormParam("quantity") Integer quantity, @FormParam("price") Double price, @FormParam("category") String category)
Creates a product- Parameters:
product
-category
-- Returns:
-
getProduct
@GET @Path("{id}") @Produces({"application/xml","application/json"}) @JsonbAnnotation public javax.ws.rs.core.Response getProduct(@PathParam("id") int id)
Returns a specific product- Parameters:
id
-- Returns:
-
updateProduct
@PUT @Path("{id}") @Consumes({"application/xml","application/json"}) @Produces({"application/xml","application/json"}) @JsonbAnnotation public javax.ws.rs.core.Response updateProduct(@PathParam("id") int id, Product product)
Updates a product with the values of the object passed in- Parameters:
id
-product
-- Returns:
- updated product if successful
-
deleteProduct
@DELETE @Path("{id}") public javax.ws.rs.core.Response deleteProduct(@PathParam("id") int id)
Deletes the product identified.- Parameters:
id
-- Returns:
-
findProductsByName
@GET @Path("") @Produces({"application/xml","application/json"}) @JsonbAnnotation public javax.ws.rs.core.Response findProductsByName(@QueryParam("name") String name, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("0") int limit)
Returns a simple list of products that match provided name- Parameters:
name
-- Returns:
-
-