Be alaways javaing...

          Loving Java
          posts - 43, comments - 5, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          一.配置

          1framework下的entity里的config里面打開entityengine.xml文件在此文件里找有四行都是以<delegator name開頭的,請將里面的datasource-name="localderby"都改為datasource-name="localmysql"

          2在此文件里找到〈datasource-name="localmysql"開頭的代碼區域,將里面的jdbc-username= jdbc-password= 都改為你安裝mysql時的用戶名和密碼。

          3我們要在entity下的lib下的jdbc中導入mysql5.0的驅動,同時加入xapool.jar

              4)mysql中建ofbiz數據庫,否則在下面部署工程中報錯

              二.部署

              1) 在命令行下運行 ant run-install

                  (前提:在環境變量中添加 ant\bin)

          2) 運行 startofbiz.bat

           

          三. 工程端口號的修改

            修改framework/base/config/ofbiz-containers.xml

          1)  修改ofbiz端口號

              <property name="http-connector" value="connector">

                      <property name="port" value="8080"/>

                </property>

           

            2)修改項目鏈接的端口號

          <property name="https-connector" value="connector">

                    <property name="port" value="8443"/>

           </property>

           

          四.運行

           在瀏覽器中輸入地址 http://localhost:8080

           



          posted @ 2008-09-11 11:44 追風舞者 閱讀(2144) | 評論 (0)編輯 收藏

          1.實體引擎核心應用類(客戶端API)
          涉及到12 個類:GenericDelegator,GenericValue,GenericPK,EntityCondition,
          EntityExpr,EntityFieldMap,EntityConditionList,EntityWhereString,EntityOperator,
          EntityListIterator,這些類都是為GenericDelegator 的接口服務的。用
          戶端程序和數據庫之間的所有交往多是通過“GenericDelegator”完成的。

          2.服務引擎應用類(服務器端API)
          涉及LocalDispatcher, GenericDispatcher; ServiceDispatcher;ServiceUtil;
          DispatchContext ;ServiceConfigUtil 等6 個類。

          3.常用工具類
          工具類主要在包org.ofbiz.core.util 中。
          1、 屬性文件訪問工具類:UtilProperties。
          2、 Map、List 對象操作工具類:UtilMisc。
          3、 UtilFormatOut :通用格式化輸出工具類(主要用在 Jsp 文件或View Helper 中)。
          4、 UtilURL:得到文件流的URL 地址類。
          5、 UtilCache:緩存管理類。
          6、 UtilValidate:通用數據輸入輸出數據校驗(合法性和有效性)類,可任意擴展。.
          7、 UtilDateTime:java.util.Date 和java.sql.Date 格式的日期/時間處理類。
          8、 StringUtil:增強的字符串處理類。
          9、 UtilXML:增強的符合JAXP & DOM 規范的XMl 解析器處理工具類。
          10、 SiteDefs:常數定義類,定義所有Web 程序用到的和環境有關的常量。
          11、 Debug:格式化輸出程序調試信息類。
          12、 HttpClient:模擬一個HttpServlet 請求類。
          13、 HttpRequestFileUpload:接受一個通過Http 上傳的文件工具類。
          14、 SendMailSMTP:符合SMTP 協議的郵件發送處理類(實現發送郵件服務器的功能)。

          posted @ 2008-09-10 16:33 追風舞者 閱讀(145) | 評論 (0)編輯 收藏

          1. entitymodle.xml中的字段類型參見 opentaps-1.0\framework\entity\fieldtype
               比較常見的字段類型定義如下:
                   <field-type-def type="id-ne" sql-type="VARCHAR(20)" java-type="String">
                              <validate method="isNotEmpty" />
                  </field-type-def>
                   <field-type-def type="id" sql-type="VARCHAR(20)" java-type="String"></field-type-def>
                   <field-type-def type="comment" sql-type="VARCHAR(255)" java-type="String"></field-type-def>
                  <field-type-def type="description" sql-type="VARCHAR(255)" java-type="String"></field-type-def>
                  <field-type-def type="name" sql-type="VARCHAR(100)" java-type="String"></field-type-def>
                  <field-type-def type="value" sql-type="VARCHAR(255)" java-type="String"></field-type-def>

          entity

          Attribute Name Required? Description
          entity-name Y The name of the entity as it is referred to when using the Entity Engine Java API and various other places in the Entity Engine.
          table-name N The name of the database table that corresponds to this entity. This attribute is optional and if not specified the table name will be derived from the entity name.
          package-name Y The name of the package that this entity is contained in. With hundreds of entities in a large data model this is used to organize and structure the entities definitions.
          dependent-on N This can be used to specify a parent entity or an entity that this entity is dependent on. This is currently not used for anything automated in the Entity Engine, but can be used to specify an heirarchical entity structure.
          enable-lock N Specifies whether or not optimistic locking should be used for this entity. The lastUpdatedStamp field must exist on the entity and will be used to keep track of the last time the entity instance was updated. If the current instance to be updated does not have a matching lastUpdatedStamp an EntityLockedException will be thrown. Must be true or false. Defaults to false.
          never-cache N If this is set to true caching of this entity will not be allowed. Automatic cache clearing will not be done to improve efficiency and any attempt to use the cache methods on the entity will result in an exception so that it is easier to find and eliminate where this is being done. Must be true or false. Defaults to false.
          title N A title for the entity. If not specified defaults to the global setting for the file the entity is in.
          copyright N The copyright of the entity. If not specified defaults to the global setting for the file the entity is in.
          author N The author of the entity. If not specified defaults to the global setting for the file the entity is in.
          version N The version of the entity. If not specified defaults to the global setting for the file the entity is in.
          Sub-Element Name How Many Description
          description 0 or 1 A description of the entity. If not specified defaults to the global setting for the file the entity is in. This element has no attributes and should contain only a simple string of characters.
          field 1 to many Used to declare fields that are part of the entity.
          prim-key 0 to many Used to declare which fields are primary keys
          relation 0 to many Used to declare relationships between entities.

          field

          Attribute Name Required? Description
          name Y The name of the field that is used to refer to it in Java code and other places.
          col-name N The name of the corresponding database column. This is not required and if not specified this will be derived from the field name.
          type Y The type of the field. This is looked up in the field types file for the current datasource at run-time to determine the Java and SQL types for the field and database column.

          Sub-Element Name How Many Description
          validate 0 to many Each validate element has a single attribute called name which specifies the name of the validation method to call. These methods are not called in all Entity Engine operations and are only used for generic user interfaces like the Entity Data Maintenance pages in WebTools.

          prim-key

          Attribute Name Required? Description
          field Y The name of the field that will be part of the primary key.

          relation

          Attribute Name Required? Description
          type Y Specifies the type of the relationship including the cardinality of the relationship (in one direction) and if a foreign key should be created for cardinality one relationships. Must be "one", "one-nofk", or "many".
          title N Because you may want to have more than one relationship to a single entity this attribute allows you to specify a title that will be prepended to the rel-entity-name to make up the name of the relationship. If not specified the rel-entity-name alone will be used as the relationship name.
          rel-entity-name Y The name of the related entity. The relationship goes from this entity to the related entity.
          fk-name N The foreign key name can be created automatically from the relationship name, but this is not recommended for two reasons: many databases have a very small maximum size (like 18 characters) for foreign key and index names, and many databases require that the FK name be unique for the entire database and not just for the table the FK is coming from.

          Sub-Element Name How Many Description
          key-map 1 to many The key-map is used to specify a field in this entity that corresponds to a field in the related entity. This element has two attributes: field-name and rel-field-name. These are used to specify the name of the field on this entity and the corresponding name of the field on the related entity.

          更加詳細的內容參照: http://ofbiz.apache.org/docs/entity.html

          posted @ 2008-09-09 10:25 追風舞者 閱讀(726) | 評論 (0)編輯 收藏

          1.將Opentaps項目導入Eclipse中
              Filee -> Import -> General -> Existing Projects into Workspace
          2.Eclipse中為.bsh,.ftl文件添加編輯器
            安裝Freemarker Eclipse plug-in.
            Windows > Preferences > General > Editors > File Associations and add "*.bsh" and associate it with the Scrapbook editor.
          3.修改 startofbiz.bat文件

          ECHO OFF
          REM ####################################################
          REM Licensed to the Apache Software Foundation (ASF) under one
          REM or more contributor license agreements.  See the NOTICE file
          REM distributed with this work for additional information
          REM regarding copyright ownership.  The ASF licenses this file
          REM to you under the Apache License, Version 2.0 (the
          REM "License"); you may not use this file except in compliance
          REM with the License.  You may obtain a copy of the License at
          REM
          REM http://www.apache.org/licenses/LICENSE-2.0
          REM
          REM Unless required by applicable law or agreed to in writing,
          REM software distributed under the License is distributed on an
          REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
          REM KIND, either express or implied.  See the License for the
          REM specific language governing permissions and limitations
          REM under the License.
          REM ########################################################
          ECHO ON

          "%JAVA_HOME%\bin\java" -Xms256M -Xmx512M -Duser.language=en -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar ofbiz.jar > runtime\logs\console.log


          4.Eclipse菜單 Run -> Open Debug Dialog
             選擇 Remote Java Application 
              注意: 右側面板中的 Port 為上面紅色標記,兩者必需一致。





          posted @ 2008-09-08 18:23 追風舞者 閱讀(2075) | 評論 (0)編輯 收藏

          1.OfBiz中利用delegator訪問數據庫

          1)創建GenericDelegator對象
            1.1 service中
            public static Map createHelloPerson(DispatchContext dctx, Map context) {
                    GenericDelegator delegator = dctx.getDelegator();
               ...
            }
            1.2手工建立GenericDelegator對象
            GenericDelegator delegator = GenericDelegator.getGenericDelegator("default");

          2)Insert a record
            通過調用delegator對象的getNextSeqId(), makeValue(String entityName, Map fields)和create()方法。
            例如:
                 String helloPersonId = delegator.getNextSeqId("HelloPerson");
              GenericValue helloPerson = delegator.makeValue("HelloPerson",
                              UtilMisc.toMap("helloPersonId", helloPersonId)); // create a GenericValue from ID we just got
                helloPerson.setNonPKFields(context); // move non-primary key fields from input parameters to GenericValue
              delegator.create(helloPerson); // store the generic value, ie persists it
             
          3)Remove a record
              delegator.removeByAnd(String entityName, Map fields);
             
          4)Strore a record
              例如:
                Map pk = UtilMisc.toMap("attribute1", attribute1Value, "attribute2", attribute2Value);//pk中存儲了查詢條件
              GenericValue obj = delegator.findByPrimaryKey("ClassName", pk);
                obj.setNonPKFields(context);//contex為Map類型,存儲了要更新的字段
              obj.store();

          5)Store records
              List resultList = delegator.findAll(String entityName, List orderBy);
              List toStore = new ArrayList();
              toStore.addAll(resultList);
              delegator.storeAll(toStore);
             
          6)Look for record/records
               findByAnd,findByCondition、findByLike、findByOr、findByPrimaryKey、
               findListIteratorByCondition、 findall、findAllByPrimaryKeys
              
          2) 依據數值對象進行訪問
              在現有的數值對象(GenericValue類型)上可以進行下列操作:
                  根據關系查找關聯信息getRelated,包括getRelated、getRelatedByAnd、getRelatedDummyPK、getRelatedMulti、getRelatedOrderBy。
                  刷新本數值對象refresh
                  保存本數值對象store,主要用于修改后的保存
                  刪除數值對象remove,包括刪除本數值對象remove和刪除某個關聯的數值對象removeRelated
                  在現有數值對象上的操作是通過調用
             
              更加具體的信息可參考:http://www.opentaps.org/javadocs/release-1.0.1/framework/api/


          posted @ 2008-09-08 17:59 追風舞者 閱讀(1238) | 評論 (0)編輯 收藏

          http://www.opensourcestrategies.com/ofbiz/tutorials.php
          http://ofbiz.apache.org/
          http://www.opentaps.org/index.php
          http://docs.ofbiz.org/display/OFBADMIN/OFBiz+Documentation+Index
          尤其是第一個里面有很多不錯的文章,不過都是英文的,耐心的看下去吧。

          posted @ 2008-09-05 15:07 追風舞者 閱讀(256) | 評論 (0)編輯 收藏

                Java語言中的equals的規范:

                    1. 自反性:對于任何一個非空引用xx.equals(x)應該返回true
              2. 對稱性:對于任何引用xy,如果x.equals(y)返回true,那么y.equals(x)也應該返回true
              3. 傳遞性:對于任何引用xyz,如果x.equals(y)返回truey.equals(z)返回true,那么x.equals(z)也應該返回true
              4. 一致性:如果xy引用的對象沒有發生變化,那么反復調用x.equals(y)應該返回同樣的結果。
              5. 對于任何非空引用xx.equals(null)應該返回false

           public boolean equals(Object obj) {
            boolean result = false;
            if (this == obj)
             return true;
            if (!(obj instanceof Student))
             return false;
            Student objTemp = (Student) obj;
            if (this.getId() == objTemp.getId())
             result = true;
            return result;
           }

          Java語言中的hashcode:

            1. 將一個非0常數,例如17,儲存于int result變量中。
            2. 對對象中的每一個有意義的字段f(更確切地說是被equals()所考慮的每一個字段)進行如下處理:
              A. 對這個字段計算出型別為int的hash 碼 c:
                i. 如果字段是個boolean,計算(f ? 0 : 1)。
                ii. 如果字段是個byte,char,short或int,計算(int)f。
                iii. 如果字段是個long,計算(int)(f^(f >>> 32))。
                iv. 如果字段是個float,計算Float.floatToIntBits(f)。
                v. 如果字段是個double,計算Double.doubleToLongBits(f),然后將計算結果按步驟2.A.iii處理。
                vi. 如果字段是個object reference,而且class 的equals()透過「遞歸呼叫equals()」的方式來比較這一字段,那么就同樣也對該字段遞歸呼叫hashCode()。
                vii. 如果字段是個array,請將每個元素視為獨立字段。也就是說對每一個有意義的元素施行上述規則,用以計算出hash 碼,然后再依步驟2.B將這些數值組合起來。
              B. 將步驟A計算出來的hash碼 c按下列公式組合到變量result中:result = 37*result + c;
           3. 傳回result。
           4. 完成hashCode()之后,反躬自省一下:是否相等的實體具有相等的hash 碼?如果不是,找出原因并修正問題。

          posted @ 2008-08-04 14:38 追風舞者 閱讀(199) | 評論 (0)編輯 收藏

               摘要: 前人栽樹,后人乘涼。想當初自己初學Java時為了解決一個很基礎的問題,好多的朋友熱心的回復我,幫我分析錯誤。現在為了方便那些Java新手,特給出自己感覺比較好的學習網站和論壇,希望對朋友們能有點幫助。
          1,http://www.javaeye.com/ 由Robbin創建發起的技術網站,人氣相當旺,有不少牛人。最初是以討論Java技 術和Hibernate技術開始的技術論壇,現在已經成為一個涵蓋整個軟件開發領域的綜合性網站,2005年被選為中國十佳技術網站之一。
          2,http://www.ibm.com/developerworks/cn/java/ 著名的IBM Developer Works。涵蓋各種技術。
          3,http://dev2dev.bea.com.cn/ IBM和BEA都在主推Java應用。它們的技術網站中有不少關于Java的好文章。
          ………………  閱讀全文

          creasure 2008-07-08 20:19 發表評論

          文章來源:http://www.aygfsteel.com/creasure/archive/2008/07/08/213420.html

          posted @ 2008-07-10 09:48 追風舞者 閱讀(81) | 評論 (0)編輯 收藏

          Eclipse 常用快捷鍵
          Eclipse的編輯功能非常強大,掌握了Eclipse快捷鍵功能,能夠大大提高開發效率。Eclipse中有如下一些和編輯相關的快捷鍵。
             1. 【ALT+/】
             此快捷鍵為用戶編輯的好幫手,能為用戶提供內容的輔助,不要為記不全方法和屬性名稱犯愁,當記不全類、方法和屬性的名字時,多體驗一下【ALT+/】快捷鍵帶來的好處吧。
             2. 【Ctrl+O】
             顯示類中方法和屬性的大綱,能快速定位類的方法和屬性,在查找Bug時非常有用。

             3. 【Ctrl+/】
             快速添加注釋,能為光標所在行或所選定行快速添加注釋或取消注釋,在調試的時候可能總會需要注釋一些東西或取消注釋,現在好了,不需要每行進行重復的注釋。

             4. 【Ctrl+D】
             刪除當前行,這也是筆者的最愛之一,不用為刪除一行而按那么多次的刪除鍵。

             5. 【Ctrl+M】
             窗口最大化和還原,用戶在窗口中進行操作時,總會覺得當前窗口小(尤其在編寫代碼時),現在好了,試試【Ctrl+M】快捷鍵。

             查看和定位快捷鍵

             在程序中,迅速定位代碼的位置,快速找到Bug的所在,是非常不容易的事,Eclipse提供了強大的查找功能,可以利用如下的快捷鍵幫助完成查找定位的工作。

             1. 【Ctrl+K】、【Ctrl++Shift+K】
             快速向下和向上查找選定的內容,從此不再需要用鼠標單擊查找對話框了。

             2. 【Ctrl+Shift+T】
             查找工作空間(Workspace)構建路徑中的可找到Java類文件,不要為找不到類而痛苦,而且可以使用“*”、“?”等通配符。

             3. 【Ctrl+Shift+R】
             和【Ctrl+Shift+T】對應,查找工作空間(Workspace)中的所有文件(包括Java文件),也可以使用通配符。

             4. 【Ctrl+Shift+G】
             查找類、方法和屬性的引用。這是一個非常實用的快捷鍵,例如要修改引用某個方法的代碼,可以通過【Ctrl+Shift+G】快捷鍵迅速定位所有引用此方法的位置。

             5. 【Ctrl+Shift+O】
          快速生成import,當從網上拷貝一段程序后,不知道如何import進所調用的類,試試【Ctrl+Shift+O】快捷鍵,一定會有驚喜。

             6. 【Ctrl+Shift+F】
             格式化代碼,書寫格式規范的代碼是每一個程序員的必修之課,當看見某段代碼極不順眼時,選定后按【Ctrl+Shift+F】快捷鍵可以格式化這段代碼,如果不選定代碼則默認格式化當前文件(Java文件)。

             7. 【ALT+Shift+W】
             查找當前文件所在項目中的路徑,可以快速定位瀏覽器視圖的位置,如果想查找某個文件所在的包時,此快捷鍵非常有用(特別在比較大的項目中)。

             8. 【Ctrl+L】
             定位到當前編輯器的某一行,對非Java文件也有效。

             9. 【Alt+←】、【Alt+→】
             后退歷史記錄和前進歷史記錄,在跟蹤代碼時非常有用,用戶可能查找了幾個有關聯的地方,但可能記不清楚了,可以通過這兩個快捷鍵定位查找的順序。

             10. 【F3】
          快速定位光標位置的某個類、方法和屬性。

             11. 【F4】
             顯示類的繼承關系,并打開類繼承視圖。

             調試快捷鍵

             Eclipse中有如下一些和運行調試相關的快捷鍵。

             1. 【Ctrl+Shift+B】:在當前行設置斷點或取消設置的斷點。
             2. 【F11】:調試最后一次執行的程序。
             3. 【Ctrl+F11】:運行最后一次執行的程序。
             4. 【F5】:跟蹤到方法中,當程序執行到某方法時,可以按【F5】鍵跟蹤到方法中。
             5. 【F6】:單步執行程序。
             6. 【F7】:執行完方法,返回到調用此方法的后一條語句。
             7. 【F8】:繼續執行,到下一個斷點或程序結束。

             常用編輯器快捷鍵

             通常文本編輯器都提供了一些和編輯相關的快捷鍵,在Eclipse中也可以通過這些快捷鍵進行文本編輯。
             1. 【Ctrl+C】:復制。
             2. 【Ctrl+X】:剪切。
             3. 【Ctrl+V】:粘貼。
             4. 【Ctrl+S】:保存文件。
             5. 【Ctrl+Z】:撤銷。
             6. 【Ctrl+Y】:重復。
             7. 【Ctrl+F】:查找。

             其他快捷鍵

             Eclipse中還有很多快捷鍵,無法一一列舉,用戶可以通過幫助文檔找到它們的使用方式,另外還有幾個常用的快捷鍵如下。
             1. 【Ctrl+F6】:切換到下一個編輯器。
             2. 【Ctrl+Shift+F6】:切換到上一個編輯器。
             3. 【Ctrl+F7】:切換到下一個視圖。
             4. 【Ctrl+Shift+F7】:切換到上一個視圖。
             5. 【Ctrl+F8】:切換到下一個透視圖。
             6. 【Ctrl+Shift+F8】:切換到上一個透視圖。

             Eclipse中快捷鍵比較多,可以通過幫助文檔找到所有快捷鍵的使用,但要掌握所有快捷鍵的使用是不可能的,也沒有必要,如果花點時間熟悉本節列舉的快捷鍵,必將會事半功倍

          posted @ 2008-07-09 14:06 追風舞者 閱讀(226) | 評論 (0)編輯 收藏

               摘要: 速動畫教程第二十七集? SVN的安裝和配置 下載:請到?http://this.oksonic.cn 下載? 工具:...  閱讀全文

          oksonic 2007-02-10 09:56 發表評論

          文章來源:http://www.aygfsteel.com/oksonic/archive/2007/02/10/99100.html

          posted @ 2008-07-09 11:02 追風舞者 閱讀(131) | 評論 (0)編輯 收藏

          僅列出標題
          共5頁: 上一頁 1 2 3 4 5 下一頁 
          主站蜘蛛池模板: 武陟县| 临夏市| 泊头市| 黄陵县| 乌恰县| 万载县| 抚宁县| 始兴县| 黔西县| 平泉县| 定兴县| 溧阳市| 新兴县| 伊川县| 汶上县| 乌兰浩特市| 扎赉特旗| 阿尔山市| 扶余县| 互助| 浦北县| 上栗县| 昌平区| 沙坪坝区| 秭归县| 大港区| 仙游县| 保亭| 集贤县| 五家渠市| 高淳县| 湄潭县| 江华| 信阳市| 巴中市| 吉林省| 东阳市| 遂溪县| 金昌市| 囊谦县| 涿州市|