在阎宏博士的《JAVA与模式》一书中开头是这样描述命令(Command)模式的:

  命令模式属于对象的行为模式。命令模式又称为行动(Action)模式或交易(Transaction)模式。

  命令模式把一个请求或者操作封装到一个对象中。命令模式允许系统使用不同的请求把客户端参数化,对请求排队或者记录请求日志,可以提供命令的撤销和恢复功能。

命令模式的结构

  命令模式是对命令的封装。命令模式把发出命令的责任和执行命令的责任分割开,委派给不同的对象。

  每一个命令都是一个操作:请求的一方发出请求要求执行一个操作;接收的一方收到请求,并执行操作。命令模式允许请求的一方和接收的一方独立开来,使得请求的一方不必知道接收请求的一方的接口,更不必知道请求是怎么被接收,以及操作是否被执行、何时被执行,以及是怎么被执行的。

  命令允许请求的一方和接收请求的一方能够独立演化,从而具有以下的优点:

  (1)命令模式使新的命令很容易地被加入到系统里。

  (2)允许接收请求的一方决定是否要否决请求。

  (3)能较容易地设计一个命令队列。

  (4)可以容易地实现对请求的撤销和恢复。

  (5)在需要的情况下,可以较容易地将命令记入日志。

  下面以一个示意性的系统,说明命令模式的结构。

  命令模式涉及到五个角色,它们分别是:

  ●  客户端(Client)角色:创建一个具体命令(ConcreteCommand)对象并确定其接收者。

  ●  命令(Command)角色:声明了一个给所有具体命令类的抽象接口。

  ●  具体命令(ConcreteCommand)角色:定义一个接收者和行为之间的弱耦合;实现execute()方法,负责调用接收者的相应操作。execute()方法通常叫做执行方法。

  ●  请求者(Invoker)角色:负责调用命令对象执行请求,相关的方法叫做行动方法。

  ●  接收者(Receiver)角色:负责具体实施和执行一个请求。任何一个类都可以成为接收者,实施和执行请求的方法叫做行动方法。

源代码

  接收者角色类

public class Receiver {
/**
* 真正执行命令相应的操作
*/
public void action(){
System.out.println("执行操作");
}
}

  抽象命令角色类

public interface Command {
/**
* 执行方法
*/
void execute();
}

  具体命令角色类

public class ConcreteCommand implements Command {
//持有相应的接收者对象
private Receiver receiver = null;
/**
* 构造方法
*/
public ConcreteCommand(Receiver receiver){
this.receiver = receiver;
}
@Override
public void execute() {
//通常会转调接收者对象的相应方法,让接收者来真正执行功能
receiver.action();
} }

  请求者角色类

public class Invoker {
/**
* 持有命令对象
*/
private Command command = null;
/**
* 构造方法
*/
public Invoker(Command command){
this.command = command;
}
/**
* 行动方法
*/
public void action(){ command.execute();
}
}

  客户端角色类

public class Client {

    public static void main(String[] args) {
//创建接收者
Receiver receiver = new Receiver();
//创建命令对象,设定它的接收者
Command command = new ConcreteCommand(receiver);
//创建请求者,把命令对象设置进去
Invoker invoker = new Invoker(command);
//执行方法
invoker.action();
} }

AudioPlayer系统

  小女孩茱丽(Julia)有一个盒式录音机,此录音机有播音(Play)、倒带(Rewind)和停止(Stop)功能,录音机的键盘便是请求者(Invoker)角色;茱丽(Julia)是客户端角色,而录音机便是接收者角色。Command类扮演抽象命令角色,而PlayCommand、StopCommand和RewindCommand便是具体命令类。茱丽(Julia)不需要知道播音(play)、倒带(rewind)和停止(stop)功能是怎么具体执行的,这些命令执行的细节全都由键盘(Keypad)具体实施。茱丽(Julia)只需要在键盘上按下相应的键便可以了。

  录音机是典型的命令模式。录音机按键把客户端与录音机的操作细节分割开来。

  

  源代码

  接收者角色,由录音机类扮演

public class AudioPlayer {

    public void play(){
System.out.println("播放...");
} public void rewind(){
System.out.println("倒带...");
} public void stop(){
System.out.println("停止...");
}
}

  抽象命令角色类

public interface Command {
/**
* 执行方法
*/
public void execute();
}

  具体命令角色类

public class PlayCommand implements Command {

    private AudioPlayer myAudio;

    public PlayCommand(AudioPlayer audioPlayer){
myAudio = audioPlayer;
}
/**
* 执行方法
*/
@Override
public void execute() {
myAudio.play();
} }
public class RewindCommand implements Command {

    private AudioPlayer myAudio;

    public RewindCommand(AudioPlayer audioPlayer){
myAudio = audioPlayer;
}
@Override
public void execute() {
myAudio.rewind();
} }
public class StopCommand implements Command {
private AudioPlayer myAudio; public StopCommand(AudioPlayer audioPlayer){
myAudio = audioPlayer;
}
@Override
public void execute() {
myAudio.stop();
} }

  请求者角色,由键盘类扮演

public class Keypad {
private Command playCommand;
private Command rewindCommand;
private Command stopCommand; public void setPlayCommand(Command playCommand) {
this.playCommand = playCommand;
}
public void setRewindCommand(Command rewindCommand) {
this.rewindCommand = rewindCommand;
}
public void setStopCommand(Command stopCommand) {
this.stopCommand = stopCommand;
}
/**
* 执行播放方法
*/
public void play(){
playCommand.execute();
}
/**
* 执行倒带方法
*/
public void rewind(){
rewindCommand.execute();
}
/**
* 执行播放方法
*/
public void stop(){
stopCommand.execute();
}
}

  客户端角色,由茱丽小女孩扮演

public class Julia {
public static void main(String[]args){
//创建接收者对象
AudioPlayer audioPlayer = new AudioPlayer();
//创建命令对象
Command playCommand = new PlayCommand(audioPlayer);
Command rewindCommand = new RewindCommand(audioPlayer);
Command stopCommand = new StopCommand(audioPlayer);
//创建请求者对象
Keypad keypad = new Keypad();
keypad.setPlayCommand(playCommand);
keypad.setRewindCommand(rewindCommand);
keypad.setStopCommand(stopCommand);
//测试
keypad.play();
keypad.rewind();
keypad.stop();
keypad.play();
keypad.stop();
}
}

运行结果如下:aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABD8AAADqCAIAAAAqF3mWAAAgAElEQVR4nO3de3Ac1YHv8fk7e2/+2ardqtRWpbaytQu4KhXCWjchWVK3bpZ7yVYIEBEbCGZiHCMDMUbCZogNFrbRAxxb2Gt7sMGWCVhjyYplCwvbwlhG8hOQ5YeIIWBZfusxUlvPeff9o6WZfpzu6RnNSGrp+6kuGPd0nz59+jHnN909cklara2t5eXl5eXl0vQz5Vd8yq9geuL7vDydlI9qbW2d6C0wMTgcAACYzMw6Ki71P5Ru3DjWahKZ8is+5VcwPco+P9FRYiJN8xjDcQEA2VZZWblgwYLc1C1YsKCysjKDhcCJjF2URHohukxhU34F06Ps8zHEYrFYbNpmGI4OAE63atWqwcHBia6FmM/nmzt37po1a95O3Zo1ax555BGfz5eRQpT6TOa2ghld/2QkveiiS7nXXV42u9zrLvfmlZd7fOUlPp/XV+Pz1ez37W+oaWipabgw3hXPminfd1Gv4N7XfyAcJq52E4boIkSA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/ff/Dgwa6urom59rJu3brKysqGhgbSCwAAAAAjJb2sWLGirq7u1KlTE3PtJf7cS0VFRVNTE+kFAAAAgJGSXjZt2tTY2Dhhz72of3Ps8OHDpBcAAAAARkp6qaysnODfHFMHGP7eCwAAAACjnsnz916sTUjrAAAAAJg8dBlhnNJLLwAAAACMjTq6ZDG93Epd2pUAAAAA4FBJY4I6umQrvXSmrgMAAADANJNGcMh8egEAAACASYX0AgAAAMAZ4mnl/wMkfAkffui76gAAAABJRU5ErkJggg==" alt="" />

宏命令

  所谓宏命令简单点说就是包含多个命令的命令,是一个命令的组合。

  设想茱丽的录音机有一个记录功能,可以把一个一个的命令记录下来,再在任何需要的时候重新把这些记录下来的命令一次性执行,这就是所谓的宏命令集功能。因此,茱丽的录音机系统现在有四个键,分别为播音、倒带、停止和宏命令功能。此时系统的设计与前面的设计相比有所增强,主要体现在Julia类现在有了一个新方法,用以操作宏命令键。

  源代码

  系统需要一个代表宏命令的接口,以定义出具体宏命令所需要的接口。

public interface MacroCommand extends Command {
/**
* 宏命令聚集的管理方法
* 可以添加一个成员命令
*/
public void add(Command cmd);
/**
* 宏命令聚集的管理方法
* 可以删除一个成员命令
*/
public void remove(Command cmd);
}

  具体的宏命令MacroAudioCommand类负责把个别的命令合成宏命令。

public class MacroAudioCommand implements MacroCommand {

    private List<Command> commandList = new ArrayList<Command>();
/**
* 宏命令聚集管理方法
*/
@Override
public void add(Command cmd) {
commandList.add(cmd);
}
/**
* 宏命令聚集管理方法
*/
@Override
public void remove(Command cmd) {
commandList.remove(cmd);
}
/**
* 执行方法
*/
@Override
public void execute() {
for(Command cmd : commandList){
cmd.execute();
}
} }

  客户端类Julia

public class Julia {

    public static void main(String[]args){
//创建接收者对象
AudioPlayer audioPlayer = new AudioPlayer();
//创建命令对象
Command playCommand = new PlayCommand(audioPlayer);
Command rewindCommand = new RewindCommand(audioPlayer);
Command stopCommand = new StopCommand(audioPlayer); MacroCommand marco = new MacroAudioCommand(); marco.add(playCommand);
marco.add(rewindCommand);
marco.add(stopCommand);
marco.execute();
}
}

  运行结果如下:aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABD8AAADqCAIAAAAqF3mWAAAgAElEQVR4nO3de3AU14Hv8fk7e2/+2ardqtRWpbayu7Fhb8per3ITJ+vUVrK+66RCbEcO+D0hBAvsYJAMlg0YGbAkHAIyLCCDDcIPNEgoFi8ZkAGBxNsW4iEbsEEI8dJjpEEPNJpX3z9amunH6TM9o9Gjpe+nTlFDT/fp06d7es5vumfk8unV19cXFRUVFRX5xp8xv+FjfgOTEz3mO3v6xk8pGlBfXz/Se2Bk8HIAAGA0sxqouLT/UYdxw9iqUWTMb/iY38DkqMe8t7PX29nb2Hxn/BR1k72dveM8xvC6AIChVlJSMmPGjPTEzZgxo6SkJIWVwInMQ5RYeiG6jGFjfgOTox7zzR0939zsGLeluaNHLeM2w/DqAOB0S5cu7enpGelWiHk8nqlTp65YseK9xK1YseLJJ5/0eDwpqURtz2juK1gxjE/604shuhQVuosKphQVuosKM4qKsj1F+R5Poafc4ynf49lTVV5VV151YbgbPmTG/NhFu4E73r5PWEaudSNGPeZvtHVdaPJSLjR5b7R13WjrIsAAwIgoKMj3eIznIo+nqKAgP+6y8hH5sd1zhGWwLbYnIyOjoKBgy5YtuxL36aefrlixIiMjIyWV2OkrjFra8YlFeimYUufzK4py2+/XFkVRKmvq1cflVVdHoO1DYMwPXLQb+En+/X2BkKGc3zFjHAYY9ZhvbL5zrqFVLU8t+uTel2vk5alFn0TnH5OlsfnO0F6E+fgnBS9P2lEwdW/h9Ib9i4ZkFYkb8ycBAKNcQUF+QUGBIcCo0UWdLl88bnoRvvUnGmCK38uwWbRLpaenb968ec+ePSf00pfXxS2ff/75iRMn1BvABl+Jnb5KIZuDimFoida+df8yFNXOkErJUoL0YnjzLixwq+ml8czp+mVLTj32SP2yJY1nTiuKUllz/rbf3zxWAsyYH7UYNnBb3r+ZT2GX9i+oH2cBRo0ul292nP6mOVrunXU4fdoSebl31mHt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CjOKNH08v8B5ays7p6PA9cAAAAASUVORK5CYII=" alt="" />

命令模式的优点

  ●  更松散的耦合

  命令模式使得发起命令的对象——客户端,和具体实现命令的对象——接收者对象完全解耦,也就是说发起命令的对象完全不知道具体实现对象是谁,也不知道如何实现。

  ●  更动态的控制

  命令模式把请求封装起来,可以动态地对它进行参数化、队列化和日志化等操作,从而使得系统更灵活。

  ●  很自然的复合命令

  命令模式中的命令对象能够很容易地组合成复合命令,也就是宏命令,从而使系统操作更简单,功能更强大。

  ●  更好的扩展性

  由于发起命令的对象和具体的实现完全解耦,因此扩展新的命令就很容易,只需要实现新的命令对象,然后在装配的时候,把具体的实现对象设置到命令对象中,然后就可以使用这个命令对象,已有的实现完全不用变化。

原文地址:《JAVA与模式》之命令模式

《JAVA设计模式》之命令模式(Command)的更多相关文章

  1. 折腾Java设计模式之命令模式

    博客原文地址 折腾Java设计模式之命令模式 命令模式 wiki上的描述 Encapsulate a request as an object, thereby allowing for the pa ...

  2. 设计模式 ( 十三 ) 命令模式Command(对象行为型)

    设计模式 ( 十三 ) 命令模式Command(对象行为型) 1.概述         在软件设计中,我们经常需要向某些对象发送请求,但是并不知道请求的接收者是谁,也不知道被请求的操作是哪个,我们只需 ...

  3. 乐在其中设计模式(C#) - 命令模式(Command Pattern)

    原文:乐在其中设计模式(C#) - 命令模式(Command Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 命令模式(Command Pattern) 作者:webabcd ...

  4. 面向对象设计模式_命令模式(Command)解读

    在.Net框架中很多对象的方法中都会有Invoke方法,这种方法的设计实际是用了设计模式的命令模式, 模式图如下 其核心思路是将Client 向Receiver发送的命令行为进行抽象(ICommand ...

  5. 二十四种设计模式:命令模式(Command Pattern)

    命令模式(Command Pattern) 介绍将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化:对请求排队或记录请求日志,以及支持可取消的操作. 示例有一个Message实体类,某个 ...

  6. 设计模式-15命令模式(Command Pattern)

    1.模式动机 在软件设计中,我们经常需要向某些对象发送请求,但是并不知道请求的接收者是谁,也不知道被请求的操作是哪个,我们只需在程序运行时指定具体的请求接收者即可,此时,可以使用命令模式来进行设计,使 ...

  7. JAVA设计模式之 命令模式【Command Pattern】

    一.概述 命令模式能够将请求发送者和接收者全然解耦.发送者与接收者之间没有直接引用关系,发送请求的对象仅仅须要知道怎样发送请求,而不必知道怎样完毕请求.核心在于引入了命令类,通过命令类来减少发送者和接 ...

  8. Java设计模式 之 命令模式

    1      从属模式分类 行为性模式 2      命令模式意图 命令模式可将动作的请求者和动作的执行者对象中解耦. 该模式将一个行为操作发起者的请求封装到对象中,该请求由另外一个对象执行. 将动作 ...

  9. [设计模式] 14 命令模式 Command

    Command 模式通过将请求封装到一个对象(Command)中,并将请求的接受者存放到具体的 ConcreteCommand 类中(Receiver)中,从而实现调用操作的对象和操作的具体实现者之间 ...

  10. 设计模式之命令模式(Command)摘录

    23种GOF设计模式一般分为三大类:创建型模式.结构型模式.行为模式. 创建型模式抽象了实例化过程,它们帮助一个系统独立于怎样创建.组合和表示它的那些对象.一个类创建型模式使用继承改变被实例化的类,而 ...

随机推荐

  1. javascript基础总汇

    ## javaScript是什么:1.JavaScript 运行在客户端(浏览器)的编程语言2.用来给HTML网页增加动态功能3.用来给HTML网页增加动态功能.4.Netscape在最初将其脚本语言 ...

  2. 【学习总结】java数据结构和算法-第三章-稀疏数组和队列

    相关链接 [学习总结]尚硅谷2019java数据结构和算法 github:javaDSA 目录 稀疏数组 队列 稀疏数组 稀疏数组介绍 图示 应用实例 代码实现 SparseArray.java:与二 ...

  3. 命令行运行python -m http.server报错

    最近在学习网站搭建,借助python搭建服务器时,在网站目录启动python服务时报错,如下: UnicodeDecodeError: 'utf-8' codec can't decode byte ...

  4. ASE Alpha Sprint - backend scrum 8

    本次scrum于2019.11.13再sky garden进行,持续30分钟. 参与人: Zhikai Chen, Jia Ning, Hao Wang 请假: Xin Kang, Lihao Ran ...

  5. intel vtune 介绍、安装和使用

    intel vtune 介绍 https://software.intel.com/en-us/vtune intel vtune 安装包下载地址 https://software.intel.com ...

  6. python面向对象--类的内置函数

    #isinstance(obj,cls)判断obj是否是类cls的实例 #issubclass(cls,cls1)判断cls是否是cls1的子类或派生类 class Foo: pass class B ...

  7. Ubuntu NFS搭建过程

    先简单介绍一下NFS服务器是什么? NFS server可以看作是一个FILE SERVER,它可以让你的PC通过网络将远端的NFS SERVER共享出来的档案MOUNT到自己的系统中,在CLIENT ...

  8. Jenkins 使用python进行调度,并下载apphost上的安装包

    在持续集成的过程中,Jenkins工具是我们必须要会用的工具,那么今天分享一个使用python对Jenkins进行调度的案例 使用的是python-jenkins 库,借用selenium登陆jenk ...

  9. mycat操作mysql示例之分库

    准备工作: 服务器192.168.96.12,centos7, jdk,mysql5.7,mycat1.6.x,navicat 搭建步骤: 1.在服务器192.168.96.12服务器上安装mysql ...

  10. java.lang.unsatisfiedLinkError:找不到指定的程序

    然后我检查了一下 明明在啊??? 查看下一个错误提示: 参考:https://bbs.csdn.net/topics/392215961   https://bbs.csdn.net/topics/3 ...