1
2
3
4
5
6
7
8
9
10
11 package org.mule.impl.internal.notifications;
12
13 import org.mule.umo.UMOTransaction;
14 import org.mule.umo.manager.UMOServerNotification;
15
16 public class TransactionNotification extends UMOServerNotification implements BlockingServerEvent
17 {
18
19
20
21 private static final long serialVersionUID = -3245036187011582121L;
22 public static final int TRANSACTION_BEGAN = TRANSACTION_EVENT_ACTION_START_RANGE + 1;
23 public static final int TRANSACTION_COMMITTED = TRANSACTION_EVENT_ACTION_START_RANGE + 2;
24 public static final int TRANSACTION_ROLLEDBACK = TRANSACTION_EVENT_ACTION_START_RANGE + 3;
25
26 private static final transient String[] ACTIONS = new String[] {"begin", "commit", "rollback"};
27
28
29
30
31
32
33 private String transactionStringId;
34
35 public TransactionNotification(UMOTransaction transaction, int action)
36 {
37 super(transaction, action);
38 this.transactionStringId = transaction.toString();
39 }
40
41 public String getTransactionStringId()
42 {
43 return this.transactionStringId;
44 }
45
46 protected String getActionName(int action)
47 {
48 int i = action - TRANSACTION_EVENT_ACTION_START_RANGE;
49 if (i - 1 > ACTIONS.length)
50 {
51 return String.valueOf(action);
52 }
53 return ACTIONS[i - 1];
54 }
55
56 public String toString()
57 {
58 return EVENT_NAME + "{" + "action=" + getActionName(action) + ", transactionStringId=" + transactionStringId
59 + ", timestamp=" + timestamp + "}";
60 }
61
62 }