Title: Technologies for Grids and eBusiness Exercise2: Enterprise JavaBeans
1Technologies for Grids and eBusinessExercise2
Enterprise JavaBeans
- Lars Schley
- Institut für Roboterforschung
- Lars Schley
2Types of Enterprise JavaBeans
- Session beans
- model business processes
- adding numbers
- accessing databases
- calling other enterprise beans
- Entity beans
- model business data
- product
- order..
- Message-driven beans
- similar to session beans
- can only be called by sending messages
3Entity Enterprise JavaBeans
- Persistent objects
- Are stored in a data base
- Object to relational data base mapping needed
- Bean knows itself how to persist to a durable
data base - Entry in the data base and the in-memory version
of the bean are always synchronized - Two ways to persist entity beans
- bean managed persistence
- container managed persistence
4Example Account
- Account.java
- Remote interface
- AccountLocal.java
- Remote interface for local access
- AccountHome.java
- Home interface
- AccountHomeLocal.java
- Home interface for local access
- AccountBean.java
- Implementation of bean
- AccountPK.java
- Primary key class for Account
5Tasks (1)
- Use the installation under C\Programme\Tgeb\
- C\Programme\Tgeb\eclipse\eclipse.exe
- C\Programme\Tgeb\start_jboss.bat
- Read, compile and deploy the Account EJB
- Read, compile and run the AccountClient
- Modify the AccountClient
- Implement the methods at the end of
AccountClient.java - Uncomment the test scenario
- libs
- C\Programme\Tgeb\jboss-4.0.3SP1\client\jbossall-c
lient.jar - C\Programme\Tgeb\jboss-4.0.3SP1\client\jboss-j2ee
.jar
6Tasks (2)
- createAccount(String userName, String key, int
seedCapital) - deleteAccount(String userName)
- withdrawMoney(String userName, int amount)
- withdrawMoney(AccountPK pk, int amount)
- printAccount(String userName)
- void printAccountAll()
- void depositMoney(String userName, int amount)
- void transferMoney(String user1, String user2,
int amount)
7Output 1/2
Creating account of John Smith Creating account
of Peter Miller Creating account of Paul
Fisher Creating account of Michael Tailor Account
balance of John Smith 5000.0 Account balance of
Peter Miller 20.0 Account balance of Paul
Fisher 1150.0 Account balance of Michael Tailor
8000.0 Total of all accounts in bank now
14170.0 Paul Fisher withdraws 50 User with
primary key 734-752 withdraws 15 Account balance
of Peter Miller 5.0 Account balance of Paul
Fisher 1100.0 Total of all accounts in bank now
14105.0 John Smith deposits 12000 Peter
Miller deposits 18 Account balance of John
Smith 17000.0 Account balance of Peter Miller
23.0 Total of all accounts in bank now 26123.0
8Output 2/2
Destroying account of Michael Tailor Total of all
accounts in bank now 18123.0 John Smith
transfers 853 to Peter Miller John Smith
withdraws 853 Peter Miller deposits 853 Account
balance of John Smith 16147.0 Account balance of
Peter Miller 876.0 Total of all accounts in bank
now 18123.0 Destroying account of John
Smith Destroying account of Peter
Miller Destroying account of Paul Fisher Total of
all accounts in bank now 0.0