Building J2EE Application Frameworks With Design Patterns In Java (Part 2)

Building J2EE Application Frameworks With Design Patterns In Java (Part 2)
In this article we would like to present an alternative way to build an effective web application framework that companies around the world such as IBM, Oracle, and Sun have applied effectively in their projects. More specifically, this application framework uses the latest competing technologies such as EJB2.0 (J2EE), XML. (Continued from Part 1) Build a J2EE application framework Note that this is just a framework, which is to build an application framework for your project, the only thing you have to do is upgrade the framework's handling to suit the requirements of the project. In the model shown in Figure 1, this is the form that creates the request handlers. and configured into the system via a mapping as an XML file. Thus, the programmer only needs to know Java and work with simple operations on the processor layer without knowing J2EE and related modules such as Servlet, web server or database server. Design options as well as related technologies in the stratified model using J2EE technology as shown in Figure 4: Framework level and commercial libraries This is an alternative to integrating existing commercial libraries into a complete application framework. It can work very well if you choose high quality libraries and frameworks, but in return you might have to pay for these libraries. For example, we can select Struts for the Web, Business Components for Java (BC4J) and Oracle's Toplink to run on the Oracle9iAS server. The frame level uses design patterns for J2EE / EJB Building the processing layer for this application framework using design patterns for EJB technology is a solution that helps programmers create a highly commercial standard library such as the one above. And this is also the solution that many companies such as IBM, Sun, Oracle selected for the construction of projects using their J2EE technology. Two of the designs most commonly used for this processing layer are: EJB Seal Pattern: This is a design pattern that allows you to analyze the function of the processor in the MVC pattern. This module can be considered as the controller of the project framework as a middleman handling transactions between the View layer and the EJB entity (Model) layer. EJB Data Transfer Object pattern (DTO): This design pattern optimizes the transaction speed between two Web tiers and EJB Entity in a distributed environment by minimizing direct communication between the two tiers. Distributed transactional environment (DTO) is Javabeans EJB Entity 2.0 This is part of the J2EE technology (you can refer to the technology specification on Sun's Web site), which allows for mapping data between the database and its corresponding entity objects. Automated on J2EE-compliant server applications (J2EE container). Using EJB Entity 2.0 technology in a proficient way to build an application framework that helps the developer (project development from this application framework) bypass many complex technologies such as JDBC, web server or database server. . Furthermore, J2EE provides an open capability for the database and web server for your project; In other words, can your product run on all Java web servers (Websphere, Jboss, Weblogic?) and database servers (Oracle, MSSQL?). Jakarta Struts (1.1 beta3) If you build a web application using Java, even though the project does not use J2EE, struts is a framework that can not be dropped. This is an open source framework that aims to create a standard component in web-level design using MVC and create a highly stable and consistent framework, as well as enable integration into J2EE systems. Easy way through a few enhancements. The struts MVC pattern is shown in Figure 5: With Struts the programmer does not have to worry about how to build MVC, just configure and run the project's display layer, which minimizes training costs, faster development time. and allow the system to run stably on different platforms or modules. This is the Web's most powerful web development framework for nearly two years. Manufacturers such as Borland, Oracle and IBM have been striving to release support for and integrate Struts in building Web applications. . Java Server Faces (early access) A technology quite similar to Struts, created by Sun with a standard technology specification that many software vendors recognize and will support in their products. However, the JSF specification is in the final stage, so the products supporting this technology can not be completed in time. This is clearly a competitive product for Struts in the near future. Your choice Where do we start, why not start with the framework that well-known companies have been using successfully? The experience and the project will complement your J2EE framework, so what are you going to do with this framework for your next project: copy and edit to make it fit enough? Modifications will also become complicated if the entity model is too different! WebGenerator is a product that helps you automatically generate a web application framework according to this requirement. WebGenerator This is a product that allows us to automatically generate a web application framework that supports J2EE. The software requires the user to include information about the entities of the project you are preparing to build and the relationships between them; Or you can include in the database the system to automatically create these entities and relationships, all using XML. The next step is to simply select the database server and the web server will deploy the application. No further modification is required. You already have an EAR file that conforms to the J2EE specification and the server standards you have configured. This EAR file can be considered as a demo for the project, using the MVC model and design patterns for the EJB layer discussed earlier. The rest of the programmer is developing the "request handler? And integrated into the framework just born without regard to J2EE, database or webserver? The advantage of this product is that it offers open capability to the user. The software uses XML / XSL syntax templates configured in the file system, so that users can register new templates so that the system generates everything they want, NET without changing the source code of this software. The demo framework supports EJB2.0, struts1.1 beta, Ant1.5, log4j, Junit3.7 and testcases. The current version supports EJB2.0 on Jboss3.0.x using MySQL3.2.2x or Oracle 8.1.7 (in the testing phase), the upcoming version will support MSSQL7.0 / 2K, WebSphere. 4.5.x and allows the user to create and select the appropriate interfaces for the project's display layer. Conclude This is not an article about the creativity or design of a complete application or framework. We only try to understand the software designs available for e-commerce applications that some large companies like Sun, IBM deployed? and sought to generalize to a generic model used in the construction of commercial applications on the web and, more or less, we have applied very successfully. It is not theoretical but more practical with the latest and the newest technology. We are looking forward to your comments. Refer - Jakarta Struts 1.1 beta3, http://jakarta.apache.org/struts - Java Server Faces (JSR 127): http://java.sub.com/j2ee/javaserverfaces - Sun J2EE design patterns: http://java.sun.com/blueprints/enterprise/ - The Java Pattern Companion Pattern, by James W.Cooper - EJB Design Pattern, by Floyd Marinescu - Programming Jakarta Struts, by Chuck Cavaness Nguyen Tuan Khang Coco Software Engineering Vietnam