Java Reference
In-Depth Information
The entity, Customer , is a simple POJO with accessors and mutators, and working equals, hashCode ,
toString methods.
// …
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
public class Customer implements Serializable {
private String id;
private String firstName, lastName;
private Date birthday;
// …
// accessor/mutators, id, equals, and hashCode.
// …
}
Note first that nothing we do in that class has any effect on Terracotta. We implement Serializable,
ostensibly, because the class may very well be serialized in, for example, an HTTP session. The
hashCode/equals implementations are just good practice.
The client that will allow us to interact with this service class is as follows:
package com.apress.springenterpriserecipes.distributedspring.terracotta.
customerconsole.view;
import com.apress.springenterpriserecipes.distributedspring.
terracotta.customerconsole.entity.Customer;
import com.apress.springenterpriserecipes.distributedspring.
terracotta.customerconsole.service.CustomerService;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import javax.swing.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
public class CustomerConsole {
private void log(String msg) {
System.out.println(msg);
}
private void list() {
for (Customer customer : customerService.getAllCustomers())
log(customer.toString());
log(SystemUtils.LINE_SEPARATOR);
}
Search WWH ::




Custom Search