[OFBiz]开发 三
1. Debug
不要在Eclipse中使用Ant来启动ofbiz, 因为在Eclipse中无法kill掉Ant的进程,而ofbiz又没有提供stop的方法。(有一个hook shutdown的方法,但是没有作用)
使用startofbiz.bat来启动ofbiz, 打开debug模式,端口5005.
注意:如果需要对org.ofbiz.base.start.Start进行debug的话,需要修改:
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
2.ofbiz-component.xml
总共有60个ofbiz-componnet.xml文件。
E:\eclipse-SDK-3.7.1-win32\ofbiz\apache-ofbiz-10.04\framework\catalina\ofbiz-component.xml
配置的是Tomcat的模块
E:\eclipse-SDK-3.7.1-win32\ofbiz\apache-ofbiz-10.04\applications\content\ofbiz-component.xml
配置的是content web应用程序的模块
它含有webapp节点:
<webapp name="content"
title="Content"
server="default-server"
location="webapp/content"
base-permission="CONTENTMGR"
mount-point="/content"/>
3.启动过程:org.ofbiz.base.start.Start
private void startStartLoaders() {
// start the loaders
for (StartupLoader loader: loaders) {
try {
loader.start();
} catch (StartupException e) {
e.printStackTrace();
System.exit(99);
}
}
serverStarted = true;
}
然后,进入org.ofbiz.base.container.ContainerLoader的start()方法中, 启动所有的Container:
public void start() throws StartupException {
Debug.logInfo("[Startup] Starting containers...", module);
// start each container object
for (Container container: loadedContainers) {
try {
container.start();
} catch (ContainerException e) {
throw new StartupException("Cannot start() " + container.getClass().getName(), e);
} catch (java.lang.AbstractMethodError e) {
throw new StartupException("Cannot start() " + container.getClass().getName(), e);
}
}
}
tomcat, 就是其中的一个作为container启动的模块。
4. 关于ofbiz-component.xml的DTD:
http://ofbiz.apache.org/dtds/ofbiz-component.xsd
<classpath type="jar" location="lib/*"/> ------------------>classpath相关
<classpath type="jar" location="build/lib/*"/>
<classpath type="dir" location="config"/>
<entity-resource type="model"
reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
classpath可以支持这两种形式:
<classpath type="jar" location="lib/product.jar"/>
<classpath type="dir" location="classes"/>
5.配置文件读取过程:
1), 先从System.getProperty("ofbiz.system.props")中,找到global的配置文件,加载到System properties中。
2),通过String cfgFile = Start.getConfigFileName(firstArg);得到类似于:
org/ofbiz/base/start/start.properties
这样的配置文件。
6.classpath的加载:
org.ofbiz.base.start.Start.initClasspath()
org.ofbiz.base.start.Start.loadLibs(String, boolean)
它将把以下路径,添加到classpath中去:
E:\eclipse-SDK-3.7.1-win32\ofbiz\apache-ofbiz-10.04\ofbiz.jar; ------------>启动类
E:\jdk1.6.0_20\lib\tools.jar;
E:\eclipse-SDK-3.7.1-win32\ofbiz\apache-ofbiz-10.04 ------------>ofbiz HOME
E:/eclipse-SDK-3.7.1-win32/ofbiz/apache-ofbiz-10.04/framework/base/lib
E:/eclipse-SDK-3.7.1-win32/ofbiz/apache-ofbiz-10.04/framework/base/build/lib/ofbiz-base.jar
E:/eclipse-SDK-3.7.1-win32/ofbiz/apache-ofbiz-10.04/framework/base/dtd
E:/eclipse-SDK-3.7.1-win32/ofbiz/apache-ofbiz-10.04/framework/base/config
而:
containerconfig=E:/eclipse-SDK-3.7.1-win32/ofbiz/apache-ofbiz-10.04/framework/base/config/ofbiz-containers.xml
7.Debug信息输出:启动JVM时,加上-DDEBUG=true属性.
if (System.getProperty("DEBUG") != null)
8.启动过程中:
if (fullInit) {
// initialize the classpath
initClasspath(); ---------->重要
// initialize the log directory
initLogDirectory();
// initialize the listener thread
initListenerThread();
// initialize the startup loaders
initStartLoaders(); ---------->重要
// set the shutdown hook
if (config.useShutdownHook) {
setShutdownHook();
} else {
System.out.println("Shutdown hook disabled");
}
}
}
start.init(args, true);
start.start();
=============>start.init(args, true);
1. 将执行start.properties里面的ofbiz.start.loader1=org.ofbiz.base.container.ContainerLoader
2. 它的org.ofbiz.base.container.ContainerLoader.load(Config, String[])方法,
将会被执行。
3. 把E:/eclipse-SDK-3.7.1-win32/ofbiz/apache-ofbiz-10.04/framework/base/config/ofbiz-containers.xml作为参数传进来
4. 将会从ofbiz-containers.xml中读取9个containers,其中包括了tomcat的那个:
[
org.ofbiz.base.container.ContainerConfig$Container@185fe0c, org.ofbiz.base.container.ContainerConfig$Container@1e9f5cc, org.ofbiz.base.container.ContainerConfig$Container@1082823, org.ofbiz.base.container.ContainerConfig$Container@831a91, org.ofbiz.base.container.ContainerConfig$Container@1453d72, org.ofbiz.base.container.ContainerConfig$Container@c5186e, org.ofbiz.base.container.ContainerConfig$Container@1c70315, org.ofbiz.base.container.ContainerConfig$Container@9b59a2, org.ofbiz.base.container.ContainerConfig$Container@119db9e
]
10个配置的containers:
component-container
classloader-container
commons-vfs-container
webslinger-container
naming-container
rmi-dispatcher
catalina-container --------->tomcat
ajp-connector
birt-container
beanshell-container
得到:
<container name="catalina-container" class="org.ofbiz.catalina.container.CatalinaContainer">
这里只是收集作用,把它们(9个containers)
放到org.ofbiz.base.container.ContainerLoader.loadedContainers存起来。
=============>start.start();
1. 将执行start.properties里面的ofbiz.start.loader1=org.ofbiz.base.container.ContainerLoader
2. 它的org.ofbiz.base.container.ContainerLoader.start()方法,
将会被执行。
3.它会把刚才记录的9个containers都进行初始起动的。
9.考察Tomcat的启动过程:
<container name="catalina-container" class="org.ofbiz.catalina.container.CatalinaContainer">
先是初始化:
org.ofbiz.catalina.container.CatalinaContainer.init(String[], String)
------>它是在start.init(args, true);的时候,被带起来执行的。
org.ofbiz.catalina.container.CatalinaContainer.loadComponents() ---->循环
org.ofbiz.catalina.container.CatalinaContainer.createContext(WebappInfo)
然后,才是在start.start();的时候,被启动的:
org.ofbiz.catalina.container.CatalinaContainer.start()
信息:debug在:org.ofbiz.catalina.container.CatalinaContainer.loadComponents()
// load the applications
List<ComponentConfig.WebappInfo> webResourceInfos = ComponentConfig.getAllWebappResourceInfos();
可以得到44个web应用程序。
10.一个很重要的jar包:
E:\eclipse-SDK-3.7.1-win32\ofbiz\apache-ofbiz-10.04\framework\base\build\lib\ofbiz-base.jar
它里面的:org.ofbiz.base.component.ComponentConfig.getAllComponents()
也是一个很重要的方法。
关注一下:componentConfigs.put(componentConfig.getGlobalName(), componentConfig);
是什么时候被调用,被填上值的。
它是在start.init(args, true);的时候,它是配置在ofbiz-containers.xml中的第一个节点:
<!-- load the ofbiz component container (always first) -->
<container name="component-container" class="org.ofbiz.base.container.ComponentContainer"/>
它是作为一个container被启动的,它的作用是负责收集所有的component模块信息。
收集的结果,放在:
org.ofbiz.base.component.ComponentConfig.componentConfigs
protected static Map<String, ComponentConfig> componentConfigs
以备接下来的其它的container(如:tomcat),初始化webapp时使用。
每一个ofbiz-component.xml对应于下面的这个类:
org.ofbiz.base.component.ComponentConfig.ComponentConfig(String, String)
ofbiz-component.xml里面的节点,都是在这个类的构造方法中被解析的,包括webapp:
// webapp - webappInfos
for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "webapp")) {
WebappInfo webappInfo = new WebappInfo(this, curElement);
this.webappInfos.add(webappInfo);
} // classpath - classpathInfos
for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "classpath")) {
ClasspathInfo classpathInfo = new ClasspathInfo(this, curElement);
this.classpathInfos.add(classpathInfo);
}
[OFBiz]开发 三的更多相关文章
- App开发三种模式
APP开发三种模式 现在App开发的模式包含以下三种: Native App 原生开发AppWeb App 网页AppHybrid App 混合原生和Web技术开发的App 详细介绍: http:// ...
- iOS开发三步搞定百度推送
iOS开发三步搞定百度推送 百度推送很简单,准备工作:在百度云推送平台注册应用,上传证书. 步骤一: 百度云推送平台 http://push.baidu.com/sdk/push_client_s ...
- 基于Spring MVC的Web应用开发(三) - Resources
基于Spring MVC的Web应用开发(3) - Resources 上一篇介绍了在基于Spring MVC的Web项目中加入日志,本文介绍Spring MVC如何处理资源文件. 注意到本项目的we ...
- Java Web高性能开发(三)
今日要闻: Clarifai:可识别视频中物体 最近几年,得益于深度学习技术的发展,谷歌和Facebook等企业的研究人员在图形识别软件领域取得了重大突破.现在,一家名为Clarifai的创业公司则提 ...
- C#的百度地图开发(三)依据坐标获取位置、商圈及周边信息
原文:C#的百度地图开发(三)依据坐标获取位置.商圈及周边信息 我们得到了百度坐标,现在依据这一坐标来获取相应的信息.下面是相应的代码 public class BaiduMap { /// < ...
- Qt计算器开发(三):执行效果及项目总结
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/guodongxiaren/article/details/26046543 执行效果 project ...
- GitHub 多人协作开发 三种方式:
GitHub 多人协作开发 三种方式: 一.Fork 方式 网上介绍比较多的方式(比较大型的开源项目,比如cocos2d-x) 开发者 fork 自己生成一个独立的分支,跟主分支完全独立,pull代码 ...
- 从零开始实现ASP.NET Core MVC的插件式开发(三) - 如何在运行时启用组件
标题:从零开始实现ASP.NET Core MVC的插件式开发(三) - 如何在运行时启用组件 作者:Lamond Lu 地址:https://www.cnblogs.com/lwqlun/p/112 ...
- Python服务器开发三:Socket
Python服务器开发三:Socket socket是操作系统中I/O的延续,它可以使进程和机器之间的通信成为可能.socket可以看成一个标准的文件描述符.不同的是文件需要用open()函数打开 ...
随机推荐
- hdu1116
http://acm.hdu.edu.cn/showproblem.php?pid=1116 #include<stdio.h> #include<math.h> #inclu ...
- redis、memcache、mongoDB有哪些区别(转载)
转载: http://leandre.cn/database/64.html Memcached Memcached的优点: Memcached可以利用多核优势,单实例吞吐量极高,可以达到几十万QPS ...
- lintcode:Minimum Subarray 最小子数组
题目: 最小子数组 给定一个整数数组,找到一个具有最小和的子数组.返回其最小和. 样例 给出数组[1, -1, -2, 1],返回 -3 注意 子数组最少包含一个数字 解题: 和最大子数组 ,差不多的 ...
- hdu 4474 Yet Another Multiple Problem
题意: 找到一个n的倍数,这个数不能含有m个后续数字中的任何一个 题解: #include<stdio.h> #include<string.h> #include<qu ...
- ubuntu下安装pthread的manpages(man 手册) 在Ubuntu中查看STL帮助
http://blog.csdn.net/leisure512/article/details/4881391 由于学习多线程编程,所以用到pthread,但是man的时候却发现没有pthread函数 ...
- eclipse Juno Indigo Helios Galileo这几种版本的意思(转)
Galileo Ganymede Europa 这些名字代表eclipse不同的版本 2001年11月7日 ,Eclipse 1.0发布 半年之后,2002年6月27日Eclipse进入了2.0 ...
- 如何构建你自己的Java库【翻译】
原文http://www.programcreek.com/2011/07/build-a-java-library-for-yourself/ 原文和翻译都只是参考,如有不对,欢迎指正. 代码复用是 ...
- n人比赛,可轮空,比赛轮数和场数
#include<stdio.h> int chang(int x,int s){ ) return s; ) ; !=){ s+=(x-)/; )/,s); } else{ s+=x/; ...
- C++ STL之迭代器注意事项
1.两个迭代器组成的区间是前闭后开的 2.如果迭代器的有效性,如果迭代器所指向的元素已经被删除,那么迭代器会失效 http://blog.csdn.net/hsujouchen/article/det ...
- 【转载】React入门-Todolist制作学习
我直接看的这个React TodoList的例子(非常好!): http://www.reqianduan.com/2297.html 文中示例的代码访问路径:http://127.0.0.1:708 ...