spring源码分析之resource.docxVIP

  • 12
  • 0
  • 约5.17千字
  • 约 8页
  • 2016-12-15 发布于湖北
  • 举报
Resource相关类图看代码过程中觉得很好的地方AbstractResource.java public boolean exists() { // Try file existence: can we find the file in the file system? try { return getFile().exists(); } catch (IOException ex) { // Fall back to stream existence: can we open the stream? try { InputStream is = getInputStream(); is.close(); return true; } catch (Throwable isEx) { return false; } } }这段代码,面向接口编程的典范,getInputStream()是父接口定义的方法,实际上的实现是在AbstractResource的子类中实现。以一种类似于模板方法模式的方式去编程,未来可扩展性较高。AbstractFileResolvingResource.java /** * Inner delegate class, avoiding a hard JBoss VFS API dependency at runtime. */ private static

文档评论(0)

1亿VIP精品文档

相关文档