开始的一些知识和概念

  • B/S架构

用户工作界面是通过WWW浏览器来实现,极少部分事务逻辑在前端(Browser)实现,但是主要事务逻辑在服务器端(Server)实现,形成所谓三层3-tier结构。相对于C/S结构属于“胖”客户端,需要在使用者电脑上安装相应的操作软件来说,B/S结构是属于一种“瘦”客户端,大多数或主要的业务逻辑都存在在服务器端,因此,B/S结构的系统不需要安装客户端软件,它运行在客户端的浏览器之上,系统升级或维护时只需更新服务器端软件即可

  • OFBiz

OFBiz(The ApacheOpen For Business Project )是开放的电子商务平台,是一个非常著名的开源项目,提供了创建基于最新J2EE/XML规范和技术标准,构建大中型企业级、跨平台、跨数据库、跨应用服务器的多层、分布式电子商务类WEB应用系统的框架。 OFBiz最主要的特点是OFBiz提供了一整套的开发基于Java的web应用程序的组件和工具。包括实体引擎, 服务引擎, 消息引擎, 工作流引擎, 规则引擎等。

OFBiz是运行在JVM上面的,在这个JVM上有着一个Servlet container,它提供了创建和运行OFBiz web applications(检查webapps)的平台。传统的web开发中,如果我们要写webapps,就必须重写整个Servlet;而对于OFBiz,我们只需要写好相关的Java方法,让OFbiz的controller servlet来调用即可,除此之外,OFBiz还可以调用Event, Service甚至java程序。(Cook book, P32)

OFBiz is aimed primarily at ecommerce businesses, giving easily customizable tools such as a full Warehouse Management System (WMS), an accounting system and full order and product management systems

  • Servlet

servlet是在服务器上运行的小程序。这个词是在Java applet的环境中创造的,Java applet是一种当作单独文件跟网页一起发送的小程序,它通常用于在客户端运行,结果得到为用户进行运算或者根据用户互作用定位图形等服务。

servlet介于客户端与服务器之间。它的工作流程如下:1、客户端发送请求到服务器;2、服务器收到请求后,把请求信息发给servlet。3、servlet根据请求信息,生成的相应动态内容。4、服务器把相应发送给客户端。

可以这样理解,Servlet可以根据用户的不同请求动态地生成网页

  • Component

OFBiz files are organized according to components, with each component being contained in a single folder。

Each OFBiz component is pretty much self-contained (other than for its relationships with other components). Each OFBiz component has data entity definitions, view definitions, flow definitions (concepts touched on tangentially in the section called "Doing Our First Customization"), the whole works. Yet, OFBiz components often need to work with each other.

An OFBiz component by itself cannot be accessed by end-users.

  • Webapp

Because an OFBiz component by itself cannot be accessed by end-users. It is simply a means of organizing OFBiz into individual parcels focused on dealing with individual aspects of ERP software. Webapps or web applications provide the front-end through which end-users can work with and use OFBiz.

Think of a webapp as an individual "office opened for service". Such a virtual "office" can recognize and respond to several different "requests" (listed as request maps in controller.xml).

Typically, each OFBiz component has one webapp, but can actually have more.

  • ECA(Event Condition Action)

It is a combinition of 3 things: an eventconditions per event, and actions per event. It is a rule used to trigger an action upon the execution of an event when certain conditions are met. When a service is called for example a lookup is performed to see if any ECAs are defined for this event. 

我的理解就是在ECA这里进行条件的判断,如果满足就会执行一个service或者event。他就是一个trigger的作用,对于SECA (Service Event Condition Action)来说,This is used when we want to trigger another service(action) on the execution of a service when certain conditions are met.对于EECA (Entity Event Condition Action)来说,This is used when we want to trigger a service on the creation of a record for an entity when certain conditions are met.

ECA就像监听一样,当发现满足一定的条件时候,就会运行,启动某一项服务之类的。

对于SECA来说,当某一项步骤运行时候如果满足某些条件,就会运行

对于EECA来说,当对某个Entity的操作满足某些条件,就会运行

  • Service for OFBiz

Services are defined as independent pieces of logic which when placed together can be used to process many different types of business requirements. Services can be of many different types: Workflow, Rules, Java, SOAP, BeanShell, etc. 

A service with the type Java is much like an event where it is a static method

Services have the ability to call other services. So, chaining small services together to accomplish a larger task makes reusing existing services much easier. 

Services which are declared in a component (service-resource in ofbiz-component.xml file) are reachable from anywhere in OFBiz,and even outside using the export feature. it's also possible to create services which are specific to an application: restricted to be available only in that application. For that, you put the service definition and implementation files under the WEB-INF directory.
 
Service的格式:
<service name="userLogin" engine="java"
 location="org.ofbiz.commonapp.security.login.LoginServices" invoke="userLogin">
 <description>Authenticate a username/password; create a UserLogin object</description>
 <attribute name="login.username" type="String" mode="IN"/>
 <attribute name="login.password" type="String" mode="IN"/>
 <attribute name="userLogin" type="org.ofbiz.entity.GenericValue" mode="OUT" optional="true"/>
</service>

SERVICE ELEMENT:

 

  • name - The unique name of the service
  • engine - The name of the engine (defined in servicesengine.xml),可以为已有的,也可以为自己写的
  • location - The location or package of the service's class
  • invoke - The method name of the service
  • auth - Does this service require authorization (true/false)
  • export - Is this service allowed to be accessed via SOAP/HTTP/JMS (true/false)
  • validate - Do we validate the attributes found below for name and type matching (true/false)

 

IMPLEMENTS ELEMENT:

 

  • service - The name of the service which this service implements. All attributes are inherited

 

ATTRIBUTE ELEMENT:

 

  • name - The name of this attribute
  • type - The object type (String, java.util.Date, etc.)
  • mode - Is this an input or output parameter or both (IN/OUT/INOUT)
  • optional - Is this parameter optional (true/false)

    *underlined values are defaults 

  • Service Engine

This is where the service is actually invoked. Each service has an engine name assigned in its definition. This engine name is mapped via the servicesengine.xml file and is instantiated by the GenericEngineFactory when called upon

我的理解Service Engine是调用Service的地方

  • Entity

Entity is a piece of data defined by a set of fields and a set of relations to other entities.

In Java files, all value objects are generic, using a map to store the fields values of the entity instance by name. The get and set methods for the fields take a String with the fieldName in it which is used to verify that the field is part of the entity, and then either get or set a value as desired.

Entity definitions are read from an XML file.These XML entity definitions specify the names of all of the entities and their fields along with which database tables and columns they correspond to. They are also used to specify a type for each field to find the Java and SQL data types.Relations between entities are also defined in this XML file.

entity的定义示例:

<entity title="Sample Entity"
            copyright="Copyright (c) 2001 John Doe Enterprises"
            author="John Doe" version="1.0"
            package-name="org.ofbiz.commonapp.sample"
            entity-name="SampleEntity"
            table-name="SAMPLE_ENTITY">
      <field name="primaryKeyFieldOne" col-name="PRIMARY_KEY_FIELD_ONE" type="id-ne"></field>
      <field name="primaryKeyFieldTwo" type="id-ne"></field>
      <field name="fieldOne" type="long-varchar"></field>
      <field name="fieldTwo" type="long-varchar"></field>
      <field name="foreignKeyOne" type="id"></field>
      <prim-key field="primaryKeyFieldOne" />
      <prim-key field="primaryKeyFieldTwo" />
      <relation type="one" rel-entity-name="OtherSampleEntity">
        <key-map field-name="foreignKeyOne" rel-field-name="primaryKeyOne" />
      </relation>
      <relation type="one" title="Self" rel-entity-name="SampleEntity">
        <key-map field-name="primaryKeyFieldOne" />
        <key-map field-name="primaryKeyFieldTwo" />
      </relation>
      <relation type="many" title="AllOne" rel-entity-name="SampleEntity">
        <key-map field-name="primaryKeyFieldOne" />
      </relation>
</entity>

 

 

  • col-name and the table-name - optional,就像primaryKeyFieldOne有col-name,其他field就没有
  • Table and column names - 全部大写,单词之间用下划线隔开,如:SAMPLE_ENTITY,FIELD_ONE
  • Entity and field names -像Java一样中的驼峰命名法一样,不过区别在于Entity names correspond to Java classes的首个字母是大写的,如SampleEntity;而field names correspond to member fields of a class首个字母是小写的,如fileOne
  • <prim-key> - 用来描述主键,多个主键可以有多个 <prim-key>tag
  • type - 在此xml中都是string,但后面可以通过fieldtypemodel XML文件将其映射到具体的Java类型和数据库类型
  • 具体的标签对应的内容及意义可以见文档:http://ofbiz.apache.org/docs/entity.html
 
需要了解的是:由于OFBiz已经为我们提供了相当多的entity的model,我们很少要自己去定义entity,我们做的更多的是extend已有的entity!

 

  • Entity Engine

The Open For Business Entity Engine is a set of tools and patterns used to model and manage entity specific data.

 The primary goal of the entity engine is to eliminate the need for entity specific persistence code in as many areas of a transactional application as possible

 Code that uses the Entity Engine APIs can be easily created and modified, and interact with entities can be deployed in various ways.

 在model一个entity的时候,entity engine使用两个xml文件来描述这个entity,one for entity modeling and the other for field type modeling。这样做的原因是file的type在不同数据库中有着不同的定义,将类型单独放在一个文件中易于修改。

  • 端口号

The port will be 8080 for protocol http (unsecured access), and 8443 for https (secured access). Therefore, in this book, all URLs to OFBiz will start withhttp://localhost:8080/ or https://localhost:8443/ .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值