/** * Create a new top-level transaction. If the specified transaction * manager supports nested transactions, then the returned transaction * can be cast to a <code>NestableTransaction</code>. * * @param mgr the transaction manager to use for this transaction * @param leaseTime the requested lease time for the transaction * @return the created transaction and the lease granted * * @throws LeaseDeniedException if this manager is unwilling to * grant the requested lease time * @throws RemoteException if a communication error occurs. */ public static Transaction.Created create(TransactionManager mgr, long leaseTime) throws LeaseDeniedException, RemoteException { TransactionManager.Created rawTxn = mgr.create(leaseTime); Transaction transaction; if (mgr instanceof NestableTransactionManager) transaction = new NestableServerTransaction( (NestableTransactionManager)mgr, rawTxn.id, null); else transaction = new ServerTransaction(mgr, rawTxn.id); return new Transaction.Created(transaction, rawTxn.lease); }
/** * Create a new top-level transaction. If the specified transaction manager supports nested * transactions, then the returned transaction can be cast to a <code>NestableTransaction</code>. * * @param mgr the transaction manager to use for this transaction * @param leaseTime the requested lease time for the transaction * @return the created transaction and the lease granted * @throws LeaseDeniedException if this manager is unwilling to grant the requested lease time * @throws RemoteException if a communication error occurs. */ public static Transaction.Created create(TransactionManager mgr, long leaseTime) throws LeaseDeniedException, RemoteException { TransactionManager.Created rawTxn = mgr.create(leaseTime); Transaction transaction; if (mgr instanceof NestableTransactionManager) transaction = new NestableServerTransaction((NestableTransactionManager) mgr, rawTxn.id, null, leaseTime); else transaction = ServerTransaction.create(mgr, rawTxn.id, leaseTime); return new Transaction.Created(transaction, rawTxn.lease); }
/** * Creates new transaction for XA transactions. * * @param xid XA TX id * @param setAsDefault set as default TX for the space */ public static Transaction.Created create(ExtendedTransactionManager mgr, Xid xid, long leaseTime, boolean setAsDefault, ISpaceProxy proxy, XAResourceImpl resource, boolean delegatedXa) throws LeaseDeniedException, RemoteException { TransactionManager.Created rawTxn = mgr.create(xid, leaseTime); GSServerTransaction transaction = GSServerTransaction.create(mgr, xid, leaseTime); Transaction.Created txCreated = new Transaction.Created(transaction, rawTxn.lease); if (setAsDefault) { proxy.replaceContextTransaction(txCreated, resource, delegatedXa); } return txCreated; } }