SimpleBank BMP Robean Sample Application |
SimpleBank BMP Robean Sample Application
This document describes how to utilize the SimpleBank BMP Robean sample application in conjunction with the Application Server.This sample application document contains the following sections:
- Overview
- Compiling and Assembling the Application
- Deploying the Sample Application
Overview
This sample demonstrates the support for Read Only Beans (ROBs) in the application server. ROBs are entity beans that are never modified by an EJB client. Entity beans can be declared as ROBs by specifying the is-read-only-bean element in the sun-ejb-jar.xml. The data that an ROB represents may be updated by external means. ROBs are useful when the data they represent does not change or the change is not frequent. In such cases the cost of ejbStore can be avoided by the use of ROBs.There are certain restrictions on ROBs. ROBs cannot start their own transactions, only container transactions are allowed. Container will not call ejbStore on ROBs. The ejbLoads will be called only when a bean is created or when a transactional method is called or at refresh intervals. ROBs Home interface need not have ejbCreate and ejbRemove methods.
The state of ROBs can be refreshed by different means:
- Invoking a transactional method can refresh the state of ROB. In the sample all the methods of CustomerTransactionalEJB are defined as transactional. To refresh the state of CustomerTransactionalEJB, servlet invokes getBalance method of CustomerTransactionalEJB which is transactional.
- The state of ROBs can be refreshed periodically by specifying the refresh-period-in-second in sun-ejb-jar.xml. If the period specified is negative, the state of ROB will never be refreshed. If the period specified is '0', the state of ROB will always be refreshed. If the period specified is greater than zero, the state of ROB will be refreshed periodically at that rate. In the sample CustomerRefreshEJB has refresh period of 60 seconds, so the state of CustomerRefreshEJB is refreshed every minute.
- The state of ROBs can be refreshed programmatically. The beans which update data used by the ROBs, need to notify the ROBs to refresh their state. The state of the ROB can be updated with the help of ReadOnlyBeanNotifier. The state of CustomerProgRefreshEJB in the sample is updated programmatically as follows:
- ReadOnlyBeanNotifier notifier = ReadOnlyBeanHelper.getReadOnlyBeanNotifier("java:comp/env/ejb/customerProgRefresh");
- notifier.refresh(new PKString1(SSN));
In order to successfully deploy and run the SimpleBank BMP Robean sample application, Database resources (PointBase) needs to be setup with the Application Server.If you want to run this sample on Oracle Database, please refer to (How to run sample applications with Oracle ) .
Compiling and Assembling the Application
This section contains instructions to build and assemble the SimpleBank BMP Robean sample application using a Command Line Interface (CLI). Please refer to the Sample Application Build Facility document for details on using a build facility.To rebuild the entire application from scratch, follow these steps:
- Compile and Assemble the application.
- Execute the asant command under <install_dir>/samples/ejb/bmp/apps/robean.
- The default target core is executed to rebuild the .ear file.
- Deploy the application.
- After you have re-created the sample application from scratch, proceed to Deploying the Sample Application.
- Clean the application project area.
- Execute the command asant clean to clean the application area.
- Undeploy the application.
- Execute the command asant undeploy to undeploy the application.
- Build Javadocs.
- Execute the command asant javadocs to create Javadocs.
- The Javadocs are created under <install_dir>/samples/ejb/bmp/apps/robean/javadocs.
NOTE: You must start the Database.
Please ensure that the database is started, (see How to start Database) before proceeding with deploying and running the sample application.
Deploying the Sample Application
In this section, you will learn how to deploy the SimpleBank BMP Robean sample application.A pre-built bmp-robean.ear file is supplied with the application server installation. The pre-built bmp-robean.ear file is the Enterprise Archive (.ear) file of the application, which contain the ejb jar and war files. Within the ejb jar and war files reside the .xml deployment descriptor files, application class files, and other content required by the application. You can use the pre-built .ear file to deploy the application. If you want to compile and assemble the application from scratch, follow the instructions under Compiling and Assembling the Application.
To deploy the application, the administrative server needs to be running.
To start the administrative server if it is not already started:
Select one of the following approaches to deploying the application:
- For UNIX:
- Execute <install_dir>/bin/asadmin start-domain --domain domain1
- For Windows:
- Start-->Programs-->Sun Microsystems-->J2EE 1.4 SDK-->Start Default Server
Command Line-based Deployment
- Command Line-based Deployment describes how to manually register the application in the Application Server using a Command Line Interface (CLI). This is the fastest means of deploying the sample application.
- GUI based Deployment describes how to use the Application Server Admin GUI to import and deploy the sample application.
Since a complete EAR file is supplied, the fastest means of setting up the application is to use the command line utilities as described in this section. The deployment process includes deploying the application .ear file to th application server. CLI deployment of the application can be performed using either the asant script or the asadmin command.
To deploy the application using the asant command:
You are now ready to exercise the application by Running the Sample Application.
- >cd <install_dir>/samples/ejb/bmp/apps/robean
- Execute the asant deploy command.
- It is an interactive command that might prompt you to provide the admin-server host, admin-server port, admin user name, admin password and server instance name.
To deploy the application file using the asadmin command:
The deployment process involves the following operations:
- >cd <install_dir>/samples/ejb/bmp/apps/robean
- Execute the following command:
- asadmin deploy --user <user-name> --password <password> bmp-robean.ear.
- Now you need to register the resources to the application server. Proceed to Configuring Resources.
- It authenticates against the local application server's administrative server
- The .ear file is transferred to the administrative server.
- The administrative server begins the registration process:
GUI Based Deployment
Since a pre-built Enterprise Archive (.ear) file for the sample application is included with the application server, you can use the Admin GUI to quickly read in the .ear file and deploy it to the application server.
- Start the admin server if it is not already started. Here are the commands for each platform:
- Unix - Execute the <install_dir>/bin/asadmin start-domain domain1 command.
- Windows - Click "Start->Programs->Sun Microsystems->J2EE 1.4 SDK->Start Default Server" command.
- Open the .ear file.
Now you need to register the resources to the application server. Proceed to Configuring Resources.
- Start Admin GUI, by entering URL http://localhost:<admin.port>/asadmin in browser. See replacing "localhost" and <admin.port> note here to determine correct values to use for your environment
- You are prompted to supply the user name and password of the application server. Enter correct values for your installed application server for "User Name:" and "Password:" input fields, then click on the "Login" button.
- In the left-hand frame, click Applications-->Enterprise Applications icon in the tree.
- In the right-hand frame, click on the "Deploy..." button.
- Choose the file to be deployed by clicking on the "Browse..." button, and navigate to select component to deploy (bmp-robean.ear). The file is located under <install_dir>/samples/ejb/bmp/apps/robean.
- In the browse dialog, click on the "OK" button.
- In the right-hand frame, click on the "Next" button.
- In the right-hand frame, click on the "OK" button. (Optionally fill in remaining values for application to be deployed)
- In the left hand pane, you will see the newly deployed module's icon in the tree. In the right hand pane you will also see the component listed as deployed.
This section describes how to create resources required for running bmp-robean application. You do not need to register them separately when you deploy the application using the asant deploy command. However, the resources can be registered as follows:
- JDBC Resource and its Associated Connection Pool
- asadmin create-jdbc-connection-pool --user <user> --password <password> --host <admin host> --port <admin port> --datasourceclassname <datasource classname> --property User=bmp:Password=bmp:<url-property>="<database jdbc url>" bmp-robean-pool
In case of PointBase, please use DatabaseName as <url-property>. In case of Oracle, please use correct value for <url-property>. You will need to escape ":" and "/", in <database jdbc url>. An example of <database jdbc url> is "jdbc\:pointbase\:server\:\/\/localhost\:9092\/sun-appserv-samples".
- asadmin create-jdbc-resource --user <user> --password <password> --host <admin host> --port <admin port> --connectionpoolid bmp-robean-pool jdbc/bmp-robean
Running the Sample Application
Perform the following steps to run the sample application:
- Go to http://<hostname>:<port>/SimpleBank/index.html
- Enter 123456789 as Customer Social Security Number.
- Click Enter.
- Enter amount in $ text box and click Update.
- Current Balance will be updated.
- Click on Get Trans. Balance.
- Transactional Refresh will be updated.
- Click on Get Prog. Balance.
- Programmatic Refresh will be updated.
- Wait for thirty seconds.
- The page will be refreshed and Time-based Refresh will be updated.
Generating javadocs
To better understand sample application source code, you may refer to the related javadocs.To generate javadocs, run one of the following commands:
After javadocs are generated, you may access them at <install_dir>/samples/ejb/bmp/apps/robean/javadocs/index.html.
Troubleshooting
If you encounter problems when running the application, review the log files at <install-dir>/domains/<domain_name>/logs/server.log to learn what exactly went wrong.
Copyright © 2004 Sun Microsystems, Inc. All rights reserved.
Last Updated March 6,
2004