KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ejb > meta > TransactionAttribute


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.ejb.meta;
8
9 /**
10  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
11  */

12
13 public class TransactionAttribute {
14     public static final byte TX_NOT_SUPPORTED = 0;
15     public static final byte TX_BEAN_MANAGED = 1;
16     public static final byte TX_SUPPORTS = 2;
17     public static final byte TX_REQUIRED = 3;
18     public static final byte TX_REQUIRES_NEW = 4;
19     public static final byte TX_MANDATORY = 5;
20     public static final byte TX_NEVER = 6;
21
22     public static String JavaDoc getTransactionAttrString(byte transactionAttr) {
23         switch(transactionAttr) {
24             case TransactionAttribute.TX_NOT_SUPPORTED: // '\0'
25
return "NotSupported";
26
27             case TransactionAttribute.TX_SUPPORTS: // '\002'
28
return "Supports";
29
30             case TransactionAttribute.TX_REQUIRED: // '\003'
31
return "Required";
32
33             case TransactionAttribute.TX_REQUIRES_NEW: // '\004'
34
return "RequiresNew";
35
36             case TransactionAttribute.TX_MANDATORY: // '\005'
37
return "Mandatory";
38
39             case TransactionAttribute.TX_NEVER: // '\006'
40
return "Never";
41
42             case 1: // '\001'
43
default:
44                 return "Unknown!!";
45         }
46
47     }
48
49     public static byte getTransactionAttribute(String JavaDoc transactionAttrString) {
50         if(transactionAttrString.equals("NotSupported"))
51             return TransactionAttribute.TX_NOT_SUPPORTED;
52         else if(transactionAttrString.equals("Supports"))
53             return TransactionAttribute.TX_SUPPORTS;
54         else if(transactionAttrString.equals("Required"))
55             return TransactionAttribute.TX_REQUIRED;
56         else if(transactionAttrString.equals("RequiresNew"))
57             return TransactionAttribute.TX_REQUIRES_NEW;
58         else if(transactionAttrString.equals("Mandatory"))
59             return TransactionAttribute.TX_MANDATORY;
60         else if(transactionAttrString.equals("Never"))
61             return TransactionAttribute.TX_NEVER;
62         else
63             throw new IllegalArgumentException JavaDoc("Unknwon transaction attribute: " + transactionAttrString);
64     }
65
66     public static void main(String JavaDoc[] args) {
67
68     }
69 }
70
71
Popular Tags