1 25 26 package org.objectweb.jonas_ejb.lib; 27 28 29 import java.lang.reflect.Field ; 30 import javax.transaction.Status ; 31 32 35 public class StatusHelper { 36 public static String getStatusName(int status) { 37 String statusName = null; 38 try { 39 Field [] flds = Status .class.getDeclaredFields(); 40 for (int i = 0; i < flds.length; i++) { 41 if (flds[i].getInt(null) == status) 42 statusName = flds[i].getName(); 43 } 44 } catch (Exception e) { 45 statusName = "invalid status value!"; 46 } 47 return statusName; 48 } 49 50 public static void listStatusValues() { 51 System.out.println("ACTIVE=" + Status.STATUS_ACTIVE); 52 System.out.println("COMMITTED=" + Status.STATUS_COMMITTED); 53 System.out.println("COMMITTING=" + Status.STATUS_COMMITTING); 54 System.out.println("MARKED_ROLLBACK=" + Status.STATUS_MARKED_ROLLBACK); 55 System.out.println("NO_TRANSACTION=" + Status.STATUS_NO_TRANSACTION); 56 System.out.println("PREPARED=" + Status.STATUS_PREPARED); 57 System.out.println("PREPARING=" + Status.STATUS_PREPARING); 58 System.out.println("ROLLEDBACK=" + Status.STATUS_ROLLEDBACK); 59 System.out.println("ROLLING_BACK=" + Status.STATUS_ROLLING_BACK); 60 System.out.println("UNKNOWN=" + Status.STATUS_UNKNOWN); 61 } 62 } 63 | Popular Tags |