Corporate Info | News | Solutions | Products | Partners | Services | Events | Download | How To Buy
Commerce Servers Doc Home | WebLogic Components Doc Home | Hands-On Tour | Previous Topic | Next Topic | Contents

Implement

This topic includes the following sections:

- Overview of Implementation

- Prerequisites for Implementing

- Directions for Implementing

Overview of Implementation

Having finished using Rational Rose to model two new WebLogic Components that will serve as the basis for the My BuyBeans site modifications, you are now prepared to implement your solution. You assemble your team and plan your next steps.

Since you are a knowledgeable WebLogic Components developer, you know that implementation with WebLogic Components involves exporting the Rational Rose model using BEA's Rational Rose Plugin, generating Enterprise Java Bean (EJB) implementations of your WebLogic Components using BEA's Smart Generator, and then adding any necessary custom business logic to the EJBs. You also realize that presentation logic for the new BeanieHat Component must be developed.

Prerequisites for Implementing

In order to fully understand this section of the tour, it is recommended that you have a general understanding of BEA Smart Generator application, HTML, and the Java programming language. You must also have successfully completed all steps of the Design section of the tour.

Directions for Implementing

Step 1. Open the copy of BEA WebLogic Components Rational Rose model.

1. Start Rational Rose.

2. Click on the Open menu item in the File menu.

3. Navigate to the model\tour directory found under the WebLogic Components installation directory.

4. Double click on BEA WeblogicAC.mdl.

Step 2. Export the model using BEA's Rational Rose Plug-In.

1. Click on the WebLogicAC menu item in the Tools menu.

2. Click on the Export Model As submenu item.

3. Navigate to the src directory found under the WebLogic Components installation directory.

4. Name the file bbtour and then click on the Save button.

5. Click the OK button in the Success dialog.

Step 3. Create a new Smart Generator project.

1. Start the Smart Generator. You can do this by first selecting the WebLogicAC menu item in the Tools menu and then clicking the Smart Generator submenu item.

2. Click on the New Project menu item in the File menu. This should open a Project Properties dialog.

3. Name the project bbtour.

4. Designate the src directory found under the WebLogic Components installation directory as the EJB Code Generation Output Directory.

5. Designate the deploy\weblogic\cloudscape\src directory found under the WebLogic Components installation directory as the Deploy Code Generation Output Directory.

6. Designate the bbtour.tast file generated in Step 2 as the TAST Model File.

7. The Project Properties dialog should now look something like the following:

   Note: This assumes that the WebLogic Components installation directory is D:\opt\WebLogicAC:

Step 4. Configure the project.

1. Click on the Packages tab.

2. Scroll down in the Packages pane until the examples.buybeans.tour entry is visible, then click on this entry.

3. In the Classes pane, double-click on the boxes next to the BeanieHat and BeanieHatPricePolicy classes. This should check both of the boxes.

4. The Project Properties dialog should now look something like the following:

5. Click on the OK button.

Step 5. Generate EJB implementations of the BeanieHat and BeanieHatPricePolicy Components.

1. In the Project pane, highlight the project entry that was created in Step 4 by clicking on it.

2. Click on the Generate button. Your EJB implementations of the BeanieHat and BeanieHatPricePolicy WebLogic Components are now being generated.

3. Wait for the Smart Generator to finish and then click on the Exit button.

Step 6. Implement custom business logic in the BeanieHatPricePolicy Component

1. Using your favorite editor, open the file BeanieHatPricePolicyImpl.java located in the src\examples\buybeans\tour directory under the WebLogic Components installation directory. This file is one of several generated by the BEA Smart Generator.

2. Locate the calculatePrice function and find the following line of code:

   >     return null;

3. This is the default implementation of the pricing policy associated with the BeanieHat Component. We would like to implement the custom pricing policy for a beanie hat (as outlined by Management), so REPLACE the above line of code with the following lines, and then save the file:

   >     // Policy: Price = base price + $2.00*propellers
   >     // Use values object for speed! This way we don't need to
   >     // make a heavy remote + database call every time.

   >     try
   >     {
   >       // Get Value Object BeanieHatValue
   >       BeanieHatValue bhv = ((BeanieHat) item).getBeanieHatByValue();

   >       // Get item's base price
   >       theory.smart.axiom.units.Price p = bhv.price;

   >       // Calculate the price of the beanie hat
   >       double newValue = p.getValue() + 2.00*bhv.propellers;

   >       // Return a new price. Do NOT re-set the item's price.
   >       // That should always be the base price

   >       theory.smart.axiom.units.Price newPrice = theory.smart.axiom.units.PriceHome.create();
   >       newPrice.setValue(newValue);

   >       return newPrice;
   >     }

   >     catch (ClassCastException ce)
   >     {

   >       // If we are here then the caller did not pass us a BeanieHat

   >       throw new java.rmi.RemoteException("BeanieHatPricePolicy: item is not a BeanieHat");
   >     }

Step 7. Implement presentation logic for the new BeanieHat Component.

1. Using your favorite editor, open the file productDetails.jsp located in the server\public_html\portals\buybeans\portlets directory under the WebLogic Components installation directory. This file contains the presentation logic for each beanie item WebLogic Component.

2. Locate the following line of code:

   >     <%@ page import="examples.buybeans.item.*" %>

3. Insert the following line of code AFTER the above line of code:

   >     <%@ page import="examples.buybeans.tour.*" %>

4. Locate the following line of code:

   >     <%-- COFFEE BEAN SPECIFIC PRODUCT INFORMATION     --%>

5. Insert the following lines of code BEFORE the above line of code (and AFTER any code that preceeds the above line of code) and save the file. You can get a little creative here if you are familiar with HTML:

   >     <%-- BEANIEHAT SPECIFIC PRODUCT INFORMATION     --%>
   >     <%
   >        if (myItemValue instanceof BeanieHatValue)
   >        {
   >        %>
   >       <tr>
   >         <td>
   >           <table width="95%" border="0" cellpadding="3" bgcolor="#FFFFFF" align="center">
   >            <tr bgcolor="#339966">
   >               <td> <font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Color:
   >                 <%= ((BeanieHatValue) myItemValue).color %></b></font>
   >               </td>
   >               <td> <font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Propellers:
   >                 <%= ((BeanieHatValue) myItemValue).propellers %></b></font>
   >               </td>
   >             </tr>
   >             <tr bgcolor="#CCCCCC">
   >               <td colspan=3> <font face="Arial, Helvetica, sans-serif" size="2" color="#000000">Each propeller raises the base price of a beanie hat by $2.00.</font> </td>
   >             </tr>
   >           </table>
   >         </td>
   >       </tr>
   >     <%
   >        }
   >     %>

Copyright © 2000 BEA Systems, Inc. All rights reserved. Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.