public class OrderException extends Exception {
public OrderException(String message) {
super(message);
}
}
public class InventoryException extends Exception {
public InventoryException(String message) {
super(message);
}
}
public OrderDTO queryOrder(String orderId) throws OrderException {
OrderDTO order = orderDao.queryOrder(orderId);
if (order == null) {
}
return order;
}
try {
OrderDTO order = orderService.queryOrder(orderId);
} catch (OrderException e) {
}
public boolean validateUserInput(String username, String password) {
}
// ...
return true;
}
@RolesAllowed({"admin"})
public void deleteUser(String userId) {
}
security.algorithm=SHA-256
security.key=1234567890abcdef
public class OrderException extends Exception {
public OrderException(String message) {
super(message);
}
}
public class InventoryException extends Exception {
public InventoryException(String message) {
super(message);
}
}
public class OrderService {
public OrderDTO queryOrder(String orderId) throws OrderException {
OrderDTO order = orderDao.queryOrder(orderId);
if (order == null) {
}
return order;
}
}
try {
OrderDTO order = orderService.queryOrder(orderId);
} catch (OrderException e) {
}
public boolean validateUserInput(String username, String password) {
}
// ...
return true;
}
@RolesAllowed({"admin"})
public void deleteUser(String userId) {
}
security.algorithm=SHA-256
security.key=1234567890abcdef
security.algorithm=SHA-256
security.key=1234567890abcdef
1. Martin, Robert C. Clean Code: A Handbook of Agile Software Craftsmanship. Prentice Hall, 2008.
2. Bloch, Joshua. Effective Java. Addison-Wesley Professional, 2017.