KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jotm > XAResourceHelper


1 /*
2  * @(#) XAResourceHelper.java
3  *
4  *
5  * JOTM: Java Open Transaction Manager
6  *
7  *
8  * This module was originally developed by
9  *
10  * - INRIA (www.inria.fr)inside the ObjectWeb Consortium
11  * (http://www.objectweb.org)
12  *
13  * --------------------------------------------------------------------------
14  * The original code and portions created by INRIA are
15  * Copyright (c) 2002 INRIA
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are met:
20  *
21  * -Redistributions of source code must retain the above copyright notice, this
22  * list of conditions and the following disclaimer.
23  *
24  * -Redistributions in binary form must reproduce the above copyright notice,
25  * this list of conditions and the following disclaimer in the documentation
26  * and/or other materials provided with the distribution.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  *
40  * --------------------------------------------------------------------------
41  * $Id: XAResourceHelper.java,v 1.4 2004/10/29 05:44:41 tonyortiz Exp $
42  * --------------------------------------------------------------------------
43  */

44 package org.objectweb.jotm;
45
46 import java.lang.reflect.Field JavaDoc;
47
48 import javax.transaction.xa.XAResource JavaDoc;
49
50 /**
51  * @author jmesnil
52  */

53 public class XAResourceHelper {
54     public static String JavaDoc getFlagName(int flag) {
55         String JavaDoc flagName = null;
56         try {
57             Field JavaDoc[] flds = XAResource JavaDoc.class.getDeclaredFields();
58             for (int i = 0; i < flds.length; i++) {
59                 if (flds[i].getInt(null) == flag)
60                     flagName = flds[i].getName();
61             }
62         } catch (Exception JavaDoc e) {
63             flagName = "invalid flag value!";
64         }
65         return flagName;
66     }
67 }
68
Popular Tags