java代碼
interface CommandRecovery{
Command recover(Throwable th)
throws Throwable;
}
當某個command失敗的時候
然後定義具體的錯誤恢復邏輯
java代碼
class RecoveredCommand implements Command{
private final Command c
private final CommandRecovery c
public Object execute(CommandContext ctxt){
try{
return c
}
catch(Throwable th){
return c
}
}
RecoveredCommand (Command c
this
this
}
}
有try
[
From:http://tw.wingwit.com/Article/program/Java/ky/201311/29273.html