throw new IllegalStateException("mailSender is required");
}
}
public void afterReturning(Object returnValue, Method m, Object[] args, Object target) throws Throwable {
Order order = (Order) args[0];
Account account = ((PetStoreFacade) target).getAccount(order.getUsername());
// don't do anything if email address is not set
if (account.getEmail() == null || account.getEmail().length() == 0) {
return;
}
StringBuffer text = new StringBuffer();
text.append("Dear ").append(account.getFirstName()).append(' ').append(account.getLastName());
text.append(", thank your for your order from JPetStore. Please note that your order number is ");
text.append(order.getOrderId());
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setTo(account.getEmail());
mailMessage.setFrom(this.mailFrom);
mailMessage.setSubject(this.subject);