1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.transaction; |
8 |
| |
9 |
| |
10 |
| import javax.transaction.NotSupportedException; |
11 |
| import javax.transaction.RollbackException; |
12 |
| import javax.transaction.SystemException; |
13 |
| import javax.transaction.Transaction; |
14 |
| import javax.transaction.TransactionManager; |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| public class NotifyingTransactionManager extends DummyTransactionManager implements TransactionManagerLookup |
22 |
| { |
23 |
| |
24 |
| private static final long serialVersionUID = -2994163352889758708L; |
25 |
| |
26 |
| private Notification notification; |
27 |
| |
28 |
3
| public void begin() throws SystemException, NotSupportedException
|
29 |
| { |
30 |
3
| super.begin();
|
31 |
3
| try
|
32 |
| { |
33 |
3
| System.out.println("Calling notification.notify()");
|
34 |
3
| notification.notify(getTransaction());
|
35 |
| } |
36 |
| catch (RollbackException e) |
37 |
| { |
38 |
0
| e.printStackTrace();
|
39 |
| } |
40 |
| } |
41 |
| |
42 |
3
| public TransactionManager getTransactionManager() throws Exception
|
43 |
| { |
44 |
3
| return this;
|
45 |
| } |
46 |
| |
47 |
| public interface Notification |
48 |
| { |
49 |
| public void notify(Transaction tx) throws SystemException, RollbackException; |
50 |
| } |
51 |
| |
52 |
| |
53 |
0
| public Notification getNotification()
|
54 |
| { |
55 |
0
| return notification;
|
56 |
| } |
57 |
| |
58 |
| |
59 |
3
| public void setNotification(Notification notification)
|
60 |
| { |
61 |
3
| this.notification = notification;
|
62 |
| } |
63 |
| |
64 |
| } |
65 |
| |
66 |
| |
67 |
| |