spring resource
1.resource的前生后世
前生:public interface Resource extends InputStreamSource
public interface InputStreamSource {/*** Return an {@link InputStream}.* <p>It is expected that each call creates a <i>fresh</i> stream.* <p>This requirement is particularly important when you consider an API such* as JavaMail, which needs to be able to read the stream multiple times when* creating mail attachments. For such a use case, it is <i>required</i>* that each <code>getInputStream()</code> call returns a fresh stream.* @throws IOException if the stream could not be opened* @see org.springframework.mail.javamail.MimeMessageHelper#addAttachment(String, InputStreamSource)*/InputStream getInputStream() throws IOException;}
后世:
2.Resource辅助工具类ResourceUtils
1 /** Pseudo URL prefix for loading from the class path: "classpath:" */ 2 public static final String CLASSPATH_URL_PREFIX = "classpath:"; 3 4 /** URL prefix for loading from the file system: "file:" */ 5 public static final String FILE_URL_PREFIX = "file:"; 6 7 /** URL protocol for a file in the file system: "file" */ 8 public static final String URL_PROTOCOL_FILE = "file"; 9 10 /** URL protocol for an entry from a jar file: "jar" */ 11 public static final String URL_PROTOCOL_JAR = "jar"; 12 13 /** URL protocol for an entry from a zip file: "zip" */ 14 public static final String URL_PROTOCOL_ZIP = "zip"; 15 16 /** URL protocol for an entry from a JBoss jar file: "vfszip" */ 17 public static final String URL_PROTOCOL_VFSZIP = "vfszip"; 18 19 /** URL protocol for an entry from a WebSphere jar file: "wsjar" */ 20 public static final String URL_PROTOCOL_WSJAR = "wsjar"; 21 22 /** URL protocol for an entry from an OC4J jar file: "code-source" */ 23 public static final String URL_PROTOCOL_CODE_SOURCE = "code-source"; 24 25 /** Separator between JAR URL and file path within the JAR */ 26 public static final String JAR_URL_SEPARATOR = "!/";
3.resource的继承关系:(http://www.ibm.com/developerworks/cn/java/j-lo-spring-principle/index.html 图 8. Resource 相关的类结构图)
图 9. Context 和 Resource 的类关系图
从上图可以看出,Context 是把资源的加载、解析和描述工作委托给了 ResourcePatternResolver 类来完成,他相当于一个接头人,他把资源的加载、解析和资源的定义整合在一起便于其他组件使用。
转载于:https://www.cnblogs.com/davidwang456/archive/2013/03/21/2972916.html
spring resource相关推荐
- Spring.Resource与Spring资源获取方式
讲到资源,就得提下Spring获取资源方式,常用的有两种 通过Resource接口的子类获取资源通过ResourceLoader接口的子类获取资源 Spring.Resource 资源操作函数一览 / ...
- Spring Resource接口获取资源
1.1.1. Resource简介 在Spring内部实现机制,针对于资源文件(配置的xml文件)有一个统一的接口Resource. 1.1.1.1. 接口定义的方法 1.exists():判断资源文 ...
- java resouce_深入了解 Java Resource Spring Resource
在Java中,为了从相对路径读取文件,经常会使用的方法便是: xxx.class.getResource(); xxx.class.getClassLoader().getResource(); 在S ...
- Spring Resource和ResourceLoader源码解析
Spring用Resource接口抽象所有的底层资源,包括File.ClassPath.URL等.ResourceLoader接口是Resource的加载器,根据资源的路径/路径模式获取Resourc ...
- Spring @Resource
@Resource 的作用相当于 @Autowired,只不过 @Autowired 按 byType 自动注入,面 @Resource 默认按 byName 自动注入罢了.@Reso ...
- Spring @Resource详解
@Resource主要做依赖注入,从容器中自动获取bean,作用如下: 在启动Spring时,首先要启动容器 在启动Sprng容器时,会默认寻找容器扫描范围内的可加载的bean,然后查找哪些bean上 ...
- Spring @Resource 源码解析 – 为什么是ByName注入
前言 上篇博客[@Autowired 源码为什么是ByType注入]跟着源码详细的说明了@Autowired在Spring源码里面是如何设计为byType注入的.本篇博客的主要内容就是源码追踪探究@R ...
- Spring @Resource、@Autowired、@Qualifier区别
@Resource默认是按照名称来装配注入的,只有当找不到与名称匹配的bean才会按照类型来装配注入: @Autowired默认是按照类型装配注入的,如果想按照名称来转配注入,则需要结合@Qualif ...
- Spring资源加载器抽象和缺省实现 -- ResourceLoader + DefaultResourceLoader(摘)
概述 对于每一个底层资源,比如文件系统中的一个文件,classpath上的一个文件,或者一个以URL形式表示的网络资源,Spring 统一使用 Resource 接口进行了建模抽象,相应地,对于这些资 ...
最新文章
- SAP Marketing Cloud的sentiment engagement
- Office安装源损坏
- 小谈Online-game服务器端设计(1、2)
- IntelliJ IDEA优秀插件(编程通用)
- 我行贿了 I Paid A Bribe! --印度IPAB中国官方网站 - 民间反腐网站“我行贿了”网址大盘点...
- [SSH] 传输文件
- LINUX系统配置相关
- SpringCloud之服务网关(总体第五篇)
- 加拿大前十大学计算机硕士学费,2018年加拿大各大学硕士学费一览表!
- nar神经网络_动态神经网络(NAR)做预测
- C#中的Socket
- css flash布局_跳过简介-CSS3是新的Flash
- 跟着弦哥学人工智能2—HAND-CRAFTED RULES实现的人工智能及其缺陷
- Windows凭据管理器
- go 怎么等待所有的协程完成_优雅地等待子协程执行完毕
- 内存类型UDIMM、RDIMM、LRDIMM
- 24点游戏 java实现_java实现24点纸牌游戏
- unity 显示 html页面,unity打开外部或本地html网页方法
- 认知的高度 = 人生的高度
- 用计算机套路别人,套路计算器隐藏版
热门文章
- c++ 冒泡排序_学习笔记-详解冒泡排序
- html5获取当前坐标,HTML5教程 如何获取当前位置的经纬度
- php 子类名,php的继承方法获取子类名
- java定焦点_Android 开发 Camera1_如何使用对焦功能
- java jtextfield设置不可见_java – JPanel设置为不可见,除默认值之外的组合框选择将其设置为可见,但组件丢失...
- python编程小组信息程序下载_300种 Python 编程图书大集合(FTP服务器下载) (豆瓣 Python编程小组)...
- android 改python,如何正确的用python修改AndroidManifest.xml(史上最详细教程)
- centos ipv6 网卡_CentOS 6配置IPv6地址
- 在浙学计算机基础2020答案,浙江大学2020年硕士研究生复试分数线的基本要求
- java 6 26_WebSphere7.0 Java6.26安装