What is the appfuse

First, Appfuse brief introduction

Matt Raible are Appfuse developed a guiding entry-level J2EE framework, how to integrate its popular Spring, Hibernate, ibatis, struts, Xdcolet, junit, etc. give the basic framework of the model, the latest version 1.7 is provided on Taperstry and JSF support. In the persistence layer, AppFuse uses Hibernate O / R mapping tools (http://www.hibernate.org); in containers, it uses Spring Framework (http://www.springframework.org). Users can freely select Struts, Spring / MVC, Webwork, Taperstry, JSF several web framework. The use of TDD development mode, the use of JUnit tests on each floor, and even test jsp output w / o error. In order to simplify the development of a set of predefined good directory structure, base class, used to create databases, configure the Tomcat, the deployment of applications to test Ant tasks to help Express automatically generated source code and automatic maintenance of some configuration files.

At https: / / appfuse.dev.java.net / can download Appfuse, the current version is 1.7.
Appfuse reference materials and documentation can http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse view.

Second, Appfuse Framework Quick Start

AppFuse project's main objective is to help developers reduce the time a project at the beginning of the work to be done. The following is a use it to create a new project of the basic steps:

1, download or from CVS (cvs-d: pserver: guest@cvs.dev.java.net: / cvs co appfuse) detected in the latest version of appfuse source.

2, install J2SE 1.4 +, set the JAVA_HOME environment variable correctly, install Ant 1.6.2 +, set the ANT_HOME environment variable.

3, the installation of MySQL 3.23.x + (recommended version 4.1.7) and Tomcat 4.1.x + (recommended version 5.0.28), set the CATALINA_HOME environment variable to point to your Tomcat installation directory.

Note: If you are ready to use MySQL 4.1.7, then you must be the default character set is set to UTF-8 character set and its default table type to InnoDB type. In other words, you want in your c: \ Windows \ my.ini or / etc / my.cnf file add the following lines:
default-character-set = utf8
default-table-type = innodb

4, install a local SMTP server, or if you already have an available SMTP server, you can modify the mail.properties (in web / WEB-INF / classes directory) and build.properties (in the root directory -- - information for log4j) to point to your SMTP server - by default it is the point to your local SMTP server.

5, lib/junit3.8.1/junit.jar documents will be copied to the $ ANT_HOME / lib directory.

6, the implementation of ant new-Dapp.name = YOURAPPNAME-Ddb.name = YOURDBNAME command. This will create a file called "YOURAPPNAME" directory.

Warning: the order for some values will not implement the app.name - Do not use "test", containing "appfuse" in the name of one of you, or any figure, two book No. (-) and so on mixed up the names of .

7, to the new directory, the implementation of ant's mission to create a database setup, at the same time your application will be posted to the Tomcat server. Only when the root of your password database user does not have the mission will work. You can also open in the time required to change the build.properties file root user's password. If you want to test and would like to know whether all were able to work well, then you can run ant the test-all mission to conduct a comprehensive test - of course the premise that when you first make the time to test Tomcat server to stop.

8, implementation of test-reports of ant mission - when the mission after the implementation, there will be a message to tell you how to view those generated test reports.

When you sure you step through the above-configured your development environment after the AppFuse - below you need to do is study guide to learn about how to use AppFuse for your development.

Optional installation

If you are willing to choose to use iBATIS as the persistence layer framework for you, please take a look specifically extras / ibatis directory README.txt file.
If you are willing to choose to use Spring as your WEB layer framework, please take a look specifically extras / spring directory README.txt file.
If you are willing to choose to use WebWork as your WEB layer framework, please take a look specifically extras / webwork directory README.txt file.
Choose if you are willing to Tapestry as your web tier framework, please take a look specifically extras / tapestry directory README.txt file.
If you are willing to select JSF as your web tier framework, please take a look specifically extras / jsf directory README.txt file.

If you want you can through the script to automatically complete the creation and testing, you can refer to the following script:
rm-r .. / appfuse-spring
ant new-Dapp.name = appfuse-spring-Ddb.name = ibatis
cd .. / appfuse-spring
ant install-ibatis install-springmvc
cd extras / ibatis
ant uninstall-hibernate
cd ../..
ant setup
ant test-all test-reports

If you do not want to install iBATIS, Spring MVC or WebWork, you will be in your items before the warehouse code control, you should remove them in extras directory of the installation content.

-------------------------------------------------- ------------------------------

Typically, when you have completed all of the above steps and they can work, the most likely thing you would want to put "org.appfuse" package names changed to a similar "com.company" this kind of package names. Does this matter now has been very easy, all you need to do is to download a package of tools, take a look at its README file, in order to understand its installation and use.

Note: before you use this tool it is best to do your project will be a backup to ensure it is able to resume.

If you will read org.appfuse.webapp.form packages such as test.web.form such a package name, you have to go simultaneously tinkering src / service package ConverterUtil category, getOpposingObject Ways are your friends, let us look at click:

name = StringUtils.replace (name, "model", "webapp.form");
name = StringUtils.replace (name, "webapp.form", "model");

Three, AppFuse Development Guide

If you have already downloaded and AppFuse want in your machine to install it, you'd better get started quickly in accordance with the steps to install. Once you have installed all of the content, the following guidelines are studying how to use AppFuse you develop the best tutorials.

NOTE: AppFuse guide the development of the release contains a version of same, if you want to update your copy that works (which in the docs directory), can be through the implementation of "ant wiki" to complete.

For AppFuse 1.6.1, you can tell in this Guide Ways to generate most of your code. If you're using Struts + Hibernate such a combination, you can even generate them completely. And if you select the web tier framework of the Spring or WebWork is not so fortunate for them to write an automated installation scripts exist many difficulties, so you have to configure it yourself Controllers and Actions of those. This is mainly because I do not have the framework of these web layer using XDoclet, but also because of the use of Ant tools as the limitations caused by the installation tool. A tool for automatic generation of code called me AppGen, I explain in Part I of how to use it.

Part I: in AppFuse to create new DAOs and Objects - This is a about how to create a table based on data for the Java object and thus how to create Java persistent object category to the database in the tutorial.

1, with regard to this guide:

This guide will show you how to create a new database table, and how to access the table to create Java code.

We will create an object and some other categories to this object will be persistent (save, load, delete) to a database. Using Java language, we call this object is a POJO object (Plain Old Java Object), this object is basically a database tables are corresponding to the other categories will be:

A data access object (also known as a DAO), an interface, implementation of a Hibernate type.
A JUnit class to test whether the U.S. DAO job correctly.
Note: If you are using MySQL and if you want to use the Service (Generally you will certainly choose to use), then you must be table-type set to InnoDB. You can do so, add the following contents of your mysql configuration file (/ etc / my.cnf or c: \ Windows \ my.ini) Medium. The second set (used to set UTF-8 character set) mysql 4.1.7 + are required.

default-table-type = innodb
default-character-set = utf8

If you use PostgreSQL Batch confusion encountered an error, you can try in your src / dao / ** / hibernate / applicationContext-hibernate.xml add 0 configuration file to turn off the batch.

AppFuse using Hibernate as its default persistence layer. Hibernate is an object-relational mapping framework, which allows you to your Java objects and database tables to establish a mapping. So you can easily implement your object CRUD (Create, Retrieve, Update, Delete) operations.

You can use the same iBATIS persistence layer as another possible choice. If you want to AppFuse install iBATIS, look extras / ibatis directory README.txt file. If you want to use iBATIS to replace Hibernate, I hope you are have enough reason and you should be familiar with it. I also hope that you can on how to use iBATIS in AppFuse-based guide to make good recommendations. ;-)

I will use the following language to tell you the actual development process is how I do.
Let us start at AppFuse project structure to create a new object, a DAO and a test case to start.

Table of Contents

[1] to create a new Object and add XDoclet tags
[2] the use of Ant, based on our new object to create a new database table
[3] to create a new order for DAOTest to JUnit test DAO
[4] to create a new DAO object for the implementation of our CRUD operations
[5] for the Person object and configure the Spring configuration file PersonDAO
[6] to run test DAOTest

[1] to create a new Object and add XDoclet tags

We need to do first thing is to create an object go of it lasting. Let us create a simple "Person" objects (to create the src / dao / ** / model directory), we let it have an id, a firstName and a lastName (as the object of property).

package org.appfuse.model;

public class Person extends BaseObject (
private Long id;
private String firstName;
private String lastName;

/ *
Generate your getters and setters using your favorite IDE:
In Eclipse:
Right-click -> Source -> Generate Getters and Setters
* /

This class should be inherited from BaseObject, because BaseObject has three abstract methods: (equals (), hashCode () and toString ()), so you have to type in the Person of their implementation. The first two methods are required by Hibernate, the simplest way is to use tools (such as: Commonclipse) to complete it, if you want to know about using this tool more information you can go to find the website of Lee Grey. Another tool you can use are Commons4E, it is an Eclipse Plugin, I have not used, so I can not tell you what features it has.

If you are using IntelliJ IDEA, you can generate equals () and hashCode (), but can not generate toString (), of course, have a ToStringPlugin, but I have never personally used.

Now we have a good create a POJO, we need to add XDoclet tags inside it in order to generate Hibernate mapping file. This mapping file is to allow Hibernate to map objects to tables, maps to the property listed in the table.

First, we add a @ hibernate.class tags, the tags tell Hibernate mapping which this object will be a table:

/ **
* @ Hibernate.class table = "person"
* /
public class Person extends BaseObject (

We must also add a primary key mapping, otherwise, when the generated mapping file when an error will occur XDoclet. Attention to all of these @ hibernate .* tags should be placed in your POJO object getter methods Javadocs location.

/ **
* @ Return Returns the id.
* @ Hibernate.id column = "id"
* Generator-class = "increment" unsaved-value = "null"
* /

public Long getId () (
return this.id;

I use a generator-class = "increment" in lieu of generate-class = "native", because I found that when the database in some other use "native" when there are some problems. If you only intend to use MySQL, I recommend you use "native", and our guide to the use of the "increment".

[2] the use of Ant, based on our new object to create a new database table

You can by running "ant setup-db" to create the person table. On the one hand, this task will be to create Person.hbm.xml create documents, on the other hand, can be in the database to create a "person" table. From the ant console, you can see Hibernate to create the table for your model:

[schemaexport] create table person (
[schemaexport] id bigint not null,
[schemaexport] primary key (id)

If you want to see what Hibernate generated Person.hbm.xml for your document, you can go build / dao / gen / ** / model directory of view, I have listed the contents of the following:

"- / / Hibernate / Hibernate Mapping DTD 2.0 / / EN"

name = "org.appfuse.model.Person"
table = "person"
dynamic-update = "false"
dynamic-insert = "false"

name = "id"
column = "id"
type = "java.lang.Long"
unsaved-value = "null"

Original connection: http://blog.csdn.net/abeetle/archive/2007/06/14/1651588.aspx

分类:Java 时间:2009-02-27 人气:1095
blog comments powered by Disqus


  • Linux system installation Tomcat 7 2010-10-16

    1. Download apache-tomcat-7.0.2.tar.gz 2. # Tar-zxvf apache-tomcat-7.0.2.tar.gz; / / decompression 3. / Usr / local / tomcat / bin / startup.sh; / / start tomcat Display Using CATALINA_BASE: / usr / local / tomcat Using CATALINA_HOME: / usr / local /

  • XiaoGangBao level persistence layer - made wheels 2011-08-18

    Title: making rounds of - Hot Wheels Usually received a lot of small small-scale Web projects, many departments need to request that XXX and YYY and other functions, they can not maintain the unity between the practices or customs, nor a unified busi

  • Cannon-class persistence layer - core processing base class 2011-08-18

    Title: core processing base class Usually received a lot of small small-scale Web projects, many departments need to request that XXX and YYY and other functions, they can not maintain the unity between the practices or customs, nor a unified busines

  • chapter04 Spring's support of the persistence layer 2010-04-07

    chapter04 Spring's support of the persistence layer Spring on the persistence layer of support: ① JDBC, ② O / R Mapping (Hibernate, TopLink, etc.) 1, Spring on the persistence layer supports the use of the strategy: 1, Spring on the persistence layer

  • J2EE project data persistence layer design 2009-04-28

    J2EE project data persistence layer design Data Persistence Layer design goal is to provide a high level throughout the project, unity, security, and concurrent data persistence mechanism. Achieve the various data persistence programming job, and for

  • Spring Annotations Learning Letters (d) Analysis of persistence layer 2010-03-29

    Today, we play with the database persistence layer to make trouble. Not engage in anything too complicated, Spring annotations for the persistence layer of the transformation is not hard to understand! We use the most direct interpretation of Spring

  • Thin, based on key-value of the persistence layer framework for 2010-03-29

    Now the mainstream JEE system development framework, usually display layers using the MVC framework, intermediate business logic layer using the spring, persistence layer hibernate / JPA. There is no dispute that the composition is almost the typical

  • Persistence Layer Overview 2008-09-17

    Durable, English "Persitence", simply put, is the data stored in the storage devices can be powered down. The so-called layer refers to a lasting procedures should be independent of a level. Persistence layer structure diagram is as follows:

  • Data Persistence Layer 2009-04-08

    J2EE three-tier structure refers to the presentation layer (Presentation), Business Logic Layer (Business Logic), as well as the infrastructure layer (Infrastructure), this division is very classic, but in the actual project development law, develope

  • [Build your own persistence layer] 1. Why build your own persistence layer, we build, what kind of persistence layer 2010-08-28

    The world is yours, as well as ours, but in the final analysis it is yours. You young people, full of vitality, are in the bloom, like the morning sun at eight or nine. Their hopes on you! In fact, I decided to release out this persistence, concurren

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.217 (s). 12 q(s)