Thẻ
Today, you’ll develop a complete enterprise application. You’ll apply different concepts you learned in the previous days to build an application that consists of Web components (JSPs and servlets), EJB components (session, entity, and message-driven enterprise beans), and the EIS tier (database tables).
The sample university registration system is an end-to-end application that handles the online course registration and enrollment process in a transactional e-commerce environment.
Today you’ll see how to perform analysis, design, implementation, and deployment of the sample application. You’ll undertake each of the following:
-
Understand the application requirements
-
Perform use case analysis
-
Decide on a system architecture that meets the application requirements
-
Identify the components in the multitier architecture and the interactions among these components
-
Implement the components, and package and deploy the application
Understanding the Application
The university registration system is a typical e-commerce application. The application has a Web site that enables students to browse the course catalog and register for courses online. Figure 21.1 shows an overview of the system.
Figure 21.1. University registration system.
The application provides the following functionality:
-
Student registration— This functionality enables new students to create and maintain their account information. The account information includes the student’s first name, last name, address, e-mail, login name, and password.
-
Student authentication— This module handles the student login process, such as verifying the login name and password. This ensures that only registered students browse the course catalog and purchase courses for enrollment.
-
Course catalog browsing— The Web site displays the current course offerings in the university and their details. The course details include the course title and fee.
-
Enrollment cart— The enrollment cart module enables students to place their course selection in a shopping cart while browsing the course catalog, and later to view the cart contents before placing an order.
-
Order processing— The order module enables students to place their orders, and performs the necessary verification before approving them.
-
Administrator interface— This functionality allows the administrator to view and approve orders for enrollment.
-
Notification— This functionality causes the system to send e-mail to students when they have enrolled for a course.
Analyzing the Application
Use case analysis is the standard technique for analyzing the requirements of an application. A use case diagram shows the interaction between the system and actors. An actor is a role that human and/or nonhuman users of the system play when interacting with use cases. Figure 21.2 shows a high-level use case diagram of the university registration system.
Figure 21.2. Use case diagram.
The use case diagram in this case consists of actors, such as student, administrator, and order verification system. The following describes the use cases:
-
New students register with the system.
-
Existing students log on to the system and can browse the course catalog.
-
A student can select courses and add them to the enrollment cart.
-
A student places an order for the enrollment cart contents.
-
The system verifies the order in the background.
-
An administrator can view the verified orders that need approval for enrollment.
-
An administrator approves the order and enrolls the student in the courses.
-
The system notifies the student of enrollment via e-mail.
Architecting the SystemArchitecting consists of deciding what tiers are needed for the application, what services are required at each tier, and how the application logic will be spread across different tiers. As you learned on Day 15, “Understanding J2EE Architecture,” the J2EE architecture is designed for multitier applications. In a multitier architecture, the business logic can be split into more than one layer. In the sample application, logic is partitioned into the business logic tier and the presentation logic tier. The user interface is partitioned into the client tier and the presentation tier. The application-persistent data is stored in the EIS tier. Figure 21.3 shows the architecture of the system. Figure 21.3. Architecture diagram.The sample architecture consists of the following tiers:
Note J2EE offers flexibility in partitioning the application logic across tiers. For example, you have a choice between Web-centric and EJB-centric design. In the Web-centric design, the Web tier components are responsible for most of the application’s functionality. The Web tier components communicate directly with the EIS tier using container services such as the JDBC API. In the EJB-centric design, the enterprise beans encapsulate the core application logic. Web tier components communicate with EJB tier components instead of accessing the EIS tier directly. The decision between the Web-centric and EJB-centric approaches depends on factors such as application functionality and scalability requirements. The Web-centric approach offers a quick start for small applications, but can rapidly become complex and difficult to maintain for large applications. The EJB-centric approach offers advantages such as automatic handling of transactions, distributed processing, security, and so on, and can stay manageable as applications grow more complex. The sample application uses the EJB-centric approach.
|
Running the Sample Application
The following steps describe how to start the PointBase database server and WebLogic Server, and run the sample application:
-
Start PointBase server in a new command window as follows:
C:\>cd styejb\examples C:\styejb\examples>setEnvWebLogic.bat C:\styejb\examples>startPointBase.bat
-
Start WebLogic Server in a new command window as follows:
C:\>cd styejb\examples C:\styejb\examples>setEnvWebLogic.bat C:\styejb\examples>startWebLogic.bat
-
Open the university registration system URL, http://localhost:7001/urs, using a Web browser. This will display the main page as shown in Figure 21.10.
Figure 21.10. Sample application main page.
-
Register a new student by clicking the New students register here link. Enter tom for the login name and tom for the password. Enter a first name, last name, address, and email for the student. Figure 21.11 shows the corresponding screenshot. Click the Register button.
Figure 21.11. Sample application registration page.
-
Figure 21.12 shows the course catalog page. Add a couple of courses to the enrollment cart by clicking the Add to cart link that corresponds to each course. Click the View your enrollment cart link to view the enrollment cart.
Figure 21.12. Sample application course catalog page.
-
Figure 21.13 shows the enrollment cart page. Click the Place Order link to purchase the cart contents.
Figure 21.13. Sample application enrollment cart page.
-
Now we’ll explore the administrator functionality. Open the URL http://localhost:7001/urs. Click the Administrator click here link. Figure 21.14 shows the administrator page displaying the verified order(s). Click the Approve link to approve the order and enroll the student in the courses.
Figure 21.14. Sample application administrator page.
The following steps describe how to start the JBoss server and run the sample application:
-
Start the JBoss server in a new command window as follows:
C:\>cd styejb\examples C:\styejb\examples>setEnvJBoss.bat C:\styejb\examples>startJBoss.bat -
Open the university registration system URL, http://localhost:8080/urs, using a Web browser. This will display the main page as shown in Figure 21.10. The remaining steps are similar to those listed for WebLogic Server’s steps 4 through 7.
Best Practices
Local architecture is implemented with local enterprise beans. Distributed architecture is implemented with remote enterprise beans. Local architecture offers the benefit of higher performance for the same hardware, but it’s harder to scale and cluster. On the other hand, distributed architecture is easier to scale and cluster, but results in reduced performance for the same hardware. One possible solution is to create distributed islands of local components as in the sample application.
Summary
Today, you worked on a complete sample application. We explored the requirements of the sample university application and analyzed them using a use case approach. We decided to use the multitier architecture that J2EE offers. We also decided to use an EJB-centric design in which the enterprise beans encapsulate the core application logic. We identified those components and their interactions. Finally, we packaged, deployed, and ran the sample application.














chào bạn, tutorial này rất hay, mình đang cần học hỏi thêm phân tích thiết kế = UML và database diagram và Diagram relationship. Mong bạn giúp đỡ