Develop J2EE Application with Rational Rose and UML (2)

xiaoxiao2021-03-06  102

Implementing software Although the analysis model can help you solve the problem, it provides a foundation, but it is still far away from the implementation. During your design, you must take into account additional limits and needs that are brought about by the techniques used, and try to map solutions to optimal implementations. In our example, suppose we are building a web-based application. Achieving such an application requires a well-thoughtable way. The role of the analysis model is to be used as a starting point to decide to map different J2EE technology to the scheme. For example, the << Control >> class is well mapped to Java Servlets or Enterprise Javabean (EJB) Session Beans. This method can correspond to the implementation model of the J2EE layer and the Sun's "Model 2" reference system. Rational Rose provides a simplified interface to develop servlets and EJB Session Beans. Figure 5 shows a dialog box for creating a servlet. **** Figure 5 Servlet Definition Window ***** Although EJB contains multiple interfaces and classes, Rational Rose also provides a convenient interface for creating EJBs. The dialog for creating EJB is shown in Figure 6. Here, the dialog displays settings that need to create a stateless session bean. **** Figure 6 **** Creating a SESSION EJB obtained by a stateless session bean is shown in Figure 7. This is based on the UML model developed for EJB, which is developed in JSR-26 with Sun Java Community Process. It shows the relationship between the various elements of EJB, especially the Home and Remote interface and EJB implementation classes. Since EJB does not really implement the Home and Remote interface (they are implemented automatically generated by configuring tools), the relationship is not implemented with home and remote interfaces, but generates << ejbRealizeHome >> and << ejbRealizeRemote >>. The dependency of the HOME and Remote interface indicates that the HOME interface instantiates the Remote interface. ************ Figure 7 ********* A Stateless session bean << Boundary >> class is roughly mapped to JSP, HTML, and FORM if you are developing a Traditional customer-based applications, which are mapped to a dialog of a client application. We use JSP as a means presenting entities and system interactions. JSP is actually two aspects, that is, the client's performance and server behavior, so its model contains a client page and the server-side page, and the relationship between them is << Build>. An example is shown in Figure 8. ********** Figure 8 *********** JSP creates a JSP as the server side and the client page to be simple than EJB, you only need to select Web in Browser menu Modeler> New> Server Page is OK, as shown in Figure 9. ************ Figure 9 ************ Create a JavaServer Page, such as Catalog, Order, and Customer class mapped to be mapped to Rational Rose Entity bean. They create as shown in Figure 6 above. One technology that is often used in J2EE applications is to use JavaBean to transmit information between servlets and JSPs. This is very simple to do in Rational Rose, by creating Attributes on a Java class, and by setting Attribute as attributes by the Attribute specification dialog box in Figure 10.

************ Figure 10 ********** Set A Attribute Set to Property In the overall implementation model, create JSPS, servlets, javabeans, and EJBs are very useful . Rational Rose allows you to easily model relationships and tell the engineers's basic details, including not only JSPS, Servlets, EJBS, and JavaBeans, but also include HTML pages and formations involved in the implementation. These can be given to the performance layer developers for further processing, while maintaining compatibility with your application logic. Figure 11 is a part of a class block diagram showing different technologies involved in the online CD store. This block diagram shows each class and how they are arranged with performance, business logic, and data layers. In this way, the client's page is on the left, the controlled servlet is in the middle, and Entity Beans is on the right. ************ Figure 11 ***************************************************** To some classes. We can try the "reading" block diagram through a simple paid scene. Assume that you have already browsed and select some CDs that are ready to purchase, and you select "Checkout" option on the home page (top on the top). This will call the MainSerlet controller displayed via the related stereotyped << link >>. The mainservlet is a detail of order in Order EJB, constructing an Order JavaBean, and set it to a properties of the session, and send the request forward, like the << Forward >> identification until a Checkout JSP. Checkout JSP uses ORDER JAVABEAN, such as the << Use Bean >> relationship between JSP and ORDER JAVABEAN, which will construct the Checkout_Client page and rendered to the user. Obviously, we ignore some of these details. For example, in an actual project, you may use a shopping cart to track the project; the responsibility of the control may be more dispersed, not just using a single mainservlet. The main point of view here is to tell you that UML is a powerful tool for designing and developing complex J2EE applications, through the above example, you will recognize this.

Implementation Rational Rose allows you to generate, JavaBean, HTML, Servlet, and EJB code from block diagrams. For example, the << include >> relationship between two JSPs will result in <% @ include file = "header.jsp"%> in the corresponding JSP. Similarly, << Use bean >> will generate , which can be used in JSP. In terms of EJB, in addition to all three EJBs in EJB2.0 (and EJB1.1 EJB), Rational Rose also provides some features to simplify EJB development. For example, when developing EJB, one of them is more troublesome is a code that needs to be written in the interface and implements the class. Rational Rose provides an option for a menu, you only need to press the button to solve it. It also provides a "Check and Repair" menu option that verifies the legality of the defined EJB (for example, the Remote interface in the Remote interface, the corresponding), if not, you can fix them for you. The other and EJB related characteristics in ROTIONAL ROSE are Rational Quality Architect (RQA), which can be used as design test EJB. For example, the RQA can be used as an EJB test. It is also possible to use the sequence diagram defined in ROSE to perform multiple EJB tests. When relying on a software component, it has not been designed, then RQA can be used to generate a frame. To ensure that you can be implemented with your own conditions, you don't have to worry about the change of the UML model, and vice versa, Rational Rose provides a built-in code editor, and the user can set the synchronization option. For example, you can choose to keep synchronization. In this case, whenever you update the source code and save, the UML model in ROSE will be updated. Sometimes, you can just want to see how they deal with and don't want to affect your model. In this case, you can turn it out of the global or based on each class. Of course, when you talk to implementation and encoding, you will need a good IDE, such as Sun's Forte for Java or Borland JBuilder. Rational Rose 2001A provides the depth integration and automatic synchronization of the mainstream IDE, so you can continue to use your favorite IDE while enjoying RATIONAL ROSE in the UML model and development J2EE application. More about UML and J2EE, we just briefly talk about the use of UML model and development J2EE applications. For example, through the various entities involved in the session, you can use the UML activity map to model session management. Another challenge is to communicate the correct operation call sequence required by session EJB. A sequence diagram can identify a scenario, but you need a large number of sequence diagrams to represent various scenarios supported by the component (some people try to use the sequence diagram with control and branch statements, but this will only get a complex and puzzled order. Figure). On the other hand, the UML state diagram provides a powerful feature that models and communicates this information.

转载请注明原文地址:https://www.9cbs.com/read-124715.html

New Post(0)