01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999-2004 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: StatusHelper.java 5445 2004-09-17 08:25:02Z joaninh $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_ejb.lib;
25:
26: import java.lang.reflect.Field;
27: import javax.transaction.Status;
28:
29: /**
30: * @author Christophe Ney : Initial developer
31: */
32: public class StatusHelper {
33: public static String getStatusName(int status) {
34: String statusName = null;
35: try {
36: Field[] flds = Status.class.getDeclaredFields();
37: for (int i = 0; i < flds.length; i++) {
38: if (flds[i].getInt(null) == status)
39: statusName = flds[i].getName();
40: }
41: } catch (Exception e) {
42: statusName = "invalid status value!";
43: }
44: return statusName;
45: }
46:
47: public static void listStatusValues() {
48: System.out.println("ACTIVE=" + Status.STATUS_ACTIVE);
49: System.out.println("COMMITTED=" + Status.STATUS_COMMITTED);
50: System.out.println("COMMITTING=" + Status.STATUS_COMMITTING);
51: System.out.println("MARKED_ROLLBACK="
52: + Status.STATUS_MARKED_ROLLBACK);
53: System.out.println("NO_TRANSACTION="
54: + Status.STATUS_NO_TRANSACTION);
55: System.out.println("PREPARED=" + Status.STATUS_PREPARED);
56: System.out.println("PREPARING=" + Status.STATUS_PREPARING);
57: System.out.println("ROLLEDBACK=" + Status.STATUS_ROLLEDBACK);
58: System.out
59: .println("ROLLING_BACK=" + Status.STATUS_ROLLING_BACK);
60: System.out.println("UNKNOWN=" + Status.STATUS_UNKNOWN);
61: }
62: }
|