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 URIbaseUrlDefines the HTTP URL for the WAR that hosts the JAX-RS resources.private javax.ws.rs.client.Clientclientstatic StringCUSTOMER_PATHstatic StringCUSTOMERS_PATHprivate static org.slf4j.Loggerloggerprivate javax.ws.rs.core.MediaTypemediaTypeDefines 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 CustomeraddCustomer(Customer customer)booleandeleteCustomer(int id)CustomersfindCustomersByName(String firstName, String lastName, int offset, int limit)private javax.ws.rs.core.UriBuildergetBaseUri(String... resourcePath)Helper class to build the base URI for a client call.CustomergetCustomer(int id)voidsetBaseUrl(URI baseUrl)voidsetClient(javax.ws.rs.client.Client client)voidsetMediaType(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:
addCustomerin interfaceCustomerClient
-
findCustomersByName
public Customers findCustomersByName(String firstName, String lastName, int offset, int limit)
- Specified by:
findCustomersByNamein interfaceCustomerClient
-
getCustomer
public Customer getCustomer(int id)
- Specified by:
getCustomerin interfaceCustomerClient
-
deleteCustomer
public boolean deleteCustomer(int id)
- Specified by:
deleteCustomerin interfaceCustomerClient
-
-