01: package example;
02:
03: import javax.ejb.Stateless;
04:
05: import javax.ejb.TransactionAttribute;
06: import static javax.ejb.TransactionAttributeType.REQUIRED;
07: import static javax.ejb.TransactionAttributeType.SUPPORTS;
08:
09: /**
10: * Implementation of the Swap bean.
11: */
12: @Stateless(name="swap")
13: public class SwapBean implements Swap {
14: /**
15: * Swaps the teacher inside a transaction.
16: */
17: @TransactionAttribute(REQUIRED)
18: public void swap(Course a, Course b) {
19: String teacher = a.getTeacher();
20: a.setTeacher(b.getTeacher());
21: b.setTeacher(teacher);
22: }
23:
24: /**
25: * Returns the teacher.
26: */
27: @TransactionAttribute(SUPPORTS)
28: public String getTeacher(Course a) {
29: return a.getTeacher();
30: }
31: }
|