开始的一些知识和概念
- 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?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這里進行條件的判斷,如果滿足就會執行一個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
?
-
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/?.
轉載于:https://www.cnblogs.com/ztk3939339/archive/2012/07/09/2582296.html
總結
以上是生活随笔為你收集整理的开始的一些知识和概念的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SharePoint服务器修改域和机器名
- 下一篇: 基于struts2+hibernate+