Enterprise Java Session Beans
During the weekly status meeting, Bill of the test team reports that functional test is proceeding on schedule. He also reports that the test team has started doing load and performance testing. Bill reports the following problems:
- One of the test cases simulates a situation where the husband and a wife are paying bills on line at the same time. While at work, the husband checks the balance of their checking account to verify that there is adequate funds pays the electric bill online. He sees that there is $120.00 in the account. The bill is for $110.00. At the same time, his wife at home gets online checks the status of the account, She also sees that there is $120.00 in the account and wants to pay off her credit card bill for $83.00. They both hit the Pay Bills button at the same time. The test case falls and the results show that both bills were paid with out a problem. The Pay Bills use case indicates that a bill should not be paid if there are insufficient funds in the account to pay the bills.
- The test team ran a test case that simulates a load of 200 simultaneous customers using the system at the same time. The response time slows to 10 seconds per request. While running this test the system crashes. When the system is started again, several of the bank account balances are incorrect.
- In another test, a customer types in a URL directly to create an account. Customers are not allowed to create bank accounts. Only bank employees are allowed to be create bank accounts. This test fails and the customer is allowed to create the account..
As the software engineer, you have been assigned to fix these problems.
Return and Report
- What is the function of a Session Enterprise Java Bean (EJB).
- What is transaction processing? What is an ACID transaction?
- Enterprise Java Beans use the proxy pattern. Describe the purpose of the Proxy pattern. Draw a class diagram of the Proxy pattern and show how this maps to an Enterprise Java Session Bean.
- Contrast the difference between stateful vs. stateless Session EJBs. Which is preferred and why?
- Draw and explain state diagrams illustrating the life cycle of both stateful and stateless Enterprise Java Session Beans. Explain the concept of activation and passivation.
- Contrast use of the Remote vs. Local Interface for Enterprise Java Beans. Which is preferred and why?
- Describe what JNDI is and why it is necessary for using EJBs. Create a java method that illustrates how to access a remote EJB using JNDI.
Design
- Update the sequence diagram for the two use cases that you are implementing to use the model 2 architecture and Session EJBs.
Implementation
- Implement the two sequence diagrams you defined above using Session EJBs for the business layer. Create JUnit test cases to access and use Session EJBs to test your business methods.
- Define the appropriate transaction attributes for all of the business methods you created.
Key Words
- Enterprise Java Beans (EJBs)
- Proxy pattern
- Stateful, Stateless
- Container Managed, Bean Managed Sesssion EJBs
- Remote vs. Local Inteface for EJBs
- JNDI
- EJB Container
- Transaction
- ACID transaction
- Transaction attributes
Suggested Resources
- Transaction Processing
- Proxy pattern
- Session EJBs (Presentation)
- JNDI
- Enterprise JavaBeans 3.0, Chapters 11, 16
- JUnit Home Page
- Unit Testing