KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > SwapBean


1 package example;
2
3 import javax.ejb.Stateless JavaDoc;
4
5 import javax.ejb.TransactionAttribute JavaDoc;
6 import static javax.ejb.TransactionAttributeType.REQUIRED JavaDoc;
7 import static javax.ejb.TransactionAttributeType.SUPPORTS JavaDoc;
8
9 /**
10  * Implementation of the Swap bean.
11  */

12 @Stateless JavaDoc(name="swap")
13 public class SwapBean implements Swap {
14   /**
15    * Swaps the teacher inside a transaction.
16    */

17   @TransactionAttribute JavaDoc(REQUIRED)
18   public void swap(Course a, Course b)
19   {
20     String JavaDoc teacher = a.getTeacher();
21     a.setTeacher(b.getTeacher());
22     b.setTeacher(teacher);
23   }
24   
25   /**
26    * Returns the teacher.
27    */

28   @TransactionAttribute JavaDoc(SUPPORTS)
29   public String JavaDoc getTeacher(Course a)
30   {
31     return a.getTeacher();
32   }
33 }
34
Popular Tags