appgen分析

appfusegen分析
1、./properties/appfuse/generator.properties分析

 # @(#)generator.properties
 ### Appliction Settings ###
 #框架名稱,在運行com.codegenerator.runner.AppFuseGenerator時,作爲args[]的參數被傳入。此名稱決定了配置文件及模板文件
的存放路徑。如框架名爲appfuse,則相關的文件夾爲:properties/appfuse、templates/appfuse

 framework=appfuse
 appname=appfuse_joa
 ### If custom managers are not required uncomment the exclude parameter
 ### 用於配置哪些代碼包不需要生成
 #exclude=Manager,Dao,hibernate.xml.beansvm,service

 ### If only the tbl class is required uncomment the include parameter
 # 用於配置需要生成的代碼包
 #include=Tbl
 ### Single key generator class and types are as below
 singleKeyGenerator=increment:Long,Integer,Short

 ### Default Package Prefix and Default package location
 ## 配置默認的包前綴及包的位置信息
 packageLocation=com/zytech
 packagePrefix=com.zytech

 templateLocation=.//templates

 ### Anything that matches keys in fileLocations goes into this directory
 ## 代碼輸出目錄
 javaOutputLocation=d://temp//appfuse_joa//

 ### Otherwise if no match default output directory is here
 defaultOutputLocation=..//generated//

 ###  These three resolver properties files customize the output file locations
 ###  package names and Field types
 fileLocationResolver=FileLocations
 fileNameResolver=FileNames
 packageNameResolver=PackageNames
 #fieldTypeResolver=FieldTypes

 ### Controller Settings [Pick one of Struts|Spring|WebWork|Tapestry|Jsf] ###
 ## 設定需要生成哪個MVC的代碼,及代碼模板
 # [All] - common templates required for all MVC frameworks
 velocityListCommon=CommonTemplates

 # [Struts]
 #velocityListStruts=StrutsTemplates

 # [String]
 #velocityListSpring=SpringTemplates

 # [WebWork]
 velocityListWebwork=WebworkTemplates

 # [JSF]
 #velocityListJsf=JsfTemplates

 # [Tapestry]
 #velocityListTapestry=TapestryTemplates

 ### Database Settings ###
 # 數據庫配置
 # [All Databases]
 dbUserid=ZYOA
 dbPasswd=ZYOA
 dbSchema=ZYOA

 # [DB2]
 #jdbcDriver=COM.ibm.db2.jdbc.app.DB2Driver
 #dbUrl=jdbc:db2:d2spdvt

 # [Oracle]
 #jdbcDriver=oracle.jdbc.driver.OracleDriver
 #dbUrl=jdbc:oracle:thin:@192.168.1.199:1521:orcl

 # [MySQL]
 jdbcDriver=com.mysql.jdbc.Driver
 dbUrl=jdbc:mysql://localhost:3306/ZYOA

 # [HSQL]
 #jdbcDriver=org.hsqldb.jdbcDriver
 #dbUrl=jdbc:hsqldb:file:d://hsqldb//data//testdb

 # [PostgreSQL]
 #jdbcDriver=org.postgresql.Driver
 #dbUrl=jdbc:postgresql://localhost/mydatabase


 ### Mail Settings ###
 # 代碼中的author備註信息
 [email protected]
 mailName=xiangchunke

 #[email protected]
 #mailName=Nathan Anderson

2、oracle下速度特別慢的原因:
 在生成getPrimaryKeys()時特別慢,不知怎麼回事
 後經考證:是oracle的問題,家裏不正常,公司正常

3、中文問題
 在VM中使用了中文,生成的代碼卻是亂碼。
 解決辦法:修改velocity的編碼。但是.properties文件中的中文卻還沒辦法


 private void initVelocity(String templateDirectory) throws Exception {
     // Init Velocity
  
     Properties p = new Properties();
     // 設置模板路徑
  p.put("file.resource.loader.path",templateDirectory);
     //設置velocity的輸入輸出編碼轉換
     p.setProperty("output.encoding", "gb2312");
     p.setProperty("input.encoding", "iso-8859-1");//輸入的編碼   
     vengine = new VelocityEngine();
     vengine.init( p );
   }

4、現在所剩問題:
 在生成XML文件時,將文件內容追加進去。而不是文件存在就不再生成


5、各properties配置文件內容說明
 CommonTemplates.properties: 基本代碼的vm模板名稱配置,對應於templates/appfuse/common
 FileLocations.properties: 各種生成的代碼文件的輸出路徑
 FileNames.properties:  暫時不知用途
 generator.properties:  整個系統的配置。主要是包、輸出位置、數據庫聯接信息
 PackageNames.properties: 各個數據庫表生成的代碼所屬的包名

 JsfFileLocations.properties JsfTemplates.properties :JSF系統的配置信息
 SpringTemplates.properties  StrutsTemplates.properties  TapestryTemplates.properties
TapestryFileLocations.properties:  各種MVC框架的配置文件
 


6、templates文件夾下的文件
 爲velocity模板文件。改變生成的代碼,主要是修改這些文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章