Accelerate J2EE development using Rational XDE

xiaoxiao2021-03-06  40

Rational®XDETM provides a true seamless integrated visual modeling environment for the most popular integrated development environment (IDE). Rational XDE does not only have the function of automated generation code and code / model, but it also has more features to assist software development. In order to better utilize Rational XDE, you need to understand the powerful J2EE mode and code template provided by XDE, you can apply J2EE mode and code template in the development, you can also define and create them. This article will show you how to use the capabilities of Rational XDE to complete a simple J2EE project development.

An overview of a simple application In order to show how to use the unique ability of Rational XDE, we will implement some features of a simple web application. This is a loan management application system that allows the lender and the loan administrator to perform some simple tasks. Lender

Online payment through the browser view installment plan loan administrator

To create one or more loan items to obtain information about booking reply, we must use the existing infrastructure platform: an IBM WebSphere application server and several databases. First we can use the free form of Rational XDE to model the direction and ideas of the relevant scheme, such as Figure 1. This free form of pictures provide us with apparent benefits: they allow you to use the same tool and make it easy to integrate the planned document into the project. Figure 1: Free form diagram is more extensive to display the key point automation analysis and design behavior once the initial plan is completed, we can start analysis and design. Although Rational XDE runs in a software development tool, it provides all the ability to complete traditional analysis and design activities - use case modeling, timing chart, etc. In fact, Rational XDE also provides Rational Unified Process? Configuration for Java Developers (RCJD), and RCJD provides the development of Java software has been proved. Figure 2 shows the initial use case model of a simple loan management system, which is obtained by discussions with customers and a step of refinement. Figure 2: The use case model of a simple loan management system For the sake of simplicity, we will only describe one of these uses to show the role of Rational XDE in the process. We choose "Show installment payment" this use case. The initial timing diagram refine the basic example of the scenario, see Figure 3. Figure 3: Detained timing chart showing the basic process of the installment payment case is obvious, this is a high-level interactive view and does not involve the details of the work inside any system. Rational Unified Process recommends using an analysis level class to provide more detailed content. See Figure 4. Figure 4: Show the refinement of the installment loan use case how to more accurately describe the content expressed in this figure has exceeded the scope of this article, you can get more detailed in the first three resource references listed in the article. information. Note In the example, we chose to divide the edge class into two pages. A more simple practice is to accept all edge interactions through a single element. Creating a model using a custom mode You may have a certain understanding of the design pattern of "4 people" (Gang of Four). These have defined patterns are supported in Rational XDE, and we will show the usage of certain modes in the rear section of this article. Rational XDE further supports the mode, which provides the ability to simplify the ability to define your own mode via UML. The ability of this custom mode not only allows you to implement your own design, but it can automate some work of boring in the modeling process, such as generating a plurality of cases. Typically, the use case has more than one event stream. For example, it shows installment lending cases with at least two event streams: one is a successful archive scene, and the other is a scene that does not fail when obtaining loan details. Figure 5 shows a custom mode (ucartifacts) that will generate a primary event stream (success), and two failed event streams. Figure 5: Custom Mode (ucartifacts) Automation Event Flow Chart This simple mode contains two input parameters: AuseCase acts as an input of an example model element, anactor as an input of the role model element. The name of the mode is created with the name of the input parameter, and the name of the use case is added to the Boundary, Control, or Entity name. These objects are used to define the framework of the timing diagram of the primary event flow diagram and two optional event flow graphs, which is based on the standard UML map provided by XDE. To create a timing chart is very simple, you can complete the work of creating the timing chart by dragging / disclosing the object in the model browser.

Each of the two optional event streams can use the role created by the pattern, any edgeary object, control (Control) object, and entity (entity) object. We can complete the example examples by drawing the required messages between different objects and deleting any analytical objects without participating event streams. Implementation Design Figure 6: Initial Class Diagram of "Show installment loan" example diagram Figure 6 shows the initial class diagram of "display installment loan" use case. This figure shows the basic role of implementing key requirements, but does not take into account other types used in the implementation. In order to achieve unified analysis modeling, we need to analyze other uses with the same method, and then combine the results. At this stage, our main goal is to identify and exclude duplicate classes, and combine similar and overlapping functions into the same class. For example, we can combine amortization and makepaymentControl into a separate control object, which can handle multiple use cases. Here we focus on "display installment loans", but there is no display of all the use case operations. You can get more knowledge about the use case through the first three reference resources of this article. J2EE Implementation This is almost independent of the specific implementation technique. Now let's take a look at how the XDE described earlier is applied to J2EE's development. Normally, the analysis class we discussed above will be mapped to the following J2EE technology: Edge Object (Boundary) HTML JavaServer Page (JSP) Control Object (Control)

Servlets Session Beans Message Driven Beans Entity Object (Entity)

Entity Beans Javabean For the development of the correct and reasonable J2EE technology when developing your application system, this is just a start point. Because different technologies can be used to achieve similar programs, the most reasonable choice depends on your requirements for details and systems. Of course, the coolest part of the Rational XDE J2EE mode is that each mode is fully implemented by XDE. What you have to do is to provide business logic for your app. In this section, let's take a look at the specific details you need to know in order to use the Front Controller mode. Establish a request between request and use case (for example, a form of submission) must be able to be simply specified to a particular use case. In the implementation of the Front Controller mode we discussed, this information should be conveyed through hidden domains in the form, and the name of the use case should be set when the form is created. When the form is submitted, the controller is simple to analyze the parameters to determine which case should be called. When the request is not specified to specify a certain case, usually a default use case function is set to process the request (see below).

show amortization

Enter the folowing information about the loan:

PRINCIPAL

Dollars

Rate

%

Duration

Years

The Controller Process Request For the controller does not require any implementation, the implementation of the mode will extract the hidden parameters according to the desired logic, request the associated Helper Bean, and commissioning the Helper Bean to complete the work. Figure 7 shows a static relationship between the page and the controller. The complete automatically generated request processing code, see the code list below Figure 7. Figure 7: Relationship between forms and controllers

// Check if we have a use copy name passed on the URL.

String Usecase = httprequest.getParameter ("Usecase");

IHELPER IHELPER = NULL;

IF (Usecase! = null)

{

// Dynamically Instantiate A Helper and Call IT.

IHELPER = (Ihelper) ThehelperFactory.create (usecase);

IHELPER = IHELPER =

(Ihelper) thehelperfactory.createDefaultHelper ();

}

Else

{

IHELPER = (Ihelper) ThehelperFactory.createDefaultHelper ();

}

IHELPER.PROCESSREQUEST (httpRequest, httpResponse);

The mapping relationship between the use case and the Helper BEAN You can establish a map relationship between the use case and the helper bean by adding mapping information in the HelperFactory constructor. For "Show installment loans" use cases and "Setup Loans", the mapping is simple, please see the code segment below. This code only needs to be placed in an appropriate, pre-defined location where the HelperFactory constructor is placed.

// Establish Showamortization Use Case Mapping to ITS Helper Class

Usecasename = "showamortization";

ClassName = "ShowamortizationHelper";

Addmap (usecasename, classname); // Establish Setuploan Use Case Mapping to Its Respective Helper Class

Usecasename = "setuploan";

ClassName = "setuploanhelper";

AddMap (usecasename, classname);

The Helper Bean is clear, and this scene should be different for different use cases. In general, a Helper Bean typically requires the appropriate form parameters in additional information collected, the equivalent of the equivalent, and other participants (eg, session beans and entity beans), and then eventually produce The result of the display is displayed. Some examples of this processing process are shown below. Note The XDE mode engine completely eliminates the need to create a Helper class manually. You need to do just in the wizard, you select the "Generated Value" option and enter the name of the Helper class. Figure 8 shows a screenshot of this wizard.

// Extract the info from the request parameter

String sprincipal = httpRequest.getParameter ("Principal");

... ..

// Locate the Amortization EJB USING The Service Locator

...

// Call The Remote Method on the session bean

Float Totalinterest = Theremote.amortize (Principal, Rate, Terminyears);

// Put Data in the AmortValuebean

AmortvalueBean AVB = New AmortvalueBean ();

Avb.SetPrincipal (Principal);

... ..

// set the session attribute

HttpRequest.getations (). SetaTRibute ("AVB", AVB);

Figure 8: Automatically generate basic helper bean display results here again, there are different ways to complete the same work. Typically, data should be available for JSP, and JSP will be responsible for data display format. Figure 9 shows this static relationship. For this method, the JSP source code is displayed below in Figure 9. Figure 9: Relationship between JSP and data formatted / displayed

Extracts Data from the 'Avb' Bean Instance and Formats / Displays IT

Results of Your Loan Amortization Request:


Pricipal entered: <% = avb.getPrincipal ()%>


Yy.

Total payments: <% = avb.gettotalpayments ()%>


back to main page

Code Templates Code Template is the ability to simplify developer development efforts in another Rational XDE. They provide a very effective mechanism for the following aspects: Code snipping and algorithm reuses a code-shared consistency based on specific issues to create standard header information and comments Rational XDE provides substantive support for code templates. In addition to scalable and built-in infrastructure, it also provides the following capabilities:

Bind one or more code templates to a method to remove a code template to rearrange the binding order as needed to meet the required parameterized code template in our example, you can create a code template to establish a use case Map of Helper class. You can then bind the code template multiple times to the constructor, and provide different default values ​​for the code template to customize the generation. Figure 10 shows an example of this. Figure 10: Code Template Code Template for Establishing Use Example and Helper Bean Map can also be used as part of a custom mode, so you can use Rational XDE to create a more scalable application framework. In fact, Rational XDE also uses the ability of code templates and patterns to implement other capabilities of the product. For example, the generation of Getters and setters related code, the implementation of design patterns, etc., the ability of the code template is used. The end-to-end scenario We have written the specific details of the design and implementation of the simple application of this article, and now let us combine these pieces. The next two timing charts capture the interactions between different objects to end, including participants from two modes. Figure 11 shows the activity of the front end: the form is submitted to the controller, the controller obtains the Helper BEAN and requires it to process the outside request. Figure 11: The form is committed and the controller processing is processed in Figure 12 is the continuation of the previous timing chart. It shows the various initializations of Helper Bean, and the final request is forwarded to the JSP page responsible for formatting and displaying the results of the calculation. The JSP page displays the result to the end user. Note that the service locator mode is used during the process of acquiring the required EJB. Figure 12: Helper bean performs processing procedure and rendering results mode and code template simplify and accelerating the development of J2EE I hope that this discussion will communicate the benefits of Rational XDE to developers in J2EE projects. The mode and code template in Rational XDE provide you with a simple way to use a classic solution to accelerate the development of software. Rational XDE's ability to automatically synchronize and create custom modes and code templates - will enable developers to liberate and further accelerate software development from boring, repeated tasks. Reference

Khawar Ahmed and Cary Umrysh, "Using J2EE and UML Develop Enterprise Java Applications" Addison-Wesley, 2001. Ivar Jacobson, Magnus Christerson, Patrik Jonsson, And Gunnar overgaard, "Object-Oriented Software Engineering" Addison-Wesley, 1992. "Rational Unified Process Guide": Analysis class Grady Booch, James Rumbaugh, And Ivar Jacobson, "Unified Modeling Language User Guide" E. Addison-Wesley, 1999.

About the author Khawar Z. Ahmed is a member of the IBM Rational XDE technology market department, and he is responsible for the XDE's Java platform version. At the same time, he is also the second author of the book "developing Enterprise Java Applications with J2EE and UML". You can contact him through kzahmed@us.ibm.com.

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

New Post(0)