01: /*
02: * $Id: TransactionNotification.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.context.notification;
12:
13: import org.mule.api.context.notification.BlockingServerEvent;
14: import org.mule.api.context.notification.ServerNotification;
15: import org.mule.api.transaction.Transaction;
16:
17: public class TransactionNotification extends ServerNotification
18: implements BlockingServerEvent {
19: /**
20: * Serial version
21: */
22: private static final long serialVersionUID = -3245036187011582121L;
23: public static final int TRANSACTION_BEGAN = TRANSACTION_EVENT_ACTION_START_RANGE + 1;
24: public static final int TRANSACTION_COMMITTED = TRANSACTION_EVENT_ACTION_START_RANGE + 2;
25: public static final int TRANSACTION_ROLLEDBACK = TRANSACTION_EVENT_ACTION_START_RANGE + 3;
26:
27: static {
28: registerAction("begin", TRANSACTION_BEGAN);
29: registerAction("commit", TRANSACTION_COMMITTED);
30: registerAction("rollback", TRANSACTION_ROLLEDBACK);
31: }
32:
33: /**
34: * Ideally, that should've been a transaction's XID, but we'd need to resort to all kinds of reflection tricks to
35: * get it. Still, toString() typically outputs a class name followed by the XID, so that's good enough.
36: */
37: private String transactionStringId;
38:
39: public TransactionNotification(Transaction transaction, int action) {
40: super (transaction, action);
41: this .transactionStringId = transaction.toString();
42: }
43:
44: public String getTransactionStringId() {
45: return this .transactionStringId;
46: }
47:
48: public String toString() {
49: return EVENT_NAME + "{" + "action=" + getActionName(action)
50: + ", transactionStringId=" + transactionStringId
51: + ", timestamp=" + timestamp + "}";
52: }
53:
54: }
|