Class CustomerJaxRSClientImpl
- java.lang.Object
-
- ejava.examples.ejbwar.customer.client.CustomerJaxRSClientImpl
-
- All Implemented Interfaces:
CustomerClient
public class CustomerJaxRSClientImpl extends Object implements CustomerClient
This class implements a JAX-RS Client interface to the customer web application. All commands are through HTTP POST, GET, PUT, and DELETE methods to specific resource URIs for customers.
-
-
Field Summary
Fields Modifier and Type Field Description private URI
baseUrl
Defines the HTTP URL for the WAR that hosts the JAX-RS resources.private javax.ws.rs.client.Client
client
static String
CUSTOMER_PATH
static String
CUSTOMERS_PATH
private static org.slf4j.Logger
logger
private javax.ws.rs.core.MediaType
mediaType
Defines the protocol between the client and server.
-
Constructor Summary
Constructors Constructor Description CustomerJaxRSClientImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Customer
addCustomer(Customer customer)
boolean
deleteCustomer(int id)
Customers
findCustomersByName(String firstName, String lastName, int offset, int limit)
private javax.ws.rs.core.UriBuilder
getBaseUri(String... resourcePath)
Helper class to build the base URI for a client call.Customer
getCustomer(int id)
void
setBaseUrl(URI baseUrl)
void
setClient(javax.ws.rs.client.Client client)
void
setMediaType(String mediaType)
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
CUSTOMERS_PATH
public static final String CUSTOMERS_PATH
- See Also:
- Constant Field Values
-
CUSTOMER_PATH
public static final String CUSTOMER_PATH
- See Also:
- Constant Field Values
-
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.
-
-
Method Detail
-
setClient
public void setClient(javax.ws.rs.client.Client client)
-
setBaseUrl
public void setBaseUrl(URI baseUrl)
-
setMediaType
public void setMediaType(String mediaType)
-
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
-
addCustomer
public Customer addCustomer(Customer customer)
- Specified by:
addCustomer
in interfaceCustomerClient
-
findCustomersByName
public Customers findCustomersByName(String firstName, String lastName, int offset, int limit)
- Specified by:
findCustomersByName
in interfaceCustomerClient
-
getCustomer
public Customer getCustomer(int id)
- Specified by:
getCustomer
in interfaceCustomerClient
-
deleteCustomer
public boolean deleteCustomer(int id)
- Specified by:
deleteCustomer
in interfaceCustomerClient
-
-