06. Java EE 6 - EJB 3.1

Lab Exercises

For the sake of the simplicity of the lab, most exercises are provided in the form of "ready-to-open-and-run" NetBeans projects.  (Many of them are borrowed from "glassfish-samples" and "Java EE 6 tutorial".)  Please feel free to create them from scratch if you want to. 

It is strongly encouraged, leveraging what is provided in this lab, you do your own experimentation meaning creating/adding your own code as much as you can. 

If you have written some code that might help everyone else, please feel free to share them on this codecamp email alias or directly send them to the instructors.  Your name will be recognized in this lab if your sample code is chosen to be included.  For the tasks that need to be done, please see the "Things to be done" section above.)

  • Exercise 1: EJB in a war packaging (step by step) (20 minutes)
  • Exercise 2: Singleton (20 minutes)
  • Exercise 3: Timer (20 minutes)
  • Exercise 4: Asynchronous method invocation (30 minutes)
  • Exercise 5: EJB embedded (30 minutes)
  • Exercise 6: EJB with REST (30 minutes)
  • Homework Exercise
      Before you start this lab, you have to get sample applications from "glassfish-samples" and "Java EE tutorial" as described in LAB-4530: Java EE 6 - Examples.

    Exercise 1: EJB in a war packaging (step by step)

    더보기



    Exercise 2: Singleton

    더보기


    Exercise 3: Timer

    더보기

                                                                                                                          

    Exercise 4: Asynchronous method invocation using @Asynchronous

    더보기

     

    Exercise 5: EJB Embedded (Building Embeddable EJB app step by step)

    더보기





    Exercise 6: EJB and RESTful service

    더보기


    Homework Exercise


    1. The homework #1 is to modify EJB-in-a-war project you did in Exercise 1 above as following.   (You might want to create a new project by copying my_ejb3.1 project.  You can name the newly copied project in any way you want.  Here it is referred to as my_ejb3.1.)
    • Exercise point: EJB in a war packaging
      • Add another stateless bean called YourSessionBean with the following two methods.
        • add(int x, int y)
        • multiply(int x, int y)
      • From the HelloServlet, call these two methods using x value 10 and y value 6 and display the result
      • Exercise point: Singleton
        • Create a Singleton EJB which has the following two variables, which are used as a total values of the addition and multiplication
          • int total_addition
          • int total_multiplication
      • Exercise point: Timer
        • Use timer to display the value of total_addition and total_multiplication every hour of the day at the GlassFish v3 server log. (Basically use System.out.println(..) method.)
      2. The homework #2 is to create my_ejb3.1_embedded project as following.
      • Exercise point: EJB embedded
        • Create Java SE application in which the add(..) and multiply(..) methods are tested
      3. Send the following files to javaee6-homeworks@sun.com with Subject as homework_javaee6_ejb3.1.
      • Zip file of the the my_ejb3.1 and my_ejb3.1_embedded NetBeans projects.  (Someone else should be able to open and runthem as NetBeans projects.)  You can use your favorite zip utility or you can use "jar" utility that comes with JDK as following.
        • cd <parent directory that contains my_ejb3.1 directory> (assuming you named your project as my_ejb3.1)
        • jar cvf my_ejb3.1.zip my_ejb3.1 (my_ejb3.1 should contain nbproject directory)
      Please reduce the size of the zip file by right clicking the project and then selecting Clean before zipping the file.
      • Captured output screen  - name it as homework_javaee6_ejb3.1.gif or homework_javaee6_ejb3.1_embedded.jpg (or homework_javaee6_ejb3.1.<whatever graphics format>) and as homework_javaee6_ejb3.1_embedded.gif or homework_javaee6_ejb3.1_embedded.jpg (or homework_javaee6_ejb3.1_embedded.<whatever graphics format>)
        • Any screen capture that shows that your program is working is good enough. 





    • 저작자 표시

      Trackback 0 Comment 0