uCosminexus Application Server, Application Development Guide
This section gives an overview of the sample project (Bank) provided by Developer.
The sample project (Bank) provided by Developer is a program that transfers the funds of a user having the User ID entered in the Web browser from a current account (Checking Account) to a savings account (Savings Account). If you enter the user ID and the transaction amount on the displayed window, and then click the Transfer button, the specified amount will be transferred from the current account of the specified user to the savings account. The funds will be managed in the database, and the current account table and savings account table will be updated when the funds are transferred.
The following figure shows the configuration of this sample project (Bank):
Figure A-1 Overview of the sample project (Bank)
In this sample project (Bank), an annotation is used to connect to the database.
The processing will be executed for the specified user ID and amount of money. The following table describes the initial balance that can be specified in 'Bank' for each user ID and the user.
Table A-1 Initial settings of the sample project (Bank)
User ID | Checking Account# | Savings Account# |
---|---|---|
001 | 10,000 | 500 |
002 | 20,000 | 1,000 |
003 | 30,000 | 1,500 |
With the EJB of the sample project, the database is also accessed by acquiring the resource adapter with the @Resource annotation. The specification contents of the @Resource annotation are as follows:
@Resource(mappedName="DB_Connector_for_Cosminexus_Driver") private DataSource dataSource; |
With a servlet (Web container), the EJB will also be accessed by acquiring the EJB with the @EJB annotation. The specification contents of the @EJB annotation are as follows:
@EJB(name="BankEJB") private BankIF bank ; |
Note that the reference name BankEJB specified in the @EJB annotation is defined as follows in the coding of BankEJB:
@Stateful(name = "BankEJB") |
This annotation expresses that the EJB is a 'Stateful Session Bean'.
In Appendix A, the procedure for using the sample project (Bank) is described with the following environment as a prerequisite:
The following projects are provided with the sample project (Bank):
Table A-2 Projects provided with the sample project (Bank)
Project name | Summary |
---|---|
Bank | This is an enterprise application project. |
Bank_EJB | This is an EJB project. This project is specified in the module project of the sample project (Bank). |
Bank_Web | This is a dynamic Web project. This project is specified in the module project of the sample project (Bank). |
BankDBBatch | This is a simple project. This project stores the files for creating the tables to be used in the sample project (Bank). |
The configuration of the projects provided with the sample project (Bank) is as follows:
Developer provides the sample project (Bank) as an archive file Bank.zip in the zip format. Bank.zip is saved in the following directory:
Developer-installation-directory\ADP\samples |
If you unzip Bank.zip in any location, the directory configuration will become as follows:
Table A-3 Directory configuration of the sample project (Bank)
Directory or File | Description |
---|---|
Bank | This is the root of the enterprise application project |
EarContent | Contents folder |
META-INF | This directory stores the management information. |
application.xml | This is a DD file (Deployment descriptor of the J2EE application (EAR)) |
.project | This is a project description file (Stores the information about the Eclipse project) |
Bank_EJB | This is the root of the EJB project |
ejbModule | This directory stores the source files |
bank | This is a package folder |
ejb | This is a package folder |
BankEJB.java |
This is a Java source file (Source code for the EJB project) |
BankIF.java |
This is a Java source file (Source code for the EJB project) |
BankItem.java |
This is a Java source file (Source code for the EJB project) |
META-INF | This directory stores the management information. |
MANIFEST.MF | This is a manifest file |
.classpath |
This is a classpath file (Stores the classpath of the project) |
.project | This is a project description file (Stores the information about the Eclipse project) |
Bank_Web | This is the root of the Web project |
src | This directory stores the source files |
bank | This is a package folder |
servlet | This is a package folder |
BankServlet.java | This is a Java source file |
BankServletException.java | This is a Java source file |
WebContent | This is a Web root folder |
META-INF | This directory stores the management information. |
MANIFEST.MF | This is a manifest file |
WEB-INF |
This directory stores the files that cannot be accessed directly from a web client. |
lib | This directory stores the libraries |
web.xml |
This is a DD file (Deployment descriptor of the Web application) |
bank.jsp |
This is a JSP file (The ID and numeric value are entered, and sent to the Servlet) |
error_500.jsp | This is a JSP file (Displays errors) |
index.jsp |
This is a JSP file (Entrance of the sample project that invokes the servlet) |
.classpath |
This is a classpath file (Stores the classpath of the project) |
.project | This is a MyEclipse project file (Stores the information about the Eclipse project) |
BankDBBatch |
This is the root of the sample project |
bank_tblcreate.bat |
This is a batch file (Batch file for creating tables) |
Insert_BankTable_ Control_checking |
This is a control file (Control file for the checking table) |
Insert_BankTable_ Control_saving |
This is a control file (Control file for the saving table) |
Insert_BankTable_ Input_checking |
This is a data file (Data file for the checking table) |
Insert_BankTable_ Input_saving |
This is a data file (Data file for the saving table) |
tablecreate |
This is an SQL file (Schema definition SQL file for the tables) |
.project | This is a project description file (Stores the information about the Eclipse project) |
All Rights Reserved. Copyright (C) 2012, 2013, Hitachi, Ltd.