ofbiz實體引擎結合jbuilder的配置

uyang發表於2003-08-05
最近在研究ofbiz,希望和有興趣的人一起交流。
我的email:yangzhihong@sina.com



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

相關文章