Establish e-commerce applications in IBM Rational XDE and WebSphere Studio
content:
Introduction Get Demand Creating Projects and Models Adding Use Delivery Create Timeling Diagram Representation Behavior Creating EJB Project Reverse Engineering EJB Project Test App App Note Resources
The Rational Zone is also:
All articles online courses
Primary Tad Siminitz (Tad@us.ibm.com) Software IT Architect, IBM 2004 March
This article describes how Rational Extended Development Environment (XDE) and IBM WebSphere Studio provide an integrated development platform to build e-commerce applications from the beginning to the end. The author explains how to perform design, implement, and test a simple application by using several different plugins from IBM WebSphere Studio and XDE kits in a mini-developed life cycle.
Introduction By using Rational Extended Development Environment (XDE) and IBM's WebSphere Studio, you will get a comprehensive and integrated development platform for building e-commerce applications. You can make a demand analysis, object-oriented design, and modeling for information models you use to build and test code. In other words, all participants in a project can now sing the same song. Before using Rational XDE, in the task of development cycle, users often need to export information from one tool, inserted to another tool. In order to show you the role of these different tools, I will use the scene below this article. Sometimes, a new project designer and system architect must start from scratch at the beginning of the project, and there is a complete control over all aspects of the application. But usually is that project staff must handle existing components, usually there are some existing relational databases. In this scenario, assuming that you are asked to implement a web-based banking application, this app allows end users to pay from their account. As the design and implementation of this small application, you are also asked to use an existing table in an existing database. At the same time, it is necessary to follow regular needs, analysis and design of each new development project in your organization. Tools selected at this stage of the development cycle are the XDE of the Rational Software and IBM WebSphere Studio Application Developer with additional development and application server test capabilities. The activities that need to be performed in this small project system are:
Gets to describe the needs of your needs to build applications. Create a case diagram to display the relationship between roles and use cases in the system. Create a timing diagram to display the interaction of the time order. Reverse engineering a relational database to create a company JavaBean (EJB) component. Create a class diagram and modify the Java class to the WebSphere application server and test the unit test tool with the WebSphere Studio tape. The first step in obtaining a demand is to obtain demand, usually complete through the potential end user with the target application. Demand may also be opened from those who handle certain tasks or from existing systems. For our Web ATM sample, a requirement we have obtained is that customers can pay for their accounts. Documentation requirements may like the following: Demand A: "End users need to enter their bank account and password, the system verifies that they are the owner of the account. Once the verification, the customer can choose" pay ". The customer then select the specified Account, enter the amount and confirmation (name) payee of the expenditure. "In real cases, it is important to get the demand as much as possible at this stage, because in the later development cycle, you need to implement or generate logic To perform the task. To accomplish this task, you need to start using XDE, XDE is designed to be a plugin for WebSphere Studio or other products that support Eclipse technology. You can enter the demand into XDE to make it a file in the project and use the software configuration management (SCM) system you selected. Control. From these needs, you can design your use case. The use case is a description of the system use. At this point, you should know who the system of users; they are indispensable parts in the case. Next we will enter a short use case to represent the use of the use of the Web Banking system. Creating a project and model You need to create an XDE modeling project and model before you can enter a use case. I assume that you have installed XDE on WebSphere Studio Application Developer and have already launched the environment. Confirm that you are in the modeling perspective. To get a modeling perspective, from a perspective menu, select Open> Other. Select Model and click Confirm (OK). In order to create a new modeling project: In the File menu, select New> Item. New project dialog popping. Select Modeling in the left hand panel of the new project dialog. Select Basic Modeling Project.) On the right panel. Click Next (Next). In the Project Name dialog, enter the name of the new project. For this scene, it is called WebBankModel. Click Finish Now you have been generated for the project, you can create a model and put it in the project. A project can have multiple models. In order to create a new model, in the modeling perspective:
In the file menu, click New> Model (Model) in the File Type Panel, select Rational XDE, for Template Area, select Blank Model in the File Name text box, enter the name of the letter model file. We use WebBankModel in the destination folder, select the item name you entered above, click to complete. The model appears in the model browser; in the chart window, the main use case is opened. You can now start building a high-level model example probably describe the system you need to build. After we will refine these use cases. The first is the first one of the needs to be added in the example. A role is defined in the UML as a model element to describe a user who is interacting with the modeled system. Although the role is usually a representative, it can also be not a representative. It can represent an organization, system, or machine interact with the system. The first role in our Web Bank Application will represent users. You can now add this role to your model by following the steps: Select your model in the model browser. Right click and select Add UML> Roles (Add UML> Actor.). Name your role, such as webbankcustomer. Repeat steps 2 and 3 add another role and name the Transaction System represents the external system you want to query. Add this example, you have to add some cases. One use case describes the behavior of the system from the perspective of the role, but the use case does not display the internal implementation details of the system. Because at this point you know is some information about the relatively high level of information you need, so you can add some use cases. You should create an exemption that verifies the user, a use case to view the balance and the use case of a transfer. Add these use cases to your model:
Select your model key in the model browser and select Add UML> Use Case (Add UML> USE Case.). Name your use case, with Authorizeuser. 1. Repeat steps 2 and 3 Add other use cases and name TRANSFERFUNDS, AccountBalance, and makePayment. Creating an example diagram You should have four cases to describe your ability to have your system. You can now create a description of your system to summarize your system. One example can contain all the usage examples and roles in the model, or only some of them. You have an empty window panel before you have a blank case editor. You can confirm this by checking if there is an example-related tool, the Actors (Use Cases) and Associations) in the toolbox. The drawing example is simple, and all the components you add are included in the model created above. Simple dragging and two roles and four use cases. The most appropriate location is that the end user is on the left and the processing system is on the right. The use case can be arranged vertically. The association represents the interaction between roles and use cases. Because your end user has a requirement, you should add associations in the example of the example. Add 3 associations, from WebBank's end user roles to 3 use cases, verify users, transfer, and query balances. When you have finished these, your model should look like Figure 1. Figure 1. Model of role and use case Creating a timing diagram means behavior Once you have developed a picture of a high-level system function, you should now put your energy will be added to the database-independent specified behavior. In particular, when you rebuild some key classes from existing databases, you may need some logic that is not part of the data model. You need to create a timing chart to display the interaction between objects in the system and these objects. The timing diagram is one of the UML diagram, which provides a view that is transmitted between the messages between the objects in a given scene in a time order. In the analysis phase, the timing diagram is determined in order to complete a certain job, what kind of objects and methods need to be performed very useful. Add a timing chart for use case MakePayment: Select Sample MakePayment in the Model Browser to select the Add Diagram> Timing Diagram: Role (Add Diagram> Sequence: Role) Name this timing diagram MakementDiagram Now you can in your model Add some components. Because this use case is very high, there is only one association between Atmuser, the use case MakePayment and the processing system. For this timing diagram, you should describe a detailed description of messages that occur between critical entities or objects that will be constructed. For "connection" elements, you can add some messages that represent interactions between objects represents between objects. In XDE, a lifeline is a symbol, which represents an object exists in a certain period. Add some lifelines and messages:
Select the role webbankcustomer from the model browser and drag it to the workspace, and place it vertically on the left. Do the same thing for Transactionsystem. Drag and drop a lifeline icon (from the toolbox) between the other two lifelines. Rename this lifeline to add a WebPage messages between ATMUser and WebPage, and add another name Enter messages between WebPage and TransactionSystem, and named from TransactionSystem to WebPage, and create the WebPage to WebBankCustomer return message is saved as MakePayment Your timing chart (CTL-S). A complete timing diagram should be like the following. Figure 2. Time-sequence graph You can create a "comment" in the example diagram, then this comment chain into the timing diagram, the comment can bring you from a specific functional domain to this function. Creating a comment: If the case webbankmodel has not been opened, first open it. Create a comment and drag it to the icon that represents the timing chart on the use case MakePayment to the comment connected to the usage case. Double-click the timeout map in the annotation in the example. Create an EJB project Because in this scenario, you already have existing databases, we will go back to see the database tables you are interested in and create some initial classes for you by using WSAD. This is very common, because many applications are originally built on the database already existed and will be used. You can understand the Java class that you can understand through the definition of the reverse engineering database table. Enterprise JavaBeans (EJB) Components are part of the J2EE specification that allows you to encapsulate behavior in your lifecycle to represent your business in your business domain, such as customers and accounts. However, J2EE's specifications are relatively complicated. His idea is that the J2EE platform handles some basic operations in a standard way, such as reading and writing persistent storage. Some tools are designed to help you efficiently create EJB components, and some runtime platforms (such as WebSphere Application Server) are designed to manage their operations. Before you create your EJB component, you need to create an EJB component project. From any perspective:
Select File> New> Projects> J2EE (File> New> Project> J2EE) and select Enterprise Application Project.) Named Project ATM and accepts the default value for the EJB and Web projects. If you want, you can apply the client project because you will not use it. Here you can check the XML file called Application.xml in the ATM project, this file contains a J2EE application consists of which components consist. A good way to find this file is to find it from the navigation view in the J2EE perspective. If you double-click this file, the XML editor allows you to browse this file in a different way, such as normal way, source file mode, and other ways. For J2EE applications, WSAD provides built-in "intelligent" tools for configuring and browsing XML configuration files. Now let's start, open the data perspective in WASD, if the data perspective is not opened yet, you can open it from the main menu:
Select Perspective> Open> Other (Perspective> Open> Other) and select Data (DATA). Now you need to create a connection to the ATM database. From the Database Browser view, click Right click and select New Connection. Then fill in the required information as shown in Figure 3. Figure 3. Creating a database connection When all necessary information is filled, click Finish. You can expand the icon to check if your database has appeared. Your database table should already appear under the database connection, name is YourId.account and YourId.csutomer. Next, you should insert these tables to the EJB project that just created J2EE project. The steps are as follows: In the database browsing view (in the Data Perspective), the entity in the bright ATM entry is expanded, click Right click and select Insert To Folder ... In the pop-up menu, click Browse, Select the ATMEJB project and click Finish. The answer to the problem of creating a folder for meta information is (YES). If you return to the J2EE perspective, open the J2EE view, you can see the information in the database directory. There are several reasons for the mapping of the creation of objects to the relationship. There is a difference between the relationship model and the object model, which needs to be processed for effective programming. Other reasons are knowledge of using the developers of the application server to provide some Java classes on the application server and databases for handling the persistence of application data. When the application is greater flexibility, the relationship map will make the application to remove the processing burden on the database and database server. In order to create a map, from J2EE perspective:
Check the atmejb module to click Right click, select Generate> EJB to RDB Mapping (Generate> EJB TO RDB Map). In the pop-up window, select the Low Object / Relation Mapping (Bottom-Up O / R Map) Open Mapping Editor Upon Completion when completion, this option allows you to see the map you created . After clicking Finish, the mapping editor should be like Figure 4 Figure 4. Creating a relational mapping reverse engineering EJB project Now you can generate a Java code model for you through tools. If we are modeling a big app, a small part of this app includes EJB components, then we can describe the entire application includes our automatic EJB code, which is typical for session beans. And entity beans. In order to make things easier, you can play J2EE views in the modeling perspective. Open the modeling perspective, then select Pistachtles in Select Single item> Show View> Other ...> J2EE (Perspective> show View> Other ...> J2EE> J2EE View) In the J2EE view in the modeling perspective, the J2EE view should be opened You can adjust its position according to your habits. In order to make code editing and browsing more convenient, doing the same thing in the outline view (OUTLINE VIEW). Here you can add the Java code model to the Atmejb project by the following steps:
Select the atmejb module Select New> Other (New> Other) and then there is a wizard. Select Modeling, Select Model (MODEL) and click Next Next screen, select Java in the file type, and select Java Code Model under the template, name the model to javacodemodel_atm, then click Finish (Finish) ), See Figure 5 Figure 5. Add Java Code Model Reverse Engineering Model: In the navigation view, click on the mouse button on this model file, select Reverse Engineer, and to answer the question to the dialog box is (Yes) ) Set the root directory to
In the model browser, select the ATM package, click Right click and select Add Diagram (Add Diagram> Class), then name the picture to Account to drag and drop the AccountBean Java class (EJB tool for you). In the class diagram, you can select the Add Related Shapes in the class, then select All Models, and finally click Confirm (OK) to display the dependence of AccountBean. Your class diagram should be like Figure 6 Figure 6. Category Samples Now you can add some other features to the Accountbean class by adding methods, such as adding payment functions. Add a method:
In the model browser, select the AccountBean class, and click Right click to add the Java> method (Add Java> Method) Enter MakePayment () Right-click on the AccountBean class, and select Generate Code in this class, you can see The framework of the method is added. Complete the following code:
Public void makepayment (java.math.bigdecimal hoWMUCH, Java.lang.String
Payee)
{
SetBalance (). Subtract (howmuch);
System.out.Println ("Make a payment to" payee "for the amount of
$ " hoWMUCH);
}
Confirmation is saved (File> Save AccountBean.java or CTL-S). Note that you are printing a comment to the console, because other services will have to be called (we have not implemented in these services) to complete the actual payment process. You don't get any potential errors, such as handling overdraft. Next you need to use AccessBeans Wizard to create Customer and Account JavaBean wrapper AccessBeans. Specify the type of JavaBean wrapper and use the FindByPrimaryKey () method for Account and Customer. You need to generate EJB deployment code before testing. You can see the code associated with the EJB component by browsing the EJB component, most of these code is established according to J2EE's specifications, which makes your EJB component good flexibility and cross The versatility of the platform system. To generate a code, from the J2EE view, the ATMEJB EJB module is selected, and the deployment EJB code is generated for Customer and Account using the pop-up menu. In the outline view, select the method to be added to the remote interface, click the right mouse button, then select Enterprise Bean> Enter the Remote Interface (Enterprise Bean> Promote to Remote Interface), make sure the method is added to the remote interface. One of the many powerful powers of the test application WebSphere Studio tool is that it has the ability to make cell testing of components in the environment of built-in application servers. Server perspective contains several different built-in application servers, including WebSphere application servers. One key benefit of this test method is that you can test and debug Java components in your integrated development environment (IDE), which is more than the application's code to the application server, and then test And debugging is simple and convenient. To test components, you need to build: Open Server Perspective (Server Perspective) Create a server item and naming, click New> Server Project (New> Server Project.) On the File menu and name Servers to create server instances and server configuration. On the File menu, click New> Server Instance and Configuration (New> Server Instance and Configuration). Name WAS V4 Local Test and confirm that it is placed in the server project. Here you also need to point out this server has a WebSphere V4 test environment. You have now established an application server, you can start, stop and install application code to this application server. This application server is very similar to the application server of your product environment in addition to your debugging environment. Next, you should create a data source for this server configuration by the following steps:
On the server configuration view, double-click WAS V4 Local Test Configuration and select the DataSource label. The name is ATM, setting JNDI Name as JDBC / ATM, data is ATM, see Figure 7. Save your changes. Figure 7. Add a data source You have added information about the data source for the WebSphere application server, and you also need to provide some other information. Add a data source information for the configuration environment related to the previously established EJB module. Most importantly, the name of the data source JNDI must be identical to the JNDI name of the referenced data source in the EJB module configuration. In order to edit the settings of the data source in the EJB module, you should use the EJB extended editor, steps as follows: Open the J2EE view to select the atmejb module, click the right mouse button, select the EJB extended editor to open (Open with ejb extension editor), then press Bindings label Setting the JNDI name of the ATMEJB Module Setting the data source as JDBC / ATM, as shown in Figure 8, saves your change (CTL-S) Figure 8. The name of the setting data source is now returned to the server perspective. The next step is very simple, but it is quite important. The main purpose of the Enterprise Archive Resource File (EAR) is to package all the necessary components in the app into a single file. This makes it easier to deploy applications, which also implements the application of J2EE's J2EE on applications that can be installed on different vendors J2EE specifications. In fact, it describes the packet mechanism of J2EE-related components and web components through an XML file. In any case, you need to add you before you create an Atmear module to the WebSphere server configuration, steps below:
Open the server perspective In the server configuration view, select WAS V4 Local Test to click on the right mouse button, select Add Project, then select EAR Module Atmear Now you need to launch the WebSphere application server configuration, steps below:
In the server control panel of the Server Perspective, select WAS V4 Local Test Click the right mouse button to select the application server selection (START). You will see the startup information in the console. When "Server has already e-commerce development" information in the console, your application server has been successful. Now your application server has started and run, you can test the components to test the components with EJBs you designed and created by using the IBM EJB test client program. Proceed as follows:
Open the J2EE perspective to select the atmejb project, then select Run ON Server to test Customer EJB by clicking from the JNDI browser from the pop-up menu. Use the indeMerhhhhome using the IndbyPrimaryKey () method, and then use the created Customer object to test by using the EJB test client program is a process that contains multiple steps. Remember, the EJB test client program is a universal test program, which is a built-in graphical application that is the function of testing your code; it is not an end user application. For example, once you "load" MakePayment method, it will try to pass parameters and finally call the method. E.g:
Click the MakePayment link in the relevant view for the first parameter, in Java.math.BigDecimal, select BigDecimal (Double) for the constructor, when the value domain appears, enter a numeric value (such as 25.00), then call and Returns the value of a java.lang.string type, when the value domain appears, enter a name, such as "HOMER", then click the call and return once the parameters are provided, click Invoke to test method. If some is normal, the balance will be reduced and your payment information will appear in the console. You can make multiple test operations through the MakePayment link. Figure 9 shows the test view Figure 9. Browse the test results Congratulations! You have completed the design, implementation and testing of this mini development cycle by using different plugins from the IBM WebSphere Studio and XDE Tool Suite. Nothing Tad hopes to express their gratitude to the following main contributors of this sample: Rick Weaver, IBM Global Tools Technical Sales Personnel; Patrick Cadonau, IBM Switzerland, Technical Experts; Mathias Staub, IBM Rational Switzerland, Consultant. Reference
Learn about WebSphere products and communities, please visit WebSphere to develop this garden website. At the DeveloperWorks Rational Software Resource Center, you can find a series of articles for developers. Learn more IBM's Rational software, access the Rational website. Access Eclipse.org, you can find all the information about Eclipse. In the Object Management Organization (OMG) home page, read more about UML. Do you want to subscribe to the developerWorks toolbox? Visit WebSphere Studio Application Developer for Windows, Version 5.