Java Reference
In-Depth Information
}
return customer;
}
private Customer findById(String customerId) throws IOException {
properties properties = new Properties();
properties.load(new FileInputStream(DATA_STORE));
String rawData = properties.getProperty(customerId);
if (rawData != null) {
final String[] field = rawData.split(",");
Address address = new Address();
Customer customer = new Customer();
customer.setId(Integer.parseInt(customerId));
customer.setAddress(address);
customer.setFirstname(field[0]);
customer.setLastname(field[1]);
address.setNumber(Integer.parseInt(field[2]));
address.setStreet(field[3]);
address.setCity(field[4]);
address.setState(field[5]);
address.setZip(field[6]);
address.setCountry(field[7]);
customer.setEmail(field[8]);
customer.setPhone(field[9]);
return customer;
}
return null;
}
The CustomerClientXML and CustomerClientJSON Classes
Jersey is the reference implementation of JAX-RS (JSR 311). You can use the Jersey client
API to write a test client for the customer example application. You can find the Jersey
APIs at http://jersey.java.net/nonav/apidocs/latest/jersey/ .
The CustomerClientXML class calls Jersey APIs to test the CustomerService
web service:
Click here to view code image
package customer.rest.client;
import com.sun.jersey.api.client.Client;
Search WWH ::




Custom Search