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 追风舞者 阅读(2130) | 评论 (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 追风舞者 阅读(138) | 评论 (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 追风舞者 阅读(721) | 评论 (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 追风舞者 阅读(2053) | 评论 (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 追风舞者 阅读(1224) | 评论 (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 追风舞者 阅读(247) | 评论 (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 追风舞者 阅读(186) | 评论 (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.blogjava.net/creasure/archive/2008/07/08/213420.html

posted @ 2008-07-10 09:48 追风舞者 阅读(69) | 评论 (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 追风舞者 阅读(211) | 评论 (0)编辑 收藏

     摘要: 速动画教程第二十七集  SVN的安装和配置 下载:请到 http://this.oksonic.cn 下载  工具:...  阅读全文

oksonic 2007-02-10 09:56 发表评论

文章来源:http://www.blogjava.net/oksonic/archive/2007/02/10/99100.html

posted @ 2008-07-09 11:02 追风舞者 阅读(123) | 评论 (0)编辑 收藏

仅列出标题
共5页: 上一页 1 2 3 4 5 下一页