您现在的位置是:首页 >

build的意思 关于build tool的构想 从Ant说起[6]

火烧 2022-12-08 09:53:54 1051
关于 uild tool的构想 从A t说起[6] java代码 i terface Comma dRecovery{ Comma d recover(Throwa le th) throw Thro
build的意思 关于build tool的构想 从Ant说起[6]

关于build tool的构想 从Ant说起[6]  

    java代码

    interface CommandRecovery{    Command recover(Throwable th)    throws Throwable;    }

    当某个mand失败的时候 这个接口会被调用 实现这个接口 可以有选择地对某一种或者几种错误进行恢复

    然后定义具体的错误恢复逻辑

    java代码

    class RecoveredCommand implements Command{    private final Command c ;    private final CommandRecovery c ;    public Object execute(CommandContext ctxt){    try{    return c execute(ctxt);    }    catch(Throwable th){    return c recover(th) execute(ctxt);    }    }    RecoveredCommand (Command c CommandRecovery c ){    this c = c ;    this c = c ;    }    }

    有try catch 就有try finally 我们也可以定义一个mand 让它保证某个关键动作必然运行

lishixinzhi/Article/program/Java/ky/201311/29273  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码