关于ofbiz-component.xml文件中的resource-loader
来源:互联网 发布:安卓源码编译教程 编辑:程序博客网 时间:2024/06/14 11:07
寻找文件的方式最后是通过ComponentConfig.java的getURL方法来解析的public URL getURL(String resourceLoaderName, String location) throws ComponentException { ResourceLoaderInfo resourceLoaderInfo = resourceLoaderInfos.get(resourceLoaderName); if (resourceLoaderInfo == null) { throw new ComponentException("Could not find resource-loader named: " + resourceLoaderName); } if ("component".equals(resourceLoaderInfo.type) || "file".equals(resourceLoaderInfo.type)) {//如果是<resource-loader name="main" type="component" /> String fullLocation = getFullLocation(resourceLoaderName, location); URL fileUrl = UtilURL.fromFilename(fullLocation); if (fileUrl == null) { throw new ComponentException("File Resource not found: " + fullLocation); } return fileUrl; } else if ("classpath".equals(resourceLoaderInfo.type)) { String fullLocation = getFullLocation(resourceLoaderName, location); URL url = UtilURL.fromResource(fullLocation); if (url == null) { throw new ComponentException("Classpath Resource not found: " + fullLocation); } return url; } else if ("url".equals(resourceLoaderInfo.type)) { String fullLocation = getFullLocation(resourceLoaderName, location); URL url = null; try { url = FlexibleLocation.resolveLocation(location); } catch (java.net.MalformedURLException e) { throw new ComponentException("Error with malformed URL while trying to load URL resource at location [" + fullLocation + "]", e); } if (url == null) { throw new ComponentException("URL Resource not found: " + fullLocation); } return url; } else { throw new ComponentException("The resource-loader type is not recognized: " + resourceLoaderInfo.type); } }
其中主要是看
就是用getFullLocation(resourceLoaderName, location);方法
它做的事是判断如果类型是component,就进行rootLocation+location。而rootLocation就是组建所在路径,而location就是我们的entity-resource或者service-resource等等设置的location。
另外这个方法还有几个操作,判断是否要使用prependEnv,如果使用,会添加上prependEnv
if (UtilValidate.isNotEmpty(resourceLoaderInfo.prependEnv)) { String propValue = System.getProperty(resourceLoaderInfo.prependEnv); if (propValue == null) { String errMsg = "The Java environment (-Dxxx=yyy) variable with name " + resourceLoaderInfo.prependEnv + " is not set, cannot load resource."; Debug.logError(errMsg, module); throw new IllegalArgumentException(errMsg); } buf.append(propValue); }//判断是否要添加prefix if (UtilValidate.isNotEmpty(resourceLoaderInfo.prefix)) { buf.append(resourceLoaderInfo.prefix); }
由此可以得出,resource-loader元素的完整配置是
<resource-loader name="main" type="component" prepend-env="" prefix=""/>
0 0
- 关于ofbiz-component.xml文件中的resource-loader
- ofbiz controller.xml 文件
- OFBIZ分享:关于contronal.xml 文件中response的类型
- Ofbiz中的.groovy文件
- Ofbiz中的.groovy文件
- 【Component】关于Ionic中的Component
- 关于FLASH中的LOADER问题
- spring @Resource + @Component
- struts 点击jar包中的文件Path must include project and resource name: /struts-default.xml
- 关于SpringMVC配置文件中的<context:component-scan >
- 关于 读取 resource.propety 文件 工具文件
- Spring @Autowired@Component@ Resource注解
- 关于如何使用vc6.0读取xml文件中的内容
- 关于如何使用vc6.0读取xml文件中的内容
- 关于Struts.xml文件中的配置(路径问题)
- 关于spring xml文件中的xmlns,xsi:schemaLocation
- 关于xml库文件在ubuntu中的安装方法
- 关于mybatis中xml文件中的#{}与${}的区别
- SSH三大框架的工作原理及流程
- MySQL server has gone away
- Codeforces #327-B. Rebranding-hash
- Android HandlerThread 完全解析
- java得到系统时区 +0800
- 关于ofbiz-component.xml文件中的resource-loader
- Web_Api的初识
- Swimvc
- 关闭浏览器窗口的两种方法分析
- asp 必须为 MapPath 方法指定 Path 参数
- 有一个疼你的女朋友是种怎样的体验
- Java程序设计(三)垃圾回收机制
- npm 安装module
- SSH框架的搭建(Struts2+Spring3+Hibernate3)