-
Notifications
You must be signed in to change notification settings - Fork 176
/
XidUtils.java
58 lines (49 loc) · 1.5 KB
/
XidUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Copyright The Narayana Authors
SPDX-License-Identifier: Apache-2.0
*/
package com.arjuna.ats.internal.jta.utils.jts;
import javax.transaction.xa.Xid;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.internal.jts.orbspecific.ControlImple;
import com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple;
import com.arjuna.ats.jta.xa.XATxConverter;
import com.arjuna.ats.jts.utils.Utility;
/**
* Utility functions for JTS (i.e. jtax) Xid handling.
*
* @author Jonathan Halliday (jonathan.halliday@redhat.com)
*/
public class XidUtils
{
public static Xid getXid (Uid uid, boolean branch) throws IllegalStateException
{
return XATxConverter.getXid(uid, branch, ArjunaTransactionImple.interpositionType());
}
public static Xid getXid (org.omg.CosTransactions.Control cont, boolean branch) throws IllegalStateException
{
if (cont == null)
throw new IllegalStateException();
Uid u = null;
if (cont instanceof ControlImple)
{
u = ((ControlImple) cont).get_uid();
return getXid(u, branch);
}
else
{
try
{
u = Utility.getUid(cont);
if(u.equals(Uid.nullUid())) {
throw new IllegalStateException();
}
return getXid(u, branch);
}
catch (Exception e)
{
throw new IllegalStateException(e);
}
}
}
}