- Java EE 8 Design Patterns and Best Practices
- Rhuan Rocha Jo?o Purifica??o
- 128字
- 2021-07-23 16:54:53
Implementing the commands
Here, we have AbstractCommand, which is an abstract class with one execute method. This is the abstract command, and the execute method is implemented on the subclasses:
public abstract class AbstractCommand {
public abstract String execute();
}
In the following code snippet, we have the subclass HomeCommand, which is the implementation of AbstractCommand. The method execute() returns the path to the home page (/home.jsp):
public class HomeCommand extends AbstractCommand {
@Override
public String execute() {
return "/home.jsp";
}
}
Here, we have the LoginCommand subclass, which is the implementation of AbstractCommand. The execute() method returns the path to the login page (/login.jsp):
public class LoginCommand extends AbstractCommand {
@Override
public String execute() {
return "/login.jsp";
}
}
推薦閱讀
- Implementing Cisco UCS Solutions
- Linux操作系統基礎
- 玩到極致 iPhone 4S完全攻略
- 數據中心系統工程及應用
- VMware NSX Cookbook
- Distributed Computing with Go
- Red Hat Enterprise Linux 6.4網絡操作系統詳解
- Agile IT Security Implementation Methodology
- 完美應用Ubuntu(第2版)
- Linux系統管理初學者指南:基于CentOS 7.6
- Responsive Web Design with AngularJS
- Python機器學習系統構建(原書第3版)
- SQL Server on Azure Virtual Machines
- Red Hat Enterprise Linux 6.0系統管理
- Windows 10使用方法與技巧從入門到精通