Bean Extender: Guide to Demos

Setting Up

This section discusses the steps in setting up a computer or computers to run the Travel Services demo. This demo may be built and run on a single computer (in which case the FlightInfoDap data access part bean is used) or the demo may be built and run on two machines as a multi-tier demonstration (in which case the FlightInfoDap data access part bean is split into two beans: a FlightInfoDapClient bean which is on the client machine and a FlightInfoDapServer bean which is on the server machine). Note that if you choose to build the multi-tier demo you must be running with the Java JDK 1.1.3 or later.

It is better to perform some of the assembly before starting the demo to make the demo less repetitive and less time consuming. For example, consider assembling the FlightSelector and Itinerary beans before the demo. Then, during the demo, add the FlightInfoDap bean (or the FlightInfoDapClient bean in the case of an RMI remote demo) to illustrate the procedure. Note that all references throughout this document to FlightInfoDap should be read as references to FlightInfoDapClient if you are constructing the demo using the RMI remote capabilities.

Perform the following steps to set up your computer for the Travel Services demo:

  1. Make local copies of the following files.

    Where product represents the name of the directory in which you installed Bean Extender.
    Note:Using local copies avoids entering long path names during the demo and ensures that you have write access to the classes to be morphed. This step lists the full path for the files you should copy. The remainder of the demo uses only simple file names.

  2. Copy all .gif files from the following directory to the Assembly Surface working directory (that is, the directory from which you start the Assembly Surface):
    product/src/com/ibm/beans/demos/travel/images/*.gif
    

  3. Make a backup copy of the FlightInfo.jar file. This backup copy will be used during the cleanup phase.
    Note:Running the demo modifies this file, and you cannot rerun the demo unless you have an unmodified copy of the FlightInfo.jar file.

  4. Start the Assembly Surface, if it is not already running. To start the Assembly Surface, enter:
    java com.ibm.beans.tools.assembly.AssemblySurfaceMain
    

    Notes:

    1. For ease-of-use, consider starting the Assembly Surface from the working directory you set up when configuring for the demos (that is, the work directory).

    2. After starting the Assembly Surface, if you do not see a Repository button in the top right corner, you need to resize the window until the button is visible.

  5. Display the Beans view, if not already displayed. To display the Beans view, click on View/Beans on the menu bar. A Repositories tab displays in the Client section of the Assembly Surface. The Client section is below the Bean tab.

  6. Load the required files into the Assembly Surface in the following order:
    A. awidgets.jar
    B. calendar.jar
    C. controls.jar
    D. media.jar
    E. Travel.jar
    F. FlightInfo.jar
    G. FlightSelector.jar
    To load each file, use the following procedure:
    A. Click on the Repositories tab in the center region of the Assembly Surface working area, under the Beans tab.
    B. Click on the Add File Repository button at the bottom of the Assembly Surface.
    C. Use the Open File dialog window to specify the location of one of the repository files. A new notebook tab, labeled with the name of the file you added is displayed under the Beans tab in the center section of the Assembly Surface working area.
    Repeat this procedure to load the remaining files.
    Note:You must load these files in the listed order. Ignore any error messages while loading FlightInfo.jar and FlightSelector.jar.

  7. Add beans to the Assembly Surface:
    A. Click on the Beans tab. Additional tabs are displayed in the center section of the Assembly Surface working area.
    B. Click on the travel.jar tab. The Itinerary bean is displayed.
    C. Select the Itinerary bean by clicking on it.
    Note:A bean is selected when it is outlined in gray.
    D. Click on the Add beans button. The Itinerary bean is displayed in the left section of the Assembly Surface working area.
    E. Layout the Itinerary bean. Click on View/Layout from the menu bar. The Layout notebook page is displayed in the center section of the Assembly Surface working area and the Layout tab is added to the view.
    F. Right-click on the Layout tab and click on Move view to window to display the layout in an independent window.
    G. Resize the Layout window so that all eight of the adjusting handles are visible and then minimize the window.
    H. Click on the Beans tab and then click on the FlightSelector tab.
    I. Add the FlightSelector bean to the left section of the Assembly Surface working area.

  8. Connect the beans together:
    A. Click on View/Event Connections on the menu bar.
    B. Connect the FlightSelector bean to the Itinerary bean by picking the following connections from the Event Connections view:

    Event Source

    FlightSelector

    Source Events

    FlightRequested

    Event Targets

    Itinerary

    Target Methods

    FlightRequested

    The columns are filled in automatically as you make selections from left to right, so your choices are limited.

    C. Click on the Connect button at the bottom of the Assembly Surface. The current event connections are displayed at the bottom of the Event Connections notebook page.

  9. Script the FlightSelector bean and the Itinerary bean to interact. This procedure sets up three scripts as the first step toward making the FlightSelector bean respond to events from the DAP and the itinerary. To define these scripts:
    A. Click on View/Scripting on the menu bar to display the Scripting notebook page, if the Scripting view is not already displayed. Three icons and a combination box are displayed on the notebook page.
    B. Click on the blue ball icon. A tree view of available objects to script is displayed.
    C. Click on the Script0 object.
    Note:You can select the Script0 object by clicking on the "Script0" text.
    The center section divides into two sections. The left section continues to display the tree view of available objects to script. The right-hand section is a scripting area containing:
    • An icon in the upper left-hand corner.
    • A combination box beside the icon.
    • A text area beneath the icon and combination box.
    D. Click on Script Globals in the combination box at the top of the new (right-hand) section.
    E. Click on the text area and enter:
    java.awt.Frame myFSFrame=null;
    
    F. Click on public void initialize() in the combination box.
    G. Click on the text area. Ensure that the cursor is positioned between the curly braces and enter:
    myFSFrame=new java.awt.Frame();
    myFSFrame.add(FlightSelector);
    myFSFrame.pack();
    
    H. Click on the FlightSelector bean in the tree view of available objects to script.
    I. Click on public void FlightSelector_actionPerformed(java.awt.event.ActionEvent arg0 in the combination box.
    J. Click on the text area. Ensure that the cursor is positioned between the curly braces and enter:
       myFSFrame.setVisible(false);
    

  10. Clean up the Assembly Surface:
    A. Remove the Event Connections view from the Assembly Surface. You can either right-click the Event Connections tab and click on Close view on the pop-up menu or click on View/Event Connections on the menu bar.
    B. Remove the Scripting view from the Assembly Surface.
    C. Unload the FlightInfo.jar repository. During the demo, you can load this repository as a typical example of loading a repository.

    1. Click on the Beans tab to return to the Beans view.

    2. Click on the Repository tab to display the Repository notebook page.

    3. Click on FlightInfo.jar from the list of currently loaded JAR files.

    4. Click on the Remove repository button at the bottom of the Assembly Surface.

  11. Only do the following if you are planning to use the remote RMI travel demo capabilities:
    A. Install any needed database software and start all necessary daemons on the server machine. For example, the default database implementation assumes that you are using DB/2 as your database. If you accept the default, you must install DB/2 and issue the db2start command. The rmiregistry daemon must always be started by typing: rmiregistry.
    B. Set up your environment so that needed jar files can be found by setting your CLASSPATH to include the jars subdirectory off of where you installed BeanExtender. For example, you would issue the following command - set CLASSPATH=c:\extender\jars;%CLASSPATH% - assuming that you installed BeanExtender in c:\extender
    C. Build the database on the server machine by running the following application:
    java com.ibm.beans.tools.JarJava com.ibm.beans.demos.travel.flight.CreateDB
    
    This application uses JDBC to build the sample database with a default JDBC URL value of: "jdbc:odbc:DB2" and a default database table name value of: "FlightInfoTbl". If you need to change these values you may do so by adding command line arguments for both of these variables when you invoke the application:
    java com.ibm.beans.tools.JarJava com.ibm.beans.demos.travel.flight.CreateDB myJDBCURL mydbTableName
    
    If the records are successfully added to the database, they will be displayed in the GUI and an "All records were successfully entered into the database!" message will be presented.

Aggregation

Scripting

  1. Add the Scripting View to the Assembly Surface:
    A. Click on View/Scripting on the menu bar to display the Scripting notebook page, if the Scripting view is not already displayed. Three icons and a combination box are displayed on the notebook page.
    B. Click on the icon that resembles a blue ball. This is the Beans view of the Scripting IDE and shows all the beans that are instantiated.
    Note:The other two icons split the selected section of the Assembly Surface horizontally or vertically.
    C. Click on FlightInfoDap (or the FlightInfoDapClient) bean from the list of instantiated beans. A new section of the Assembly Surface is displayed on the right.
    Note:Click on the word "FlightInfoDap" or "FlightInfoDapClient", not on the plus sign (+) beside it.
    D. Insure that you have selected the FlightInformationChanged method. It should be the method that is visible in the drop down list.
    E. Position the cursor between the curly braces and enter:
    Point pt = Itinerary.getLocationOnScreen();
    myFSFrame.setLocation(pt);
    myFSFrame.setVisible(true);
    FlightSelector.setVisible(true);
    
    Alternatively, if you have the code in a file, you can click on the icon above the curly braces (the icon that resembles a piece of paper) to import the contents of the file.

  2. Generate the new aggregate bean:


    A. Supply information about the new bean in the Class, Extends, Package, and Repository fields in the control area of the Assembly Surface.

    The class and package cannot be the same and cannot start with a number. For example, you might enter TravelDemo for the class, com.ibm.beans.Demo for the package, and TravelDemo.jar for the repository. Do not change the default contents of the Extends field (the default contents are java.awt.Panel).

    B. Click on the Generate button in the action area of the Assembly Surface. Status messages are displayed in the status area of the action area of the Assembly Surface. The generation is complete when the "Successfully generated..." message is displayed in the status area and the Run button in the action area of the Assembly Surface is enabled.

    Run the new aggregate bean:
    A. Click on the Run button in the action area of the Assembly Surface. A window opens to run the new aggregate bean. This window contains a logo at the top and a row of buttons at the bottom. If necessary, resize the window so that the buttons are visible.
    B. Click the Add Flight button at the bottom of the window. Two input fields are displayed in the right-hand side of the window.
    C. Enter the city of origin (Austin) into the Depart from field and a destination city (either Dallas or Chicago) into the Arrive at field.
    D. Click on the Click HERE to select flight label. The FlightSelector bean displays the corresponding flight choices for the stated parameters in a new window. Click on the desired flight and click on the Ok button. Information about the selected flight is displayed in the main window of the aggregate bean. To select alternate flights, click on the Click HERE to select flight label again and repeat the procedure. To add additional flights, click on the Add Flight button at the bottom of the window and repeat the procedure.
    E. When finished viewing the running aggregate bean, close the window by clicking the Stop button in the action area of the Assembly Surface.

Dipping

  1. Morph the FlightInfoDap bean (or the FlightInfoDapServer bean on the server machine if running the remote RMI demo) as a subclass of the original bean:
    A. Click on View/Beans from the menu bar.
    B. Click on the FlightInfo.jar tab.
    C. Click on the FlightInfoDap (or FlightInfoDapServer) bean, if not already selected.
    D. Click on the Morph bean button at the bottom of the Assembly Surface. The Morph Beans window is displayed. The Inheritance morphing option should be selected and the Save with original location should be specified.
    E. Click on the Morph selected bean button at the bottom of the Morph Beans window. A progress window is displayed.
    F. When the progress window closes, click on the Done button at the bottom of the Morph Beans window. The FlightInfoDapDippable (or FlightInfoDapServerDippable if you are morphing the server side for the remote RMI demo) bean icon is displayed in the Beans view.
    Note:You can select the new bean and click on the Run button in the action area of the Assembly Surface to see that the dippable bean looks and acts like the original. Close the window in which the bean is running when you finish.

  2. Replace the non-dippable FlightInfoDap (or FlightInfoDapServer) bean:
    A. Click on the FlightInfoDapDippable (or FlightInfoDapServerDippable) bean.
    B. Click on the Add beans to assembly button at the bottom of the Assembly Surface. An instance of FlightInfoDapDippable (or FlightInfoDapServerDippable) is added to the Contents list in the left section of the Assembly Surface working area. Note that if you are building the remote RMI demo you will have to reconfigure the customizer for the FlightInfoDapServerDippable bean as described earlier.
    C. Click on the FlightInfoDap (or FlightInfoDapServer) bean.
    D. Click on the Delete button at the bottom of the Contents list. The non-dippable bean is removed from the Contents list.

  3. Connect the FlightInfoDapDippable bean to other beans (note that if you are building a remote RMI demo it is not necessary to redo these connections as the connections are made to the FlightInfoDapClient bean which has not been modified!):
    A. Click on View/Event Connection on the menu bar.
    B. Pick the following items from the columns, then click on the Connect button at the bottom of the Assembly Surface to establish each event connection.

    Connect the Itinerary bean to the FlightInfoDapDippable bean by selecting:

    Event Sources

    Itinerary

    Source Events

    FlightRequested

    Event Targets

    FlightinfoDapDippable

    Target Methods

    FlightRequested

    C. Click on the Connect button at the bottom of the Assembly Surface. The current event connections are displayed at the bottom of the Event Connections notebook page.
    D. Connect the FlightInfoDapDippable bean to the Itinerary bean by selecting:

    Event Sources

    FlightInfoDapDippable

    Source Events

    FlightReserved

    Event Targets

    Itinerary

    Target Methods

    FlightReserved

    E. Click on the Connect button at the bottom of the Assembly Surface. The current event connections are displayed at the bottom of the Event Connections notebook page.
    F. Connect the FlightInfoDapDippable bean to the FlightSelector bean by selecting:

    Event Sources

    FlightInfoDapDippable

    Source Events

    FlightInformationChanged

    Event Targets

    FlightSelector

    Target Methods

    FlightInformationChanged

    G. Click on the Connect button at the bottom of the Assembly Surface. The current event connections are displayed at the bottom of the Event Connections notebook page.
    H. Connect the Itinerary bean to the FlightInfoDapDippable bean by selecting:

    Event Sources

    Itinerary

    Source Events

    TravelInfoChanged

    Event Targets

    FlightinfoDapDippable

    Target Methods

    TravelInfoChanged

    I. Click on the Connect button at the bottom of the Assembly Surface. The current event connections are displayed at the bottom of the Event Connections notebook page.

  4. Rescript the DAP (note that if you are building a remote RMI demo this step is not necessary as the scripting is applied to the client side FlightInfoDapClient bean which has not changed!):
    A. Click on View/Scripting on the menu bar to display the Scripting notebook page, if the Scripting view is not already displayed. Three icons and a combination box are displayed on the notebook page.
    B. Click on the icon that resembles a blue ball. This is the Beans view of the Scripting IDE, and shows all the beans that are instantiated.
    Note:The other two icons split the selected section of the Assembly Surface horizontally or vertically.
    C. Click on FlightInfoDapDippable from the list of instantiated beans.
    Note:Click on the text, not the plus sign (+) beside it.
    A new section of the Assembly Surface is displayed on the right.
    D. Position the cursor between the curly braces and enter:
    Point pt = Itinerary.getLocationOnScreen(); myFSFrame.setLocation(pt);
    myFSFrame.setVisible(true);
    FlightSelector.setVisible(true);
    
    Alternatively, if you have the code in a file, you can click on the icon above the curly braces (the icon that resembles a piece of paper) to import the contents of the file.

  5. Apply the dip:
    A. Click on View/Dips/Available dips from the menu bar.
    B. Load the dip to be applied by clicking on the Add file repository button at the bottom of the Assembly Surface, then specifying the location of the FlightRules.jar file. Two icons are displayed representing the following dips:

    CarrierRestrictionDip

    Restricts a specific carrier from appearing in the list of possible flights.

    ConnectingFlightDip

    Restricts direct flights with a difference in cost exceeding a specified amount (compared to a scenario involving connecting flights) from appearing in the list of possible flights.

    Note:The dips can be applied one at a time or simultaneously. The demo applies the dips one at a time.
    C. Click on the CarrierRestrictionDip dip, then click on the FlightInfoDapDippable (or FlightInfoDapServerDippable in the remote RMI demo) bean in the contents list in the left section of the Assembly Surface.
    D. Click on the Apply dips to selected bean button at the bottom of the Assembly Surface. A customization window for the dip is displayed.
    E. In the customization window, enter the name of an airline in the Carrier field. Click on the Apply button and then click on the Done button.
    F. Click on the ConnectingFlightDip dip, then click on the FlightInfoDapDippable (or FlightInfoDapServerDippable in the remote RMI demo) bean in the contents list in the left section of the Assembly Surface.
    G. Click on the Apply dips to selected bean button at the bottom of the Assembly Surface. A customization window for the dip is displayed.
    H. In the customization window, enter a dollar amount (for example, $100) that should not be exceeded in the Dollar amount field. Click on the Apply button and then click on the Done button.
    I. View the applied dips. Click on View/Dips/Applied dips on the menu bar to display a window listing all dips that have been applied.
    Note:You can display the Applied Dips window before applying the dips to verify that no dips were initially applied to the bean.

  6. Regenerate the aggregate bean (note that this step does not need to be done if you are using the RMI remote demo as there have been no changes to the client):
    A. Modify the class name in the control section of the Assembly Surface. For example, you might use the class name "TravelDemoDipped."
    B. Click on the Generate button in the action area of the Assembly Surface. Status messages are displayed in the status area in the action area of the Assembly Surface. When the status messages complete, the aggregate bean has been generated.

  7. Run the generated bean:
    A. Click on the Run button in the action area of the Assembly Surface.
    B. Verify that when the user requests the list of possible flights, the carrier that was restricted when customizing the dip does not appear in the list. Further, any direct flights with a difference in cost greater than $100 compared to a scenario involving connecting flights do not appear in the list of possible flights. Otherwise, the bean works as before.

Cleanup

Restore the system to its original state:

  1. Exit the Assembly Surface by clicking on File/Exit on the menu bar.

  2. Remove the contents of the working directory (work).

  3. Restore the FlightInfo.jar file to its original state, using the backup copy you made earlier. This removes the FlightInfoDapDippable (or FlightInfoDapServerDippable) bean from the JAR.


[ Top of Page | Previous Page | Next Page | Table of Contents | Documentation Homepage ]