开始的一些知识和概念
- B/S架構(gòu)
用戶工作界面是通過WWW瀏覽器來實(shí)現(xiàn),極少部分事務(wù)邏輯在前端(Browser)實(shí)現(xiàn),但是主要事務(wù)邏輯在服務(wù)器端(Server)實(shí)現(xiàn),形成所謂三層3-tier結(jié)構(gòu)。相對(duì)于C/S結(jié)構(gòu)屬于“胖”客戶端,需要在使用者電腦上安裝相應(yīng)的操作軟件來說,B/S結(jié)構(gòu)是屬于一種“瘦”客戶端,大多數(shù)或主要的業(yè)務(wù)邏輯都存在在服務(wù)器端,因此,B/S結(jié)構(gòu)的系統(tǒng)不需要安裝客戶端軟件,它運(yùn)行在客戶端的瀏覽器之上,系統(tǒng)升級(jí)或維護(hù)時(shí)只需更新服務(wù)器端軟件即可
- OFBiz
OFBiz(The ApacheOpen For Business Project )是開放的電子商務(wù)平臺(tái),是一個(gè)非常著名的開源項(xiàng)目,提供了創(chuàng)建基于最新J2EE/XML規(guī)范和技術(shù)標(biāo)準(zhǔn),構(gòu)建大中型企業(yè)級(jí)、跨平臺(tái)、跨數(shù)據(jù)庫(kù)、跨應(yīng)用服務(wù)器的多層、分布式電子商務(wù)類WEB應(yīng)用系統(tǒng)的框架。 OFBiz最主要的特點(diǎn)是OFBiz提供了一整套的開發(fā)基于Java的web應(yīng)用程序的組件和工具。包括實(shí)體引擎, 服務(wù)引擎, 消息引擎, 工作流引擎, 規(guī)則引擎等。
OFBiz是運(yùn)行在JVM上面的,在這個(gè)JVM上有著一個(gè)Servlet container,它提供了創(chuàng)建和運(yùn)行OFBiz web applications(檢查webapps)的平臺(tái)。傳統(tǒng)的web開發(fā)中,如果我們要寫webapps,就必須重寫整個(gè)Servlet;而對(duì)于OFBiz,我們只需要寫好相關(guān)的Java方法,讓OFbiz的controller servlet來調(diào)用即可,除此之外,OFBiz還可以調(diào)用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是在服務(wù)器上運(yùn)行的小程序。這個(gè)詞是在Java applet的環(huán)境中創(chuàng)造的,Java applet是一種當(dāng)作單獨(dú)文件跟網(wǎng)頁(yè)一起發(fā)送的小程序,它通常用于在客戶端運(yùn)行,結(jié)果得到為用戶進(jìn)行運(yùn)算或者根據(jù)用戶互作用定位圖形等服務(wù)。
servlet介于客戶端與服務(wù)器之間。它的工作流程如下:1、客戶端發(fā)送請(qǐng)求到服務(wù)器;2、服務(wù)器收到請(qǐng)求后,把請(qǐng)求信息發(fā)給servlet。3、servlet根據(jù)請(qǐng)求信息,生成的相應(yīng)動(dòng)態(tài)內(nèi)容。4、服務(wù)器把相應(yīng)發(fā)送給客戶端。
可以這樣理解,Servlet可以根據(jù)用戶的不同請(qǐng)求動(dòng)態(tài)地生成網(wǎng)頁(yè)
-
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?event,?conditions?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這里進(jìn)行條件的判斷,如果滿足就會(huì)執(zhí)行一個(gè)service或者event。他就是一個(gè)trigger的作用,對(duì)于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.對(duì)于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就像監(jiān)聽一樣,當(dāng)發(fā)現(xiàn)滿足一定的條件時(shí)候,就會(huì)運(yùn)行,啟動(dòng)某一項(xiàng)服務(wù)之類的。
對(duì)于SECA來說,當(dāng)某一項(xiàng)步驟運(yùn)行時(shí)候如果滿足某些條件,就會(huì)運(yùn)行
對(duì)于EECA來說,當(dāng)對(duì)某個(gè)Entity的操作滿足某些條件,就會(huì)運(yùn)行
-
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是調(diào)用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一樣中的駝峰命名法一樣,不過區(qū)別在于Entity names correspond to Java classes的首個(gè)字母是大寫的,如SampleEntity;而field names correspond to member fields of a class首個(gè)字母是小寫的,如fileOne
- <prim-key> -?用來描述主鍵,多個(gè)主鍵可以有多個(gè)?<prim-key>tag
- type -?在此xml中都是string,但后面可以通過fieldtypemodel XML文件將其映射到具體的Java類型和數(shù)據(jù)庫(kù)類型
- 具體的標(biāo)簽對(duì)應(yīng)的內(nèi)容及意義可以見文檔:http://ofbiz.apache.org/docs/entity.html
?
-
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一個(gè)entity的時(shí)候,entity engine使用兩個(gè)xml文件來描述這個(gè)entity,one for entity modeling and the other for field type modeling。這樣做的原因是file的type在不同數(shù)據(jù)庫(kù)中有著不同的定義,將類型單獨(dú)放在一個(gè)文件中易于修改。
-
端口號(hào)
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/?.
轉(zhuǎn)載于:https://www.cnblogs.com/ztk3939339/archive/2012/07/09/2582296.html
總結(jié)
以上是生活随笔為你收集整理的开始的一些知识和概念的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SharePoint服务器修改域和机器名
- 下一篇: 基于struts2+hibernate+