1 43 package org.objectweb.jotm; 44 45 import javax.transaction.xa.XAResource ; 46 import javax.transaction.xa.XAException ; 47 48 54 55 public class RmRegistration { 56 57 private String rmName = null; 58 private XAResource rmXares = null; 59 private String rmXaName = null; 60 private boolean rmReference = false; 61 private String rmReferenceName = ""; 62 63 public void rmAddRegistration (String prmName, XAResource prmXares, String prmxaName) { 64 if (TraceTm.recovery.isDebugEnabled()) { 65 TraceTm.recovery.debug("Add registration Resource manager= " + prmName); 66 TraceTm.recovery.debug("Add registration XAResource = " + prmXares); 67 TraceTm.recovery.debug("Add registration XAResource Name = " + prmxaName); 68 } 69 70 rmName = prmName; 71 rmXares = prmXares; 72 rmXaName = prmxaName; 73 } 74 75 public void rmAddName (String prmName) { 76 rmName = prmName; 77 } 78 79 public void rmAddXaRes (XAResource prmXares) { 80 rmXares = prmXares; 81 } 82 83 public String rmGetName () { 84 if (TraceTm.recovery.isDebugEnabled()) { 85 TraceTm.recovery.debug("rmName= " + rmName); 86 } 87 return rmName; 88 } 89 90 public XAResource rmGetXaRes () { 91 if (TraceTm.recovery.isDebugEnabled()) { 92 TraceTm.recovery.debug("rmXares= " + rmXares); 93 } 94 return rmXares; 95 } 96 97 public String rmGetXaResName () { 98 if (TraceTm.recovery.isDebugEnabled()) { 99 TraceTm.recovery.debug("rmXaName= " + rmXaName); 100 } 101 return rmXaName; 102 } 103 104 public XAResource rmCheckoutXARes () throws XAException { 105 if (TraceTm.recovery.isDebugEnabled()) { 106 TraceTm.recovery.debug("rmCheckoutXares= " + rmXares); 107 } 108 109 if (rmXares == null) { 110 throw new XAException ("Attempt to use unregistered Resource Manager"); 111 } 112 113 synchronized (this) { 114 while (true) { 115 if (rmReference == false) { 116 rmReferenceName = Thread.currentThread().getName(); 117 rmReference = true; 118 return rmXares; 119 } 120 try { 121 wait(); 122 } catch (InterruptedException e) { 123 ; 124 } 125 } 126 } 127 } 128 129 public void rmCheckinXARes () { 130 if (TraceTm.recovery.isDebugEnabled()) { 131 TraceTm.recovery.debug("rmCheckinXares= " + rmXares); 132 } 133 134 synchronized(this) { 135 rmReference = false; notifyAll(); 137 } 138 } 139 } | Popular Tags |