KickJava   Java API By Example, From Geeks To Geeks.

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


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

11
12 public class MethodTransaction implements Comparable JavaDoc {
13     private MethodDescriptor methodDesc;
14     private byte transactionAttr = TransactionAttribute.TX_BEAN_MANAGED;
15
16     public MethodTransaction() {
17
18     }
19
20     public MethodDescriptor getMethod() {
21         return methodDesc;
22     }
23
24     public void setMethod(MethodDescriptor methodDesc) {
25         this.methodDesc = methodDesc;
26     }
27
28     public byte getTransactionAttr() {
29         return transactionAttr;
30     }
31
32     public String JavaDoc getTransactionAttributeString() {
33         return TransactionAttribute.getTransactionAttrString(transactionAttr);
34     }
35
36     public void setTransactionAttr(byte i) {
37         switch(i) {
38             case TransactionAttribute.TX_NOT_SUPPORTED: // '\0'
39
case TransactionAttribute.TX_SUPPORTS: // '\002'
40
case TransactionAttribute.TX_REQUIRED: // '\003'
41
case TransactionAttribute.TX_REQUIRES_NEW: // '\004'
42
case TransactionAttribute.TX_MANDATORY: // '\005'
43
case TransactionAttribute.TX_NEVER: // '\006'
44
transactionAttr = i;
45                 break;
46
47             case 1: // '\001'
48
default:
49                 throw new IllegalArgumentException JavaDoc("Invalid transaction attribute: " + i);
50         }
51     }
52
53     public void setTransactionAttributeString(String JavaDoc transactionAttrString) {
54         transactionAttr = TransactionAttribute.getTransactionAttribute(transactionAttrString);
55     }
56
57     public int compareTo(Object JavaDoc obj) {
58         MethodTransaction mtd = (MethodTransaction) obj;
59         return methodDesc.compareTo(mtd.methodDesc);
60     }
61
62     public boolean equals(Object JavaDoc obj) {
63         if(obj != null && (obj instanceof MethodTransaction)) {
64             MethodTransaction containertransaction = (MethodTransaction) obj;
65             return methodDesc.equals(containertransaction.methodDesc);
66         }
67         else {
68             return false;
69         }
70     }
71
72     public int hashCode() {
73         return methodDesc.hashCode();
74     }
75
76     public static void main(String JavaDoc[] args) {
77
78     }
79 }
80
81
Popular Tags