http://www.coreservlets.com
Session Beans
1. Install JBoss or Glassfish and configure Eclipse to recognize it. Start the s...
Upcoming SlideShare
Loading in …5
×

Ejb3 4 -Exercises session-beans

45 views
33 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
45
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ejb3 4 -Exercises session-beans

  1. 1. http://www.coreservlets.com Session Beans 1. Install JBoss or Glassfish and configure Eclipse to recognize it. Start the server in Eclipse and access http://localhost:8080/. 2. Make an EJB project with an interface RandomNumber and a concrete class Ran- domNumberBean. Give it two methods: findNum (no arguments, returns random number between 0 and 1) and findNumInRange (takes a double as an argument and returns a number between 0 and that number). Make it a remotely-accessible stateless session bean. Deploy the project to your app server. 3. Make a standalone client that can access the bean. Test out both methods. Use a Dynamic Web project so that you can later add servlets to it. But this client should just have a “main”, and can be executed from within Eclipse (R-click, Run As, Java Application) without deploying the project. 4. Add a new class to your EJB project called RandomNumber2. Make it a stateful ses- sion bean. Give it four methods: • setupNum(range): sets the initial value to be a number in that range • currentValue(): returns the current value of the number • doubleNum(): doubles the stored number • done(): tells app server to gc (garbage collect) the object 5. Test your bean from a standalone client. 6. Test your bean from a servlet.

×