1.1 配置
这一节将给出实体引擎在jbuider中单独使用的配置向导
本文是从ofbiz网站的(OFBiz Quick Start Guide by Brett G. Palmer)的基础上完成配置。
1.从www.ofbiz.org中下载ofbiz-XX-XX-complete.zip包,本文用的是ofbiz-2.1.1-apps.zip
解开放到某个目录下,本文在j:\ofbiz,这也就是ofbiz.home的值
2.建立jbuilder项目,如下图所示
3.加入源文件,
ofbiz.home/core/src/entiry
ofbiz.home/core/src/share
4.加入所用到的jar文件
ofbiz.home/lib/common
ofbiz.home/lib/compile
ofbiz.home/lib/jasterreports
ofbiz.home/lib/jotm
ofbiz.home/lib/scripting
ofbiz.home/lib/share
ofbiz.home/lib/tyrex
5.将配置文件等导入工程
将ofbiz.home/commonapp/etc下所有文件打到ofbiz_etc.jar包内
jar cvf ofbiz_etc.jar *
将ofbiz.home/core/docs/xmldefs/ofbiz下所有文件打到ofbiz_dtd.jar包内
jar cvf ofbiz_dtd.jar *
将这两个包引入工程。
6.将ofbiz.home\setup\jrun4\servers\ofbiz\SERVER-INF\jndi.properties文件放入
ofbiz.home\lib\jotm\jotm.jar包内
7.配置ofbiz.home
在项目run tab中加入vm parameter:
-Dofbiz.home=j:\ofbiz
8.在GenericDelegator.java中,将下面语句注释掉。
/*
// setup the Entity ECA Handler
try {
Class eecahClass = loader.loadClass(ECA_HANDLER_CLASS_NAME);
this.entityEcaHandler = (EntityEcaHandler) eecahClass.newInstance();
this.entityEcaHandler.setDelegator(this);
} catch (ClassNotFoundException e) {
Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " was not found, Entity ECA Rules will be disabled");
} catch (InstantiationException e) {
Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " could not be instantiated, Entity ECA Rules will be disabled");
} catch (IllegalAccessException e) {
Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " could not be accessed (illegal), Entity ECA Rules will be disabled");
} catch (ClassCastException e) {
Debug.logWarning(e, "EntityEcaHandler class with name " + ECA_HANDLER_CLASS_NAME + " does not implement the EntityEcaHandler interface, Entity ECA Rules will be disabled");
}
*/
9.测试文件Test.java
package org.ofbiz.core;
import org.ofbiz.core.entity.GenericDelegator;
import org.ofbiz.core.entity.GenericValue;
import org.ofbiz.core.util.UtilMisc;
import org.ofbiz.core.entity.*;
public class Test {
public static void main(String[] args) {
System.out.println("Entered testFindByPrimaryKey");
//Instantiate the delegator.
GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");
// Find book by primary key
try {
GenericValue party= delegator.findByPrimaryKey("PartyType",
UtilMisc.toMap("partyTypeId", "PERSON"));
}
catch (GenericEntityException ex1) {
}
return;
}
}
10.ok