Class InventoryJaxRSClientImpl

  • All Implemented Interfaces:
    InventoryClient

    public class InventoryJaxRSClientImpl
    extends Object
    implements InventoryClient
    This class implements a JAX-RS Client interface to the inventory web application. All commands are through HTTP POST, GET, PUT, and DELETE methods to specific resource URIs for products and categories. However, this uses an API interface that hides some of the HTTP and marshaling details.
    • Field Detail

      • logger

        private static final org.slf4j.Logger logger
      • client

        private javax.ws.rs.client.Client client
      • baseUrl

        private URI baseUrl
        Defines the HTTP URL for the WAR that hosts the JAX-RS resources.
      • mediaType

        private javax.ws.rs.core.MediaType mediaType
        Defines the protocol between the client and server.
    • Constructor Detail

      • InventoryJaxRSClientImpl

        public InventoryJaxRSClientImpl()
    • Method Detail

      • setClient

        public void setClient​(javax.ws.rs.client.Client client)
      • setBaseUrl

        public void setBaseUrl​(URI baseUrl)
      • setMediaType

        public void setMediaType​(String mediaType)
      • isSuccessful

        private boolean isSuccessful​(javax.ws.rs.core.Response response)
      • getBaseUri

        private javax.ws.rs.core.UriBuilder getBaseUri​(String... resourcePath)
        Helper class to build the base URI for a client call.
        Parameters:
        resourcePath -
        Returns:
        uri builder ready to accept path parameter values
      • getCategory

        public Category getCategory​(int id)
                             throws javax.ws.rs.client.ResponseProcessingException
        Specified by:
        getCategory in interface InventoryClient
        Throws:
        javax.ws.rs.client.ResponseProcessingException