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模板文件。改变生成的代码,主要是修改这些文件

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