1. Overview Dynafuse is similar to AppFuse, a new architecture that integrates current mainstream J2EE technology, using Struts, SpringFramework, Hibernate, Groovy, etc., proposed Eventyhes Be Dynamic, providing a new Dynamic modeling, dynamic programming.
2. Operation example
Download and install MySQL-4.0, create database Dynafuse, create user username / password to admin / admin. Download and extract DynaFuse-xx.zip, perform statements in Data / Create-Tables.sql in MySQL. Download Jakarta-Tomcat-5.0.28, Dynafuse / Lib / MySQL-Connector-Java-3.0.14-Production / MySQL-Connector-Java-3.0.14-Production-Bin.jar and Dynafuse / LIB / JTA-1.0 / JTa.jar Copy to Jakarta-Tomcat-5.0.28 / Common / Lib, copy DYNAFUSE / DYNAFUSE.XML to JAKARTA-TOMCAT-5.0.28 / Conf / Catalina / Localhost, download Dynafuse.war to Jakarta-Tomcat -5.0.28 / WebApps. Start Tomcat, open the browser http: // localhost: 8080 / DYNAFUSE to enter the example program.
3. Structure Description Download and extract the Dynafuse package, you will get the following directory structure: build: Compile file config: Profile Data: Test Data Dist: Packaged release file DOCS: Document lib: Used JAR file Metadata: XDoclet needs configured file segment Script: Groovy script src: Source Test: Test Source WEB: JSP for Example Programs
4. The main features of Dynafuses are the most important feature of Dynafuses, from DAO to Service to Web, each level provides integration of Groovy's new Server Srcipt language, making basic all logical code in web applications. It can be written, maintained in a dynamic form, and the architecture is divided into three layers:
DAO Layer - This level, Dynafuse provides two interface: DAO and Dynadao, DAO is a universal data access (increasing, deleting, changing, check) interface, Dynadao provides a call to the DAO level on the basis of DAO Features. These two interface currently only provide Hibernate implementation. DAO and Dynadao are configured in the IOC container as a bean in the SpringFrameWok, respectively, please refer to Config / ApplicationContext-Hibernate.xml. Service Layer - This level, DYNAFUSE provides two interface: Manager and Dynamanager to complete the Package of DAO and provide call features for business logic scripts in the service level, call service level scripts, one is in the transaction environment InvokescriptInTiaSAction, one is not required to be a transaction (InvokeScript). Manager and Dynamanager are configured in the IOC container as the bean in the SpringFrameWok, respectively, please refer to Config / ApplicationContext-Service.xml. Web Layer - This level, DYNAFUSE provides DynaAction to complete call to web-level scripts. 5. Architecture Use the following text to describe how to use DYNAFUSE for development.
1. Constructing Hibernate's dynamic model Hibernate provides a dynamic model, with the dynamic model, you can consult the Dynamic model, which is given below, the dynamic model of the Dynafuse sample program, the file see Dynafuse / Model / EXAMPLE.HBM.XML XML Version = "1.0"?> "delete"> INSERT = "true" column = "person_description" not-null = "false" unique = "false" /> 3.Service level, in actual applications, business logic is ever-changing, so the service level adds script support is very useful. The service layer's script will be called in the Web layer through Dynamanager, below is the Dynafuse in the sample program. /script/DeptManager.groovyimport org.robusta.dynafuse.dao.DynaDAO; import java.util.List; public class DeptManager {public dynaDAO dynaDao; public List getDepts () {return dynaDao.getObjects ( "Dept", null, null, null);} public Object getAvgAgeOfDept (Integer deptId) {return dynaDao.invokeScript ( "PersonDAO.groovy", "getAvgAgeOfDept", new Object [] {deptId});}} It should be noted that the dynaDao class member variables, and The session in the DAO level script is the same when executed in the script in the Service level, and you only use it with your feelings. It is also important to note that Dynadao can be used to call the script of the DAO level in the script in the service level, as GetAvgageOfDept above. 4. Building a dynamic model of the Web layer, Struts provides a mechanism for this construction dynamic model of DynavalidatorActionForm, please refer to DYNAFUSE / MetAdata / Web / Struts-Forms.xml in the example. 5.Web level, like the business logic, the page logic is also a variable, so the script of the web layer is very useful, the following is the DynaFUSE / Script / DeptAction.groovBlic Class DeptAction Extends baseAction {.... public Dynamanager dynaManager; .... public ActionForward editDept (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {if (log.isDebugEnabled ()) {log.debug ( "Entering 'editDept' method");} String deptId = request .GetParameter ("deptid"); if (deptid! = null&&! "" "" "{Map Data = Dynamanager.GetObject (" dept ", new integer (deptid); long avgage = (long) Dynamanager .invokeScript ( "DeptManager.groovy", "getAvgAgeOfDept", new Object [] {new Integer (deptId)}); DynaValidatorActionForm deptForm = (DynaValidatorActionForm) form; deptForm.set ( "id", data.get ( "id") ); Deptform.Set ("Name", Data.get ("Name")); Deptform.Set ("Description", Data.Get ("Description")); Deptform.Set ("Avgage", Avgage); UpdateFormbean , Request, Deptform;} return mapping.findforward ("Edit");} .... and the SERVCIE and DAO layers, there is a Dynamanager member variable in the web layer script.