由于最近一段时间在给一个创业的公司做客户关系管理CRM系统,限于人力要求(其实是没有多少人力),只能看能否有稳定,开源的半成品进行改造,而且最好不需要前端(js)相关开发人员的支援就可以把事情做成,经过一段时间(其实也就是1周)的调研,最好把目标锁定在OFBiz上。

OFBiz简介,什么是OFBiz

 
OFBiz is an Apache Software Foundation top level project.
 
Apache  OFBiz全称是The ApacheOpen For Business Project。是开放的电子商务平台,是一个非常著名的开源项目,提供了创建基于最新的J2EE/XML规范和技术标准,构建大中型企业级、快平台、跨数据库、跨应用服务器的多层、分布式电子商务类WEB应用系统的框架。
 
OFBiz几乎实现了所有的J2EE核心设计模式,各个模块之间的耦合比较松散,用户能够比较容易的根据自己的需要进行拆卸,非常灵活。下面介绍一下它的目录结构以及文件说明。
 
可以参考一些blog中关于OFBiz的讨论:
 
 

Apache OFBiz进行环境部署

 
Apache OFBiz是一个商业软件架构,opentaps 基于 Apache OFBiz 的解决方案,其官方网站地址:
 
在官网中下载最新版本的OFBiz:apache-ofbiz-13.07.02.zip
 
将其解压,执行命令
 
ant
ant load-demo
cd tools
./startofbiz.sh
 
执行完成后,就可以在本机的下面url中的查看相应的功能:
 
 
其中,管理员的用户名 admin/ofbiz,登录后的界面如下(其中修改了默认的视觉风格): 


 

一些重要的配置文件

 
<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->

component-load.xml

 
路径:ofbiz\application\,该配置文件的作用为模块加载文件,定义了所有在OFBIZ启动时需要加载的应用程序的位置,当你创建了新的应用程序时,别忘了在该文件中添加应用程序的位置信息,在 ofbiz\hot-deploy\目录下的应用程序不需要在component-load.xml里定义,ofbiz启动时会自动加载所有hot- deploy下的内容。
 

ofbiz-component.xml

 
位置:基于ofbiz的任何应用程序根目录下,指出该应用程序数据模型(<entity-resource>),商业逻辑(<service-resource>),web应用程序(<webapp.../>)的位置。
例子:  

<entity-resource type="model" reader-name="main"   loader="main" location="entitydef/entitymodel.xml" />
<service-resource type="model" loader="main" location="servicedef/services_agreement.xml" />
<webapp name="accounting" title="Accounting" server="default-server" location="webapp/accounting" base-permission="OFBTOOLS,ACCOUNTING" mount-point="/accounting" />
 

web.xml

 
位置:应用程序\webapp\accounting\WEB-INF,用于配置main servlet(s),控制后台服务器(如tomcat server),及一些相关参数。 
 

controller.xml

位置:应用程序\webapp\accounting\WEB-INF,作用:负责控制接收到的请求request。任何到来的请求,无论是屏幕请求,还是服务请求或事件请求,都要经过controller.xml的处理,然后转交给相应的部分处理。
例子:  
<request-map uri="main">
<security https="true" auth="true" />
<response name="success" type="view" value="main" />
</request-map>
<view-map name="main" type="screen" page="component://accounting/widget/CommonScreens.xml#main" />
(当请求"main"到来时,在controller.xml中,先找到<request-map uri="main">,根据其value="main",继续向下找到view-map name="main"
,最后得到该请求该返回的页面位置:page="component://accounting/widget /CommonScreens.xml#main" ) 
 
在OFBiz中,是根据模块-请求-服务-页面的总体流程来实现的,每个模块的配置文件如下:
 
<?xml version="1.0" encoding="UTF-8"?>
<ofbiz-component name="basicconfig"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
<resource-loader name="main" type="component"/>
<classpath type="jar" location="build/lib/*"/>
<classpath type="dir" location="config"/>
<entity-resource type="data" reader-name="main" loader="main" location="data/BasicDataTypeData.xml"/>
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_consultant.xml"/>
<webapp name="basicconfig"
title="BasicConfig"
description="BasicConfigDescription"
server="default-server"
base-permission="OFBTOOLS,BASICCONFIG"
location="webapp/basicconfig"
mount-point="/basicconfig"
app-bar-display="true">
</webapp> </ofbiz-component> 
 
其中涉及到 实体模型文件,服务模型文件,webapp声明部分。
 

OFBiz中的服务

其中的服务实现有两种,其中src对应其中的java类,此时声明service的engine为java,而没有使用OFBiz中自带的特殊服务类型,下面就是服务声明部分:
<service name="createConsultant" engine="java"
location="com.xxx.basicconfig.service.ConsultantServices" invoke="createConsultant" auth="true">
<description>Get commission receiving parties and amounts for a product. &lt;br/&gt;
amount input is for the entire quantity. &lt;br/&gt;&lt;br/&gt;
Returns a List of Maps each containing &lt;br/&gt;
partyIdFrom String commission paying party &lt;br/&gt;
partyIdTo String commission receiving party &lt;br/&gt;
commission BigDecimal Commission &lt;br/&gt;
days Long term days &lt;br/&gt;
currencyUomId String Currency &lt;br/&gt;
productId String Product Id &lt;br/&gt;
Will use the virtual product if no agreement is found for a variant product. If no quantity is specified,
defaults to one (1).
</description>
<!--<permission-service service-name="acctgCommissionPermissionCheck" main-action="VIEW"/>-->
<attribute name="consultantName" type="String" mode="IN" optional="false"/>
<attribute name="consultantCode" type="String" mode="IN" optional="false"/>
<attribute name="consultantEmail" type="String" mode="IN" optional="false"/>
<attribute name="consultantGender" type="String" mode="IN" optional="false"/>
<attribute name="consultantCity" type="String" mode="IN" optional="false"/>
<!--<attribute name="commissions" type="List" mode="OUT" optional="false"/>-->
</service>
其中涉及到了服务名称,引擎类型(java),如果引擎是java类,location就使用了对应的Java类完整路径,invoke中指定了该类型调用的方法。
 
属性列表中声明了该服务所输入/输出的所有的参数列表,如果在调用该服务时,参数并没有满足要求,比如名称,类型,输入(IN)且optional=false的参数没有传过来,则会报错。
 
服务类的方式采用类型的静态方法(保证无状态),其实现举例如下:
 
public static Map<String, Object> deleteConsultant(DispatchContext dispatchContext, Map<String, Object> context) {
String consultantId = (String) context.get("userId");
Delegator delegator = dispatchContext.getDelegator();
GenericPK dsConsultant = delegator.makePKSingle("UserLoginSecurity", consultantId); try {
delegator.removeByPrimaryKey(dsConsultant);
} catch (GenericEntityException e) {
Debug.logWarning(e.getMessage(), module);
return ServiceUtil.returnError(e.getMessageList());
}
return new HashMap<>();
}
 在Map结构的Context中,根据key(也就是service文件中声明的属性名称,mode需为IN/INOUT)来拿到其对应的值,返回一个Map,其中的key对应service文件声明的属性,mode对应OUT,需要将该名称的属性值放到Map中。
 
在服务实现中无可避免地需要使用数据层服务,这个时候,就需要dispatchContext.getDelegator()方法来拿到Delegator作为数据端的代理,使用OFBiz中的数据模型服务来操纵数据库。关于Delegator以及数据服务端,在下一篇总结中介绍。
 
 
 

ApacheOFBiz的相关介绍以及使用总结(一)的更多相关文章

  1. ApacheOFBiz的相关介绍以及使用总结(三)

    Ofbiz中还提供了一些基础性服务,可以直接用来使用,下面就简单介绍说明一下.   ofbiz邮件发送服务   ofbiz中提供发送邮件相关功能:sendMailFromScreen   contex ...

  2. ApacheOFBiz的相关介绍以及使用总结(二)

    OFBiz的实体配置   实体定义文件一般存放位置是在对应模块的entity文件夹下面,在该模块对应的ofbiz-component.xml配置文件中加入一行,用来声明实体定义文件路径:   < ...

  3. ppDelegate的相关介绍

    //  AppDelegate的相关介绍//  IOS笔记 //@interface AppDelegate : UIResponder <UIApplicationDelegate>// ...

  4. 【个人笔记】002-PHP基础-01-PHP快速入门-02-PHP语言相关介绍输

    002-PHP基础-01-PHP快速入门 02-PHP语言相关介绍 1.PHP是什么 Hypertext Preprocessor超文本预处理器 是一种通用开源脚本语言 Personal Home P ...

  5. Android HttpClient HttpURLConnection相关介绍

    Android HttpClient HttpURLConnection相关介绍 遇到一个问题 在android studio上用HttpClient编写网络访问代码的时候,发现该类无法导入并使用.. ...

  6. Android开发工程师文集-Activity生命周期,启动方式,Intent相关介绍,Activity详细讲解

    前言 大家好,给大家带来Android开发工程师文集-Activity生命周期,启动方式,Intent相关介绍,Activity详细讲解的概述,希望你们喜欢 Activity是什么 作为一个Activ ...

  7. CSS3 Backgrounds相关介绍

    CSS3 Backgrounds相关介绍 1.背景图片(background images)是在padding-box的左上角落脚安家的,我们可以使用background-position属性改变默认 ...

  8. 一 hadoop 相关介绍

    hadoop 相关介绍 hadoop的首页有下面这样一段介绍.对hadoop是什么这个问题,做了简要的回答. The Apache™ Hadoop® project develops open-sou ...

  9. Django day 33 vue中使用element-ui的使用,课程的相关介绍,vue绑定图片,课程列表接口,课程详情页面

    一:vue中使用element-ui的使用, 二:课程的相关介绍, 三:vue绑定图片, 四:课程列表接口, 五:课程详情页面

随机推荐

  1. 原生js重写《锋利的JS》之 轮播效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. jmeter的三种参数化

    以FTP请求(用户.密码)为例:(其他都相同) 1.文件参数化 使用配置元件中的CSV Data Set Config 配置CSV Data Set Config: 文件中存储ftp登录的用户名和密码 ...

  3. mybatis传入0但判断为空

    当是数字类型时,传入0会判断为空,当值为空,显示在页面上的将会是0:

  4. Linux:修改Shell命令提示符及颜色

    Linux修改Shell命令提示符及颜色   1. Linux登录过程中加载配置文件顺序: /etc/profile → /etc/profile.d/*.sh → ~/.bash_profile → ...

  5. MB到片组的映射

    待分析 链接原文: http://blog.csdn.net/mr_phy/article/details/61638262

  6. win7下pyhton3.6创建django2的pycharm项目

    1.进入python虚拟环境: workon workon oneenv 2. 在虚拟环境中安装django,也可以使用pycharm上的自动安装,但那个比较慢,所有还是在cmd中安装的好 pip i ...

  7. chrome 55 zepto tap事件出错?

    刚才升级chrome后发现的,在54.0.2840.98上点击没有问题,在新升级的55.0.2883.75 上点击后会报错Cannot read property 'trigger' of undef ...

  8. 构造字典:DictionaryBase类和SortedList类

    DictionaryBase 类 msdn对DictionaryBase的文档解释 泛型KeyValuePair类 msdnd对泛型KeyValuePair类的文档解释 SortedList类 RUN ...

  9. UDP:rfc768/广播和多播/IGMP

    封装情况:

  10. python使用progressbar显示进度条

    progressbar安装: pip install progressbar 用法一 # -*- coding=utf-8 -*- import time from progressbar impor ...