btm-dist-2.1.4/0000777000175000017500000000000012215446662012021 5ustar tonytonybtm-dist-2.1.4/lib/0000777000175000017500000000000012215446662012567 5ustar tonytonybtm-dist-2.1.4/lib/SLF4J-LICENSE.txt0000644000175000017500000000215412147207062015221 0ustar tonytonyCopyright (c) 2004-2008 QOS.ch All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. btm-dist-2.1.4/lib/APACHE-LICENSE-2.0.txt0000644000175000017500000002613612147207062015623 0ustar tonytony Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. btm-dist-2.1.4/build.xml0000644000175000017500000000704112147207062013631 0ustar tonytony package bitronix.tm; public final class Version { public static String getVersion() { return "${jar.version}"; } } btm-dist-2.1.4/test-lib/0000777000175000017500000000000012215446662013544 5ustar tonytonybtm-dist-2.1.4/src/0000777000175000017500000000000012215446662012610 5ustar tonytonybtm-dist-2.1.4/src/overview.html0000644000175000017500000000073112147207062015332 0ustar tonytony The Bitronix Transaction Manager (BTM) is a simple but complete implementation of the JTA API. The goal is to provide a fully working XA transaction manager that provides all services required by the JTA API while trying to keep the code as simple as possible for easier understanding of the XA semantics.

© Bitronix Software

btm-dist-2.1.4/src/bitronix/0000755000175000017500000000000012136323160014427 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/0000755000175000017500000000000012147207062015053 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/package.html0000644000175000017500000000016012147207062017331 0ustar tonytony

JTA interfaces implementations and global services.

btm-dist-2.1.4/src/bitronix/tm/timer/0000755000175000017500000000000012147207062016173 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/timer/package.html0000644000175000017500000000012312147207062020450 0ustar tonytony

Timed tasks scheduler.

btm-dist-2.1.4/src/bitronix/tm/timer/TransactionTimeoutTask.java0000644000175000017500000000376412147207062023527 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.timer; import bitronix.tm.BitronixTransaction; import bitronix.tm.internal.BitronixSystemException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; /** * This task is used to mark a transaction as timed-out. * * @author lorban */ public class TransactionTimeoutTask extends Task { private final static Logger log = LoggerFactory.getLogger(TransactionTimeoutTask.class); private final BitronixTransaction transaction; public TransactionTimeoutTask(BitronixTransaction transaction, Date executionTime, TaskScheduler scheduler) { super(executionTime, scheduler); this.transaction = transaction; } public Object getObject() { return transaction; } public void execute() throws TaskException { try { if (log.isDebugEnabled()) log.debug("marking " + transaction + " as timed out"); transaction.timeout(); } catch (BitronixSystemException ex) { throw new TaskException("failed to timeout " + transaction, ex); } } public String toString() { return "a TransactionTimeoutTask on " + transaction + " scheduled for " + getExecutionTime(); } } btm-dist-2.1.4/src/bitronix/tm/timer/TaskException.java0000644000175000017500000000206012147207062021615 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.timer; /** * Thrown when an error occurs during the execution of a task. * * @author lorban */ public class TaskException extends Exception { public TaskException(String message, Throwable cause) { super(message, cause); } } btm-dist-2.1.4/src/bitronix/tm/timer/TaskScheduler.java0000644000175000017500000002457512147207062021614 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.timer; import bitronix.tm.BitronixTransaction; import bitronix.tm.TransactionManagerServices; import bitronix.tm.recovery.Recoverer; import bitronix.tm.resource.common.XAPool; import bitronix.tm.utils.ClassLoaderUtils; import bitronix.tm.utils.MonotonicClock; import bitronix.tm.utils.Service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; import java.util.HashSet; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** * Timed tasks service. * * @author lorban */ public class TaskScheduler extends Thread implements Service { private final static Logger log = LoggerFactory.getLogger(TaskScheduler.class); private final SortedSet tasks; private final Lock tasksLock; private final AtomicBoolean active = new AtomicBoolean(true); public TaskScheduler() { // it is up to the ShutdownHandler to control the lifespan of the JVM and give some time for this thread // to die gracefully, meaning enough time for all tasks to get executed. This is why it is set as daemon. setDaemon(true); setName("bitronix-task-scheduler"); SortedSet tasks; Lock tasksLock; try { @SuppressWarnings("unchecked") Class> clazz = ClassLoaderUtils.loadClass("java.util.concurrent.ConcurrentSkipListSet"); tasks = clazz.newInstance(); tasksLock = null; if (log.isDebugEnabled()) log.debug("task scheduler backed by ConcurrentSkipListSet"); } catch (Exception e) { tasks = new TreeSet(); tasksLock = new ReentrantLock(); if (log.isDebugEnabled()) log.debug("task scheduler backed by locked TreeSet"); } this.tasks = tasks; this.tasksLock = tasksLock; } private void lock() { if (tasksLock != null) { tasksLock.lock(); } } private void unlock() { if (tasksLock != null) { tasksLock.unlock(); } } /** * Get the amount of tasks currently queued. * @return the amount of tasks currently queued. */ public int countTasksQueued() { lock(); try { return tasks.size(); } finally { unlock(); } } public void shutdown() { boolean wasActive = setActive(false); if (wasActive) { try { long gracefulShutdownTime = TransactionManagerServices.getConfiguration().getGracefulShutdownInterval() * 1000; if (log.isDebugEnabled()) log.debug("graceful scheduler shutdown interval: " + gracefulShutdownTime + "ms"); join(gracefulShutdownTime); } catch (InterruptedException ex) { log.error("could not stop the task scheduler within " + TransactionManagerServices.getConfiguration().getGracefulShutdownInterval() + "s"); } } } /** * Schedule a task that will mark the transaction as timed out at the specified date. If this method is called * with the same transaction multiple times, the previous timeout date is dropped and replaced by the new one. * @param transaction the transaction to mark as timeout. * @param executionTime the date at which the transaction must be marked. */ public void scheduleTransactionTimeout(BitronixTransaction transaction, Date executionTime) { if (log.isDebugEnabled()) log.debug("scheduling transaction timeout task on " + transaction + " for " + executionTime); if (transaction == null) throw new IllegalArgumentException("expected a non-null transaction"); if (executionTime == null) throw new IllegalArgumentException("expected a non-null execution date"); TransactionTimeoutTask task = new TransactionTimeoutTask(transaction, executionTime, this); addTask(task); if (log.isDebugEnabled()) log.debug("scheduled " + task + ", total task(s) queued: " + tasks.size()); } /** * Cancel the task that will mark the transaction as timed out at the specified date. * @param transaction the transaction to mark as timeout. */ public void cancelTransactionTimeout(BitronixTransaction transaction) { if (log.isDebugEnabled()) log.debug("cancelling transaction timeout task on " + transaction); if (transaction == null) throw new IllegalArgumentException("expected a non-null transaction"); if (!removeTaskByObject(transaction)) if (log.isDebugEnabled()) log.debug("no task found based on object " + transaction); } /** * Schedule a task that will run background recovery at the specified date. * @param recoverer the recovery implementation to use. * @param executionTime the date at which the transaction must be marked. */ public void scheduleRecovery(Recoverer recoverer, Date executionTime) { if (log.isDebugEnabled()) log.debug("scheduling recovery task for " + executionTime); if (recoverer == null) throw new IllegalArgumentException("expected a non-null recoverer"); if (executionTime == null) throw new IllegalArgumentException("expected a non-null execution date"); RecoveryTask task = new RecoveryTask(recoverer, executionTime, this); addTask(task); if (log.isDebugEnabled()) log.debug("scheduled " + task + ", total task(s) queued: " + tasks.size()); } /** * Cancel the task that will run background recovery at the specified date. * @param recoverer the recovery implementation to use. */ public void cancelRecovery(Recoverer recoverer) { if (log.isDebugEnabled()) log.debug("cancelling recovery task"); if (!removeTaskByObject(recoverer)) if (log.isDebugEnabled()) log.debug("no task found based on object " + recoverer); } /** * Schedule a task that will tell a XA pool to close idle connections. The execution time will be provided by the * XA pool itself via the {@link bitronix.tm.resource.common.XAPool#getNextShrinkDate()}. * @param xaPool the XA pool to notify. */ public void schedulePoolShrinking(XAPool xaPool) { Date executionTime = xaPool.getNextShrinkDate(); if (log.isDebugEnabled()) log.debug("scheduling pool shrinking task on " + xaPool + " for " + executionTime); if (executionTime == null) throw new IllegalArgumentException("expected a non-null execution date"); PoolShrinkingTask task = new PoolShrinkingTask(xaPool, executionTime, this); addTask(task); if (log.isDebugEnabled()) log.debug("scheduled " + task + ", total task(s) queued: " + tasks.size()); } /** * Cancel the task that will tell a XA pool to close idle connections. * @param xaPool the XA pool to notify. */ public void cancelPoolShrinking(XAPool xaPool) { if (log.isDebugEnabled()) log.debug("cancelling pool shrinking task on " + xaPool); if (xaPool == null) throw new IllegalArgumentException("expected a non-null XA pool"); if (!removeTaskByObject(xaPool)) if (log.isDebugEnabled()) log.debug("no task found based on object " + xaPool); } void addTask(Task task) { lock(); try { removeTaskByObject(task.getObject()); tasks.add(task); } finally { unlock(); } } boolean removeTaskByObject(Object obj) { lock(); try { if (log.isDebugEnabled()) log.debug("removing task by " + obj); for (Task task : tasks) { if (task.getObject() == obj) { tasks.remove(task); if (log.isDebugEnabled()) log.debug("cancelled " + task + ", total task(s) still queued: " + tasks.size()); return true; } } return false; } finally { unlock(); } } boolean setActive(boolean active) { return this.active.getAndSet(active); } private boolean isActive() { return active.get(); } public void run() { while (isActive()) { try { executeElapsedTasks(); Thread.sleep(500); // execute twice per second. That's enough precision. } catch (InterruptedException ex) { // ignore } } } private void executeElapsedTasks() { lock(); try { if (this.tasks.isEmpty()) return; Set toRemove = new HashSet(); for (Task task : tasks) { if (task.getExecutionTime().compareTo(new Date(MonotonicClock.currentTimeMillis())) <= 0) { // if the execution time is now or in the past if (log.isDebugEnabled()) log.debug("running " + task); try { task.execute(); if (log.isDebugEnabled()) log.debug("successfully ran " + task); } catch (Exception ex) { log.warn("error running " + task, ex); } finally { toRemove.add(task); if (log.isDebugEnabled()) log.debug("total task(s) still queued: " + tasks.size()); } } // if } this.tasks.removeAll(toRemove); } finally { unlock(); } } } btm-dist-2.1.4/src/bitronix/tm/timer/Task.java0000644000175000017500000000311412147207062017737 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.timer; import java.util.Date; /** * Asbtract superclass of all timed tasks. * * @author lorban */ public abstract class Task implements Comparable { private final Date executionTime; private final TaskScheduler taskScheduler; protected Task(Date executionTime, TaskScheduler scheduler) { this.executionTime = executionTime; this.taskScheduler = scheduler; } public Date getExecutionTime() { return executionTime; } protected TaskScheduler getTaskScheduler() { return taskScheduler; } public int compareTo(Task otherTask) { return this.executionTime.compareTo(otherTask.executionTime); } public abstract Object getObject(); public abstract void execute() throws TaskException; } btm-dist-2.1.4/src/bitronix/tm/timer/RecoveryTask.java0000644000175000017500000000435412147207062021465 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.timer; import bitronix.tm.TransactionManagerServices; import bitronix.tm.recovery.Recoverer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Date; /** * This task is used to run the background recovery. * * @author lorban */ public class RecoveryTask extends Task { private final static Logger log = LoggerFactory.getLogger(RecoveryTask.class); private final Recoverer recoverer; public RecoveryTask(Recoverer recoverer, Date executionTime, TaskScheduler scheduler) { super(executionTime, scheduler); this.recoverer = recoverer; } public Object getObject() { return recoverer; } public void execute() throws TaskException { if (log.isDebugEnabled()) log.debug("running recovery"); Thread recovery = new Thread(recoverer); recovery.setName("bitronix-recovery-thread"); recovery.setDaemon(true); recovery.setPriority(Thread.NORM_PRIORITY -1); recovery.start(); Date nextExecutionDate = new Date(getExecutionTime().getTime() + (TransactionManagerServices.getConfiguration().getBackgroundRecoveryIntervalSeconds() * 1000L)); if (log.isDebugEnabled()) log.debug("rescheduling recovery for " + nextExecutionDate); getTaskScheduler().scheduleRecovery(recoverer, nextExecutionDate); } public String toString() { return "a RecoveryTask scheduled for " + getExecutionTime(); } } btm-dist-2.1.4/src/bitronix/tm/timer/PoolShrinkingTask.java0000644000175000017500000000332612147207062022453 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.timer; import bitronix.tm.resource.common.XAPool; import java.util.Date; /** * This task is used to notify a XA pool to close idle connections. * * @author lorban */ public class PoolShrinkingTask extends Task { private final XAPool xaPool; public PoolShrinkingTask(XAPool xaPool, Date executionTime, TaskScheduler scheduler) { super(executionTime, scheduler); this.xaPool = xaPool; } public Object getObject() { return xaPool; } public void execute() throws TaskException { try { xaPool.shrink(); } catch (Exception ex) { throw new TaskException("error while trying to shrink " + xaPool, ex); } finally { getTaskScheduler().schedulePoolShrinking(xaPool); } } public String toString() { return "a PoolShrinkingTask scheduled for " + getExecutionTime() + " on " + xaPool; } } btm-dist-2.1.4/src/bitronix/tm/internal/0000755000175000017500000000000012147207062016667 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/internal/package.html0000644000175000017500000000013512147207062021147 0ustar tonytony

Internal implementation details.

btm-dist-2.1.4/src/bitronix/tm/internal/XAResourceManager.java0000644000175000017500000003474012147207062023055 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import bitronix.tm.BitronixXid; import bitronix.tm.TransactionManagerServices; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.utils.Scheduler; import bitronix.tm.utils.Uid; import bitronix.tm.utils.UidGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import java.util.*; /** * Every {@link bitronix.tm.BitronixTransaction} contains an instance of this class that is used to register * and keep track of resources enlisted in a transaction. * * @author lorban */ public class XAResourceManager { private final static Logger log = LoggerFactory.getLogger(XAResourceManager.class); private final Uid gtrid; private final Scheduler resources = new Scheduler(); /** * Create a resource manager for the specified GTRID. * @param gtrid the transaction's GTRID this XAResourceManager will be assigned to. */ public XAResourceManager(Uid gtrid) { this.gtrid = gtrid; } /** * Enlist the specified {@link XAResourceHolderState}. A XID is generated and the resource is started with * XAResource.TMNOFLAGS or XAResource.TMJOIN if it could be joined with another previously enlisted one. *
* There are 3 different cases that can happen when a {@link XAResourceHolderState} is enlisted: *
    *
  • already enlisted and not ended: do nothing
  • *
  • already enlisted and ended: try to join. if you can join, keep a reference on the passed-in * {@link XAResourceHolderState} and drop the previous one. if you cannot join, it's the same as case 3
  • *
  • not enlisted: create a new branch and keep a reference on the passed-in {@link XAResourceHolderState}
  • *
* * @param xaResourceHolderState the {@link XAResourceHolderState} to be enlisted. * @throws XAException if a resource error occured. * @throws BitronixSystemException if an internal error occured. */ public void enlist(XAResourceHolderState xaResourceHolderState) throws XAException, BitronixSystemException { XAResourceHolderState alreadyEnlistedHolder = findXAResourceHolderState(xaResourceHolderState.getXAResource()); if (alreadyEnlistedHolder != null && !alreadyEnlistedHolder.isEnded()) { xaResourceHolderState.setXid(alreadyEnlistedHolder.getXid()); log.warn("ignoring enlistment of already enlisted but not ended resource " + xaResourceHolderState); return; } XAResourceHolderState toBeJoinedHolderState = null; if (alreadyEnlistedHolder != null) { if (log.isDebugEnabled()) log.debug("resource already enlisted but has been ended eligible for join: " + alreadyEnlistedHolder); toBeJoinedHolderState = getManagedResourceWithSameRM(xaResourceHolderState); } BitronixXid xid; int flag; if (toBeJoinedHolderState != null) { if (log.isDebugEnabled()) log.debug("joining " + xaResourceHolderState + " with " + toBeJoinedHolderState); xid = toBeJoinedHolderState.getXid(); flag = XAResource.TMJOIN; } else { xid = UidGenerator.generateXid(gtrid); if (log.isDebugEnabled()) log.debug("creating new branch with " + xid); flag = XAResource.TMNOFLAGS; } // check for enlistment of a 2nd LRC resource, forbid this if the 2nd resource cannot be joined with the 1st one // unless this is explicitly allowed in the config if (flag != XAResource.TMJOIN && xaResourceHolderState.getTwoPcOrderingPosition() == Scheduler.ALWAYS_LAST_POSITION && !TransactionManagerServices.getConfiguration().isAllowMultipleLrc()) { List alwaysLastResources = resources.getByNaturalOrderForPosition(Scheduler.ALWAYS_LAST_POSITION); if (alwaysLastResources != null && !alwaysLastResources.isEmpty()) throw new BitronixSystemException("cannot enlist more than one non-XA resource, tried enlisting " + xaResourceHolderState + ", already enlisted: " + alwaysLastResources.get(0)); } xaResourceHolderState.setXid(xid); xaResourceHolderState.start(flag); // in case of a JOIN, the resource holder is already in the scheduler -> do not add it twice if (toBeJoinedHolderState != null) { resources.remove(toBeJoinedHolderState); } // this must be done only after start() successfully returned resources.add(xaResourceHolderState, xaResourceHolderState.getTwoPcOrderingPosition()); } /** * Delist the specified {@link XAResourceHolderState}. A reference to the resource is kept anyway. * @param xaResourceHolderState the {@link XAResourceHolderState} to be delisted. * @param flag the delistment flag. * @return true if the resource could be delisted, false otherwise. * @throws XAException if the resource threw an exception during delistment. * @throws BitronixSystemException if an internal error occured. */ public boolean delist(XAResourceHolderState xaResourceHolderState, int flag) throws XAException, BitronixSystemException { if (findXAResourceHolderState(xaResourceHolderState.getXAResource()) != null) { if (log.isDebugEnabled()) log.debug("delisting resource " + xaResourceHolderState); xaResourceHolderState.end(flag); return true; } log.warn("trying to delist resource that has not been previously enlisted: " + xaResourceHolderState); return false; } /** * Suspend all enlisted resources from the current transaction context. * @throws XAException if the resource threw an exception during suspend. */ public void suspend() throws XAException { for (XAResourceHolderState xaResourceHolderState : resources) { if (!xaResourceHolderState.isEnded()) { if (log.isDebugEnabled()) log.debug("suspending " + xaResourceHolderState); xaResourceHolderState.end(XAResource.TMSUCCESS); } } // while } /** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List toBeReEnlisted = new ArrayList(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) log.debug("resuming " + xaResourceHolderState); // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) log.debug("re-enlisting resource " + xaResourceHolderState); try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } } /** * Look if an {@link XAResource} has already been enlisted. * @param xaResource the {@link XAResource} to look for. * @return the {@link XAResourceHolderState} of the enlisted resource or null if the {@link XAResource} has not * been enlisted in this {@link XAResourceManager}. * @throws BitronixSystemException if an internal error happens. */ public XAResourceHolderState findXAResourceHolderState(XAResource xaResource) throws BitronixSystemException { for (XAResourceHolderState xaResourceHolderState : resources) { if (xaResourceHolderState.getXAResource() == xaResource) return xaResourceHolderState; } return null; } /** * Search for an eventually already enlisted {@link XAResourceHolderState} that could be joined with the * {@link XAResourceHolderState} passed as parameter.
* If datasource configuration property bitronix.useTmJoin=false is set this method always returns null. * @param xaResourceHolderState a {@link XAResourceHolderState} looking to be joined. * @return another enlisted {@link XAResourceHolderState} that can be joined with the one passed in or null if none is found. * @throws XAException if call to XAResource.isSameRM() fails. */ private XAResourceHolderState getManagedResourceWithSameRM(XAResourceHolderState xaResourceHolderState) throws XAException { if (!xaResourceHolderState.getUseTmJoin()) { if (log.isDebugEnabled()) log.debug("join disabled on resource " + xaResourceHolderState); return null; } for (XAResourceHolderState alreadyEnlistedHolderState : resources) { if (log.isDebugEnabled()) log.debug("checking joinability of " + xaResourceHolderState + " with " + alreadyEnlistedHolderState); if (alreadyEnlistedHolderState.isEnded() && !alreadyEnlistedHolderState.isSuspended() && xaResourceHolderState.getXAResource().isSameRM(alreadyEnlistedHolderState.getXAResource())) { if (log.isDebugEnabled()) log.debug("resources are joinable"); return alreadyEnlistedHolderState; } if (log.isDebugEnabled()) log.debug("resources are not joinable"); } if (log.isDebugEnabled()) log.debug("no joinable resource found for " + xaResourceHolderState); return null; } /** * Remove this transaction's {@link XAResourceHolderState} from all enlisted * {@link bitronix.tm.resource.common.XAResourceHolder}s. */ public void clearXAResourceHolderStates() { if (log.isDebugEnabled()) log.debug("clearing XAResourceHolder states on " + resources.size() + " resource(s)"); Iterator it = resources.iterator(); while (it.hasNext()) { XAResourceHolderState xaResourceHolderState = it.next(); XAResourceHolder resourceHolder = xaResourceHolderState.getXAResourceHolder(); // clear out the current state resourceHolder.removeXAResourceHolderState(xaResourceHolderState.getXid()); Map statesForGtrid = resourceHolder.getXAResourceHolderStatesForGtrid(gtrid); if (statesForGtrid != null) log.warn("resource " + resourceHolder + " did not clean up " + statesForGtrid.size() + "transaction states for GTRID [" + gtrid + "]"); else if (log.isDebugEnabled()) log.debug("resource " + resourceHolder + " cleaned up all transaction states for GTRID [" + gtrid + "]"); it.remove(); } } /** * Get a {@link Set} of unique names of all the enlisted {@link XAResourceHolderState}s. * @return a {@link Set} of unique names of all the enlisted {@link XAResourceHolderState}s. */ public Set collectUniqueNames() { Set names = new HashSet(resources.size()); for (XAResourceHolderState xaResourceHolderState : resources) { names.add(xaResourceHolderState.getUniqueName()); } return Collections.unmodifiableSet(names); } public SortedSet getNaturalOrderPositions() { return Collections.unmodifiableSortedSet(resources.getNaturalOrderPositions()); } public SortedSet getReverseOrderPositions() { return Collections.unmodifiableSortedSet(resources.getReverseOrderPositions()); } public List getNaturalOrderResourcesForPosition(Integer position) { return Collections.unmodifiableList(resources.getByNaturalOrderForPosition(position)); } public List getReverseOrderResourcesForPosition(Integer position) { return Collections.unmodifiableList(resources.getByReverseOrderForPosition(position)); } public List getAllResources() { List result = new ArrayList(resources.size()); for (Integer positionKey : resources.getNaturalOrderPositions()) { result.addAll(resources.getByNaturalOrderForPosition(positionKey)); } return Collections.unmodifiableList(result); } /** * Get the enlisted resources count. * @return the enlisted resources count. */ public int size() { return resources.size(); } /** * Get the GTRID of the transaction the {@link XAResourceManager} instance is attached to. * @return the GTRID of the transaction the {@link XAResourceManager} instance is attached to. */ public Uid getGtrid() { return gtrid; } /** * Return a human-readable representation of this object. * @return a human-readable representation of this object. */ public String toString() { return "a XAResourceManager with GTRID [" + gtrid + "] and " + resources; } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixHeuristicMixedException.java0000644000175000017500000000245212147207062026061 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import javax.transaction.HeuristicMixedException; /** * Subclass of {@link javax.transaction.HeuristicMixedException} supporting nested {@link Throwable}s. * * @author lorban */ public class BitronixHeuristicMixedException extends HeuristicMixedException { public BitronixHeuristicMixedException(String string) { super(string); } public BitronixHeuristicMixedException(String string, Throwable t) { super(string); initCause(t); } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixSystemException.java0000644000175000017500000000251212147207062024414 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import javax.transaction.SystemException; /** * Subclass of {@link javax.transaction.SystemException} supporting nested {@link Throwable}s. * * @author lorban */ public class BitronixSystemException extends SystemException { public BitronixSystemException(int errorCode) { super(errorCode); } public BitronixSystemException(String string) { super(string); } public BitronixSystemException(String string, Throwable t) { super(string); initCause(t); } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixRollbackSystemException.java0000644000175000017500000000233112147207062026065 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; /** * Subclass of {@link javax.transaction.SystemException} indicating a rollback must be performed. * This exception is used to handle unilateral rollback of resources during delistement. * * @author lorban */ public class BitronixRollbackSystemException extends BitronixSystemException { public BitronixRollbackSystemException(String string, Throwable t) { super(string, t); } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixRuntimeException.java0000644000175000017500000000222112147207062024550 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; /** * Thrown when a runtime exception happens. * * @author lorban */ public class BitronixRuntimeException extends RuntimeException { public BitronixRuntimeException(String message, Throwable cause) { super(message, cause); } public BitronixRuntimeException(String message) { super(message); } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixRollbackException.java0000644000175000017500000000240112147207062024656 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import javax.transaction.RollbackException; /** * Subclass of {@link javax.transaction.RollbackException} supporting nested {@link Throwable}s. * * @author lorban */ public class BitronixRollbackException extends RollbackException { public BitronixRollbackException(String string) { super(string); } public BitronixRollbackException(String string, Throwable t) { super(string); initCause(t); } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixHeuristicRollbackException.java0000644000175000017500000000247312147207062026547 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import javax.transaction.HeuristicRollbackException; /** * Subclass of {@link javax.transaction.HeuristicRollbackException} supporting nested {@link Throwable}s. * * @author lorban */ public class BitronixHeuristicRollbackException extends HeuristicRollbackException { public BitronixHeuristicRollbackException(String string) { super(string); } public BitronixHeuristicRollbackException(String string, Throwable t) { super(string); initCause(t); } } btm-dist-2.1.4/src/bitronix/tm/internal/XAResourceHolderState.java0000644000175000017500000002170712147207062023720 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.BitronixXid; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.MonotonicClock; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import java.util.Date; /** * {@link XAResourceHolder} state container. * Instances are kept in the transaction and bound to / unbound from the {@link XAResourceHolder} as the * resource participates in different transactions. A {@link XAResourceHolder} without {@link XAResourceHolderState} * is considered to be in local transaction mode. *

Objects of this class also expose resource specific configuration like the unique resource name.

*

The {@link XAResource} state during a transaction participation is also contained: assigned XID, transaction * start / end state...

*

There is exactly one {@link XAResourceHolderState} object per {@link XAResourceHolder} per * {@link javax.transaction.Transaction}.

* * @see bitronix.tm.resource.common.ResourceBean * @author lorban */ public class XAResourceHolderState { private final static Logger log = LoggerFactory.getLogger(XAResourceHolderState.class); private final ResourceBean bean; private final XAResourceHolder xaResourceHolder; private BitronixXid xid; private boolean started; private boolean ended; private boolean suspended; private Date transactionTimeoutDate; private boolean isTimeoutAlreadySet; private boolean failed; public XAResourceHolderState(XAResourceHolder resourceHolder, ResourceBean bean) { this.bean = bean; this.xaResourceHolder = resourceHolder; started = false; ended = false; suspended = false; isTimeoutAlreadySet = false; xid = null; } public XAResourceHolderState(XAResourceHolderState resourceHolderState) { this.bean = resourceHolderState.bean; this.xaResourceHolder = resourceHolderState.xaResourceHolder; started = false; ended = false; suspended = false; isTimeoutAlreadySet = false; xid = null; } public BitronixXid getXid() { return xid; } public void setXid(BitronixXid xid) throws BitronixSystemException { if (log.isDebugEnabled()) log.debug("assigning <" + xid + "> to <" + this + ">"); if (this.xid != null && !xid.equals(this.xid)) throw new BitronixSystemException("a XID has already been assigned to " + this); this.xid = xid; } public XAResource getXAResource() { return xaResourceHolder.getXAResource(); } public XAResourceHolder getXAResourceHolder() { return xaResourceHolder; } public Date getTransactionTimeoutDate() { return transactionTimeoutDate; } public void setTransactionTimeoutDate(Date transactionTimeoutDate) { this.transactionTimeoutDate = transactionTimeoutDate; } public String getUniqueName() { return bean.getUniqueName(); } public boolean getUseTmJoin() { return bean.getUseTmJoin(); } public int getTwoPcOrderingPosition() { return bean.getTwoPcOrderingPosition(); } public boolean getIgnoreRecoveryFailures() { return bean.getIgnoreRecoveryFailures(); } public boolean isEnded() { return ended; } public boolean isStarted() { return started; } public boolean isSuspended() { return suspended; } public boolean isFailed() { return failed; } public void end(int flags) throws XAException { boolean ended = this.ended; boolean suspended = this.suspended; if (this.ended && (flags == XAResource.TMSUSPEND)) { if (log.isDebugEnabled()) log.debug("resource already ended, changing state to suspended: " + this); this.suspended = true; return; } if (this.ended) throw new BitronixXAException("resource already ended: " + this, XAException.XAER_PROTO); if (flags == XAResource.TMSUSPEND) { if (!this.started) throw new BitronixXAException("resource hasn't been started, cannot suspend it: " + this, XAException.XAER_PROTO); if (this.suspended) throw new BitronixXAException("resource already suspended: " + this, XAException.XAER_PROTO); if (log.isDebugEnabled()) log.debug("suspending " + this + " with " + Decoder.decodeXAResourceFlag(flags)); suspended = true; } else { if (log.isDebugEnabled()) log.debug("ending " + this + " with " + Decoder.decodeXAResourceFlag(flags)); ended = true; } try { getXAResource().end(xid, flags); if (log.isDebugEnabled()) log.debug("ended " + this + " with " + Decoder.decodeXAResourceFlag(flags)); } catch(XAException ex) { // could mean failed or unilaterally rolled back failed = true; throw ex; } finally { this.suspended = suspended; this.ended = ended; this.started = false; } } public void start(int flags) throws XAException { boolean suspended = this.suspended; boolean started = this.started; if (this.ended && (flags == XAResource.TMRESUME)) { if (log.isDebugEnabled()) log.debug("resource already ended, changing state to resumed: " + this); this.suspended = false; return; } if (flags == XAResource.TMRESUME) { if (!this.suspended) throw new BitronixXAException("resource hasn't been suspended, cannot resume it: " + this, XAException.XAER_PROTO); if (!this.started) throw new BitronixXAException("resource hasn't been started, cannot resume it: " + this, XAException.XAER_PROTO); if (log.isDebugEnabled()) log.debug("resuming " + this + " with " + Decoder.decodeXAResourceFlag(flags)); suspended = false; } else { if (this.started) throw new BitronixXAException("resource already started: " + this, XAException.XAER_PROTO); if (log.isDebugEnabled()) log.debug("starting " + this + " with " + Decoder.decodeXAResourceFlag(flags)); started = true; } if (!isTimeoutAlreadySet && transactionTimeoutDate != null && bean.getApplyTransactionTimeout()) { int timeoutInSeconds = (int) ((transactionTimeoutDate.getTime() - MonotonicClock.currentTimeMillis() + 999L) / 1000L); timeoutInSeconds = Math.max(1, timeoutInSeconds); // setting a timeout of 0 means resetting -> set it to at least 1 if (log.isDebugEnabled()) log.debug("applying resource timeout of " + timeoutInSeconds + "s on " + this); getXAResource().setTransactionTimeout(timeoutInSeconds); isTimeoutAlreadySet = true; } getXAResource().start(xid, flags); this.suspended = suspended; this.started = started; this.ended = false; if (log.isDebugEnabled()) log.debug("started " + this + " with " + Decoder.decodeXAResourceFlag(flags)); } public int hashCode() { return 17 * (bean.hashCode() + xid.hashCode()); } public boolean equals(Object obj) { if (!(obj instanceof XAResourceHolderState)) return false; XAResourceHolderState other = (XAResourceHolderState) obj; return equals(other.bean, bean) && equals(other.xid, xid); } private boolean equals(Object obj1, Object obj2) { if (obj1 == obj2) return true; if (obj1 == null || obj2 == null) return false; return obj1.equals(obj2); } public String toString() { return "an XAResourceHolderState with uniqueName=" + bean.getUniqueName() + " XAResource=" + getXAResource() + (started ? " (started)":"") + (ended ? " (ended)":"") + (suspended ? " (suspended)":"") + " with XID " + xid; } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixHeuristicCommitException.java0000644000175000017500000000245312147207062026244 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import javax.transaction.HeuristicCommitException; /** * Subclass of {@link javax.transaction.HeuristicCommitException} supporting nested {@link Throwable}s. * * @author lorban */ public class BitronixHeuristicCommitException extends HeuristicCommitException { public BitronixHeuristicCommitException(String string) { super(string); } public BitronixHeuristicCommitException(String string, Throwable t) { super(string); initCause(t); } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixMultiSystemException.java0000644000175000017500000000772312147207062025440 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.Decoder; import javax.transaction.xa.XAException; import java.util.ArrayList; import java.util.List; /** * Subclass of {@link javax.transaction.SystemException} supporting nested {@link Throwable}s. * * @author lorban */ public class BitronixMultiSystemException extends BitronixSystemException { private List exceptions = new ArrayList(); private List resourceStates = new ArrayList(); public BitronixMultiSystemException(String string, List exceptions, List resourceStates) { super(string); this.exceptions = exceptions; this.resourceStates = resourceStates; } public String getMessage() { StringBuffer errorMessage = new StringBuffer(); errorMessage.append("collected "); errorMessage.append(exceptions.size()); errorMessage.append(" exception(s):"); for (int i = 0; i < exceptions.size(); i++) { errorMessage.append(System.getProperty("line.separator")); Throwable throwable = (Throwable) exceptions.get(i); String message = throwable.getMessage(); XAResourceHolderState holderState = (XAResourceHolderState) resourceStates.get(i); if (holderState != null) { errorMessage.append(" ["); errorMessage.append(holderState.getUniqueName()); errorMessage.append(" - "); } errorMessage.append(throwable.getClass().getName()); if (throwable instanceof XAException) { XAException xaEx = (XAException) throwable; errorMessage.append("("); errorMessage.append(Decoder.decodeXAExceptionErrorCode(xaEx)); String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(xaEx); if (extraErrorDetails != null) errorMessage.append(" - ").append(extraErrorDetails); errorMessage.append(")"); } errorMessage.append(" - "); errorMessage.append(message); errorMessage.append("]"); } return errorMessage.toString(); } public boolean isUnilateralRollback() { for (int i = 0; i < exceptions.size(); i++) { Throwable throwable = (Throwable) exceptions.get(i); if (!(throwable instanceof BitronixRollbackSystemException)) return false; } return true; } /** * Get the list of exceptions that have been thrown during execution. * @return the list of exceptions that have been thrown during execution. */ public List getExceptions() { return exceptions; } /** * Get the list of XAResourceHolderStates which threw an exception during execution. * This list always contains exactly one resource per exception present in {@link #getExceptions} list. * Indices of both list always match a resource against the exception it threw. * @return the list of resource which threw an exception during execution. */ public List getResourceStates() { return resourceStates; } } btm-dist-2.1.4/src/bitronix/tm/internal/BitronixXAException.java0000644000175000017500000000304212147207062023437 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import javax.transaction.xa.XAException; /** * Subclass of {@link javax.transaction.xa.XAException} supporting nested {@link Throwable}s. * * @author lorban */ public class BitronixXAException extends XAException { public BitronixXAException(String message, int errorCode) { super(message); this.errorCode = errorCode; } public BitronixXAException(String message, int errorCode, Throwable t) { super(message); this.errorCode = errorCode; initCause(t); } public static boolean isUnilateralRollback(XAException ex) { return (ex.errorCode >= XAException.XA_RBBASE && ex.errorCode <= XAException.XA_RBEND) || ex.errorCode == XAException.XAER_NOTA; } } btm-dist-2.1.4/src/bitronix/tm/internal/TransactionStatusChangeListener.java0000644000175000017500000000256512147207062026047 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; /** * {@link bitronix.tm.BitronixTransaction} status change listener interface. * * @author lorban */ public interface TransactionStatusChangeListener { /** * Fired when the status of a {@link bitronix.tm.BitronixTransaction} has changed. * @param oldStatus the old status of the {@link bitronix.tm.BitronixTransaction}. * @param newStatus the new status of the {@link bitronix.tm.BitronixTransaction}. * @see javax.transaction.Status Status constant values. */ public void statusChanged(int oldStatus, int newStatus); } btm-dist-2.1.4/src/bitronix/tm/internal/ThreadContext.java0000644000175000017500000000733412147207062022315 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.internal; import bitronix.tm.BitronixTransaction; import bitronix.tm.TransactionManagerServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Transactional context of a thread. It contains both the active transaction (if any) and all default parameters * that a transaction running on a thread must inherit. * * @author lorban */ public class ThreadContext { private final static Logger log = LoggerFactory.getLogger(ThreadContext.class); private volatile BitronixTransaction transaction; private volatile int timeout = TransactionManagerServices.getConfiguration().getDefaultTransactionTimeout(); private final Map resources = Collections.synchronizedMap(new HashMap()); /** * Return the transaction linked with this thread context. * @return the transaction linked to this thread context or null if there is none. */ public BitronixTransaction getTransaction() { return transaction; } /** * Link a transaction with this thead context. * @param transaction the transaction to link. */ public void setTransaction(BitronixTransaction transaction) { if (transaction == null) throw new IllegalArgumentException("transaction parameter cannot be null"); if (log.isDebugEnabled()) log.debug("assigning <" + transaction + "> to <" + this + ">"); this.transaction = transaction; } /** * Return this context's default timeout. * @return this context's default timeout. */ public int getTimeout() { return timeout; } /** * Set this context's default timeout. All transactions started by the thread linked to this context will get * this value as their default timeout. * @param timeout the new default timeout value in seconds. */ public void setTimeout(int timeout) { if (timeout == 0) { int defaultValue = TransactionManagerServices.getConfiguration().getDefaultTransactionTimeout(); if (log.isDebugEnabled()) log.debug("resetting default timeout of thread context to default value of " + defaultValue + "s"); this.timeout = defaultValue; } else { if (log.isDebugEnabled()) log.debug("changing default timeout of thread context to " + timeout + "s"); this.timeout = timeout; } } /** * Get this context's resources, in the JTA 1.1 TransactionSynchronizationRegistry sense. * @return this context's resources. */ public Map getResources() { return resources; } /** * Return a human-readable representation. * @return a human-readable representation. */ public String toString() { return "a ThreadContext with transaction " + transaction + ", default timeout " + timeout + "s"; } } btm-dist-2.1.4/src/bitronix/tm/BitronixTransactionSynchronizationRegistry.java0000644000175000017500000001467412147207062026611 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.internal.BitronixRuntimeException; import bitronix.tm.internal.ThreadContext; import bitronix.tm.utils.Scheduler; import javax.naming.NamingException; import javax.naming.Reference; import javax.naming.Referenceable; import javax.naming.StringRefAddr; import javax.transaction.Status; import javax.transaction.Synchronization; import javax.transaction.SystemException; import javax.transaction.TransactionSynchronizationRegistry; import java.util.Map; /** * Implementation of JTA 1.1 {@link TransactionSynchronizationRegistry}. * * @author lorban */ public class BitronixTransactionSynchronizationRegistry implements TransactionSynchronizationRegistry, Referenceable { private final BitronixTransactionManager transactionManager; public BitronixTransactionSynchronizationRegistry() { transactionManager = TransactionManagerServices.getTransactionManager(); } public Object getResource(Object key) { try { if (key == null) throw new NullPointerException("key cannot be null"); if (currentTransaction() == null || currentTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("no transaction started on current thread"); return getResources().get(key); } catch (SystemException ex) { throw new BitronixRuntimeException("cannot get current transaction status", ex); } } public boolean getRollbackOnly() { try { if (currentTransaction() == null || currentTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("no transaction started on current thread"); return currentTransaction().getStatus() == Status.STATUS_MARKED_ROLLBACK; } catch (SystemException e) { throw new BitronixRuntimeException("cannot get current transaction status"); } } public Object getTransactionKey() { try { if (currentTransaction() == null || currentTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) return null; return currentTransaction().getGtrid(); } catch (SystemException ex) { throw new BitronixRuntimeException("cannot get current transaction status", ex); } } public int getTransactionStatus() { try { if (currentTransaction() == null) return Status.STATUS_NO_TRANSACTION; return currentTransaction().getStatus(); } catch (SystemException ex) { throw new BitronixRuntimeException("cannot get current transaction status", ex); } } public void putResource(Object key, Object value) { try { if (key == null) throw new NullPointerException("key cannot be null"); if (currentTransaction() == null || currentTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("no transaction started on current thread"); getResources().put(key, value); } catch (SystemException ex) { throw new BitronixRuntimeException("cannot get current transaction status", ex); } } public void registerInterposedSynchronization(Synchronization synchronization) { try { if (currentTransaction() == null || currentTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("no transaction started on current thread"); if ( currentTransaction().getStatus() == Status.STATUS_PREPARING || currentTransaction().getStatus() == Status.STATUS_PREPARED || currentTransaction().getStatus() == Status.STATUS_COMMITTING || currentTransaction().getStatus() == Status.STATUS_COMMITTED || currentTransaction().getStatus() == Status.STATUS_ROLLING_BACK || currentTransaction().getStatus() == Status.STATUS_ROLLEDBACK ) throw new IllegalStateException("transaction is done, cannot register an interposed synchronization"); currentTransaction().getSynchronizationScheduler().add(synchronization, Scheduler.DEFAULT_POSITION -1); } catch (SystemException ex) { throw new BitronixRuntimeException("cannot get current transaction status", ex); } } public void setRollbackOnly() { try { if (currentTransaction() == null || currentTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("no transaction started on current thread"); currentTransaction().setStatus(Status.STATUS_MARKED_ROLLBACK); } catch (SystemException ex) { throw new BitronixRuntimeException("cannot get or set current transaction status", ex); } } private Map getResources() { ThreadContext currentContext = transactionManager.currentThreadContext(); if (currentContext == null) { return null; } return currentContext.getResources(); } private BitronixTransaction currentTransaction() { return transactionManager.getCurrentTransaction(); } public Reference getReference() throws NamingException { return new Reference( BitronixTransactionManager.class.getName(), new StringRefAddr("TransactionSynchronizationRegistry", "BitronixTransactionSynchronizationRegistry"), BitronixTransactionSynchronizationRegistryObjectFactory.class.getName(), null ); } } btm-dist-2.1.4/src/bitronix/tm/Version.java0000644000175000017500000000045612215446460017353 0ustar tonytonypackage bitronix.tm; public final class Version { public static String getVersion() { return "2.1.4"; } }btm-dist-2.1.4/src/bitronix/tm/utils/0000755000175000017500000000000012170065060016207 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/utils/ManagementRegistrar.java0000644000175000017500000000557712147207062023033 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import bitronix.tm.TransactionManagerServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.management.MBeanServer; import javax.management.ObjectName; import java.lang.management.ManagementFactory; /** * Simple JMX facade. In case JMX is disabled, calling methods of this class have no effect. * * @author lorban */ public final class ManagementRegistrar { private final static Logger log = LoggerFactory.getLogger(ManagementRegistrar.class); private ManagementRegistrar() { } /** * Replace characters considered illegal in a management object's name. * @param name the name to work on. * @return a fully valid name where all invalid characters have been replaced with '_'. */ public static String makeValidName(String name) { return name.replaceAll("[\\:\\,\\=,\\.]", "_"); } /** * Register the specified management object. * @param name the name of the object. * @param obj the management object. */ public static void register(String name, Object obj) { MBeanServer mbeanServer = getMBeanServer(); if (mbeanServer == null) return; try { mbeanServer.registerMBean(obj, new ObjectName(name)); } catch (Exception ex) { log.warn("cannot register object with name " + name, ex); } } /** * Unregister the management object with the specified name. * @param name the name of the object. */ public static void unregister(String name) { MBeanServer mbeanServer = getMBeanServer(); if (mbeanServer == null) return; try { mbeanServer.unregisterMBean(new ObjectName(name)); } catch (Exception ex) { log.warn("cannot unregister object with name " + name, ex); } } private static MBeanServer getMBeanServer() { if (!TransactionManagerServices.getConfiguration().isDisableJmx()) { return ManagementFactory.getPlatformMBeanServer(); } else { return null; } } } btm-dist-2.1.4/src/bitronix/tm/utils/package.html0000644000175000017500000000012212147207062020467 0ustar tonytony

Misc utility classes.

btm-dist-2.1.4/src/bitronix/tm/utils/CollectionUtils.java0000644000175000017500000000302612147207062022173 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import java.util.Collection; import java.util.Iterator; /** *

{@link Collection} helper functions.

* * @author lorban */ public class CollectionUtils { /** * Check if a collection contains a specific object by searching for it by identity * instead of by using equals/hashcode. * @param collection the collection to search in. * @param toBeFound the object to search for. * @return true if the collection contains the object, false otherwise. */ public static boolean containsByIdentity(Collection collection, Object toBeFound) { for (Object o : collection) { if (o == toBeFound) return true; } return false; } } btm-dist-2.1.4/src/bitronix/tm/utils/PropertyException.java0000644000175000017500000000222612147207062022563 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; /** * Thrown by {@link PropertyUtils} when some reflection error occurs. * * @author lorban */ public class PropertyException extends RuntimeException { public PropertyException(String message, Throwable cause) { super(message, cause); } public PropertyException(String message) { super(message); } } btm-dist-2.1.4/src/bitronix/tm/utils/DefaultExceptionAnalyzer.java0000644000175000017500000000263712147207062024037 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2011, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import javax.transaction.xa.XAException; /** * Default implementation of {@link ExceptionAnalyzer}. * * @author lorban */ public class DefaultExceptionAnalyzer implements ExceptionAnalyzer { public String extractExtraXAExceptionDetails(XAException ex) { if (ex.getClass().getName().equals("oracle.jdbc.xa.OracleXAException")) { try { return "ORA-" + PropertyUtils.getProperty(ex, "oracleError"); } catch (PropertyException e) { return null; } } return null; } public void shutdown() { } } btm-dist-2.1.4/src/bitronix/tm/utils/InitializationException.java0000644000175000017500000000224412147207062023726 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; /** * Thrown at transaction manager startup when an error occurs. * * @author lorban */ public class InitializationException extends RuntimeException { public InitializationException(String message) { super(message); } public InitializationException(String message, Throwable cause) { super(message, cause); } } btm-dist-2.1.4/src/bitronix/tm/utils/ClassLoaderUtils.java0000644000175000017500000000577412147207062022310 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.InputStream; /** * Static utility methods for loading classes and resources. */ public class ClassLoaderUtils { private final static Logger log = LoggerFactory.getLogger(ClassLoaderUtils.class); /** * Get the class loader which can be used to generate proxies without leaking memory. * @return the class loader which can be used to generate proxies without leaking memory. */ public static ClassLoader getClassLoader() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl != null) { return cl; } return ClassLoaderUtils.class.getClassLoader(); } /** * Load a class by name. Tries the current thread's context loader then falls back to {@link Class#forName(String)}. * @param className name of the class to load. * @return the loaded class. * @throws ClassNotFoundException if the class cannot be found in the classpath. */ public static Class loadClass(String className) throws ClassNotFoundException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl != null) { try { return cl.loadClass(className); } catch (ClassNotFoundException ex) { if (log.isDebugEnabled()) log.debug("context classloader could not find class '" + className + "', trying Class.forName() instead"); } } return Class.forName(className); } /** * Load a resource from the classpath. Tries the current thread's context loader then falls back to * {@link ClassLoader#getResourceAsStream(String)} using this class' classloader. * @param resourceName the resource name to load. * @return a {@link java.io.InputStream} if the resource could be found, null otherwise. */ public static InputStream getResourceAsStream(String resourceName) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl != null) return cl.getResourceAsStream(resourceName); return ClassLoaderUtils.class.getClassLoader().getResourceAsStream(resourceName); } }btm-dist-2.1.4/src/bitronix/tm/utils/StackTrace.java0000644000175000017500000000171512147207062021106 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; /** * A dummy {@link Throwable} used to build a call stack. * * @author Ludovic Orban */ public class StackTrace extends Throwable { } btm-dist-2.1.4/src/bitronix/tm/utils/CryptoEngine.java0000644000175000017500000014754012170065060021473 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import bitronix.tm.Version; import bitronix.tm.internal.BitronixRuntimeException; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; import javax.crypto.CipherOutputStream; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; /** *

Simple crypto helper that uses symetric keys to crypt and decrypt resources passwords.

* * @author lorban */ public class CryptoEngine { private static final int LONG_SIZE_IN_BYTES = 8; private static final String CRYPTO_PASSWORD = "B1tr0n!+B1tr0n!+B1tr0n!+"; /** * Crypt the given data using the given cipher. * The crypted result is base64-encoded before it is returned. * @param cipher the cypther to use. * @param data the data to crypt. * @return crypted, base64-encoded data. * @throws InvalidKeyException if the given key material is shorter than 8 bytes. * @throws NoSuchAlgorithmException if a secret-key factory for the specified algorithm is not available in the * default provider package or any of the other provider packages that were searched. * @throws NoSuchPaddingException if transformation contains a padding scheme that is not available. * @throws InvalidKeySpecException if the given key specification is inappropriate for this secret-key factory to * produce a secret key. * @throws IOException if an I/O error occurs. */ public static String crypt(String cipher, String data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IOException { byte[] prependedBytes = Encoder.longToBytes(MonotonicClock.currentTimeMillis()); byte[] dataBytes = data.getBytes("US-ASCII"); byte[] toCrypt = new byte[LONG_SIZE_IN_BYTES + dataBytes.length]; System.arraycopy(prependedBytes, 0, toCrypt, 0, LONG_SIZE_IN_BYTES); System.arraycopy(dataBytes, 0, toCrypt, LONG_SIZE_IN_BYTES, dataBytes.length); KeySpec keySpec = loadKeySpec(CRYPTO_PASSWORD.getBytes(), cipher); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(cipher); SecretKey secretKey = keyFactory.generateSecret(keySpec); Cipher desCipher = Cipher.getInstance(cipher); desCipher.init(Cipher.ENCRYPT_MODE, secretKey); ByteArrayOutputStream bos = new ByteArrayOutputStream(); CipherOutputStream cos = new CipherOutputStream(bos, desCipher); cos.write(toCrypt); cos.close(); bos.close(); byte[] cypherBytes = bos.toByteArray(); return Base64.encodeBytes(cypherBytes); } private static KeySpec loadKeySpec(byte[] bytes, String cipher) throws NoSuchAlgorithmException { try { Class aClass = ClassLoaderUtils.loadClass("javax.crypto.spec." + cipher + "KeySpec"); return (KeySpec) aClass.getConstructor(byte[].class).newInstance(bytes); } catch (Exception e) { throw new NoSuchAlgorithmException("No such KeySpec: " + cipher, e); } } /** * Decrypt using the given cipher the given base64-encoded, crypted data. * @param cipher the cypther to use. * @param data the base64-encoded data to decrypt. * @return decrypted data. * @throws InvalidKeyException if the given key material is shorter than 8 bytes. * @throws NoSuchAlgorithmException if a secret-key factory for the specified algorithm is not available in the * default provider package or any of the other provider packages that were searched. * @throws NoSuchPaddingException if transformation contains a padding scheme that is not available. * @throws InvalidKeySpecException if the given key specification is inappropriate for this secret-key factory to * produce a secret key. * @throws IOException if an I/O error occurs. */ public static String decrypt(String cipher, String data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IOException { KeySpec keySpec = loadKeySpec(CRYPTO_PASSWORD.getBytes(), cipher); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(cipher); SecretKey secretKey = keyFactory.generateSecret(keySpec); Cipher desCipher = Cipher.getInstance(cipher); desCipher.init(Cipher.DECRYPT_MODE, secretKey); byte[] cypherBytes = Base64.decode(data); ByteArrayInputStream bis = new ByteArrayInputStream(cypherBytes); CipherInputStream cis = new CipherInputStream(bis, desCipher); StringBuffer sb = new StringBuffer(); while (true) { int b = cis.read(); if (b == -1) break; sb.append((char) b); } if (sb.length() < LONG_SIZE_IN_BYTES +1) throw new BitronixRuntimeException("invalid crypted password '" + data + "'"); return sb.substring(LONG_SIZE_IN_BYTES); } /** * Main method of this class to be used as a command-line tool to get a crypted version of a resource password. * @param args the command-line arguments. * @throws Exception when an error occurs crypting the given resource password. */ public static void main(String[] args) throws Exception { System.out.println("Bitronix Transaction Manager " + Version.getVersion() + " password property crypter"); System.out.flush(); if (args.length < 1 || args.length > 2) { System.err.println("Usage: CryptoEngine [cipher]"); System.err.println(" where:"); System.err.println(" is mandatory and is the resource password to crypt"); System.err.println(" [cipher] is optional and is the cipher to be used to crypt the password"); System.exit(1); } String data = args[0]; String cipher = "DES"; if (args.length > 1) cipher = args[1]; String propertyValue = "{" + cipher + "}" + crypt(cipher, data); System.out.println("crypted password property value: " + propertyValue); } /** *

Encode and decode to / from Base64 notation.

*

Homepage: http://iharder.net/base64.

* @author Robert Harder * @author rob@iharder.net */ private final static class Base64 { public final static int NO_OPTIONS = 0; public final static int ENCODE = 1; public final static int DECODE = 0; public final static int GZIP = 2; public final static int DONT_BREAK_LINES = 8; public final static int URL_SAFE = 16; public final static int ORDERED = 32; private final static int MAX_LINE_LENGTH = 76; private final static byte EQUALS_SIGN = (byte) '='; private final static byte NEW_LINE = (byte) '\n'; private final static String PREFERRED_ENCODING = "UTF-8"; private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding /** * The 64 valid Base64 values. */ //private final static byte[] ALPHABET; /* Host platform me be something funny like EBCDIC, so we hardcode these values. */ private final static byte[] _STANDARD_ALPHABET = { (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) '+', (byte) '/' }; /** * Translates a Base64 value to either its 6-bit reconstruction value * or a negative number indicating some other meaning. */ private final static byte[] _STANDARD_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8 -5, -5, // Whitespace: Tab and Linefeed -9, -9, // Decimal 11 - 12 -5, // Whitespace: Carriage Return -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26 -9, -9, -9, -9, -9, // Decimal 27 - 31 -5, // Whitespace: Space -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42 62, // Plus sign at decimal 43 -9, -9, -9, // Decimal 44 - 46 63, // Slash at decimal 47 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine -9, -9, -9, // Decimal 58 - 60 -1, // Equals sign at decimal 61 -9, -9, -9, // Decimal 62 - 64 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N' 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z' -9, -9, -9, -9, -9, -9, // Decimal 91 - 96 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm' 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z' -9, -9, -9, -9 // Decimal 123 - 126 /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */ }; /** * Used in the URL- and Filename-safe dialect described in Section 4 of RFC3548: * http://www.faqs.org/rfcs/rfc3548.html. * Notice that the last two bytes become "hyphen" and "underscore" instead of "plus" and "slash." */ private final static byte[] _URL_SAFE_ALPHABET = { (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) '-', (byte) '_' }; /** * Used in decoding URL- and Filename-safe dialects of Base64. */ private final static byte[] _URL_SAFE_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8 -5, -5, // Whitespace: Tab and Linefeed -9, -9, // Decimal 11 - 12 -5, // Whitespace: Carriage Return -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26 -9, -9, -9, -9, -9, // Decimal 27 - 31 -5, // Whitespace: Space -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42 -9, // Plus sign at decimal 43 -9, // Decimal 44 62, // Minus sign at decimal 45 -9, // Decimal 46 -9, // Slash at decimal 47 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine -9, -9, -9, // Decimal 58 - 60 -1, // Equals sign at decimal 61 -9, -9, -9, // Decimal 62 - 64 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N' 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z' -9, -9, -9, -9, // Decimal 91 - 94 63, // Underscore at decimal 95 -9, // Decimal 96 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm' 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z' -9, -9, -9, -9 // Decimal 123 - 126 /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */ }; /** * I don't get the point of this technique, but it is described here: * http://www.faqs.org/qa/rfcc-1940.html. */ private final static byte[] _ORDERED_ALPHABET = { (byte) '-', (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) '_', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z' }; /** * Used in decoding the "ordered" dialect of Base64. */ private final static byte[] _ORDERED_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 0 - 8 -5, -5, // Whitespace: Tab and Linefeed -9, -9, // Decimal 11 - 12 -5, // Whitespace: Carriage Return -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26 -9, -9, -9, -9, -9, // Decimal 27 - 31 -5, // Whitespace: Space -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42 -9, // Plus sign at decimal 43 -9, // Decimal 44 0, // Minus sign at decimal 45 -9, // Decimal 46 -9, // Slash at decimal 47 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, // Numbers zero through nine -9, -9, -9, // Decimal 58 - 60 -1, // Equals sign at decimal 61 -9, -9, -9, // Decimal 62 - 64 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, // Letters 'A' through 'M' 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, // Letters 'N' through 'Z' -9, -9, -9, -9, // Decimal 91 - 94 37, // Underscore at decimal 95 -9, // Decimal 96 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, // Letters 'a' through 'm' 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // Letters 'n' through 'z' -9, -9, -9, -9 // Decimal 123 - 126 /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243 -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */ }; /** * Returns one of the _SOMETHING_ALPHABET byte arrays depending on * the options specified. * It's possible, though silly, to specify ORDERED and URLSAFE * in which case one of them will be picked, though there is * no guarantee as to which one will be picked. * @param options the options * @return a byte array */ private static byte[] getAlphabet(int options) { if ((options & URL_SAFE) == URL_SAFE) return _URL_SAFE_ALPHABET; else if ((options & ORDERED) == ORDERED) return _ORDERED_ALPHABET; else return _STANDARD_ALPHABET; } // end getAlphabet /** * Returns one of the _SOMETHING_DECODABET byte arrays depending on * the options specified. * It's possible, though silly, to specify ORDERED and URL_SAFE * in which case one of them will be picked, though there is * no guarantee as to which one will be picked. * @param options the options * @return a byte array */ private static byte[] getDecodabet(int options) { if ((options & URL_SAFE) == URL_SAFE) return _URL_SAFE_DECODABET; else if ((options & ORDERED) == ORDERED) return _ORDERED_DECODABET; else return _STANDARD_DECODABET; } // end getAlphabet /** * Defeats instantiation. */ private Base64() { } /** * Encodes up to the first three bytes of array threeBytes * and returns a four-byte array in Base64 notation. * The actual number of significant bytes in your array is * given by numSigBytes. * The array threeBytes needs only be as big as * numSigBytes. * Code can reuse a byte array by passing a four-byte array as b4. * * @param b4 A reusable byte array to reduce array instantiation * @param threeBytes the array to convert * @param numSigBytes the number of significant bytes in your array * @param options the options * @return four byte array in Base64 notation. * @since 1.5.1 */ private static byte[] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes, int options) { encode3to4(threeBytes, 0, numSigBytes, b4, 0, options); return b4; } // end encode3to4 /** *

Encodes up to three bytes of the array source * and writes the resulting four Base64 bytes to destination. * The source and destination arrays can be manipulated * anywhere along their length by specifying * srcOffset and destOffset. * This method does not check to make sure your arrays * are large enough to accomodate srcOffset + 3 for * the source array or destOffset + 4 for * the destination array. * The actual number of significant bytes in your array is * given by numSigBytes.

*

This is the lowest level of the encoding methods with * all possible parameters.

* * @param source the array to convert * @param srcOffset the index where conversion begins * @param numSigBytes the number of significant bytes in your array * @param destination the array to hold the conversion * @param destOffset the index where output will be put * @param options the options * @return the destination array * @since 1.3 */ private static byte[] encode3to4( byte[] source, int srcOffset, int numSigBytes, byte[] destination, int destOffset, int options) { byte[] ALPHABET = getAlphabet(options); // 1 2 3 // 01234567890123456789012345678901 Bit position // --------000000001111111122222222 Array position from threeBytes // --------| || || || | Six bit groups to index ALPHABET // >>18 >>12 >> 6 >> 0 Right shift necessary // 0x3f 0x3f 0x3f Additional AND // Create buffer with zero-padding if there are only one or two // significant bytes passed in the array. // We have to shift left 24 in order to flush out the 1's that appear // when Java treats a value as negative that is cast from a byte to an int. int inBuff = (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8) : 0) | (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16) : 0) | (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24) : 0); switch (numSigBytes) { case 3: destination[destOffset] = ALPHABET[(inBuff >>> 18)]; destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f]; destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f]; destination[destOffset + 3] = ALPHABET[(inBuff) & 0x3f]; return destination; case 2: destination[destOffset] = ALPHABET[(inBuff >>> 18)]; destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f]; destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f]; destination[destOffset + 3] = EQUALS_SIGN; return destination; case 1: destination[destOffset] = ALPHABET[(inBuff >>> 18)]; destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f]; destination[destOffset + 2] = EQUALS_SIGN; destination[destOffset + 3] = EQUALS_SIGN; return destination; default: return destination; } // end switch } // end encode3to4 /** * Encodes a byte array into Base64 notation. * Does not GZip-compress data. * * @param source The data to convert * @return a String * @since 1.4 */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes /** * Encodes a byte array into Base64 notation. *

* Valid options:

         *   GZIP: gzip-compresses object before encoding it.
         *   DONT_BREAK_LINES: don't break lines at 76 characters
         *     Note: Technically, this makes your encoding non-compliant.
         * 
*

* Example: encodeBytes( myData, Base64.GZIP ) or *

* Example: encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES ) * * @param source The data to convert * @param off Offset in array where conversion should begin * @param len Length of data to convert * @param options alphabet type is pulled from this (standard, url-safe, ordered) * @see Base64#GZIP * @see Base64#DONT_BREAK_LINES * @since 2.0 * @return a String */ public static String encodeBytes(byte[] source, int off, int len, int options) { // Isolate options int dontBreakLines = (options & DONT_BREAK_LINES); int gzip = (options & GZIP); // Compress? if (gzip == GZIP) { java.io.ByteArrayOutputStream baos = null; java.util.zip.GZIPOutputStream gzos = null; Base64.OutputStream b64os = null; try { // GZip -> Base64 -> ByteArray baos = new java.io.ByteArrayOutputStream(); b64os = new Base64.OutputStream(baos, ENCODE | options); gzos = new java.util.zip.GZIPOutputStream(b64os); gzos.write(source, off, len); gzos.close(); } // end try catch (java.io.IOException e) { e.printStackTrace(); return null; } // end catch finally { try { gzos.close(); } catch (Exception e) { // ignore } try { b64os.close(); } catch (Exception e) { // ignore } try { baos.close(); } catch (Exception e) { // ignore } } // end finally // Return value according to relevant encoding. try { return new String(baos.toByteArray(), PREFERRED_ENCODING); } // end try catch (java.io.UnsupportedEncodingException uue) { return new String(baos.toByteArray()); } // end catch } // end if: compress // Else, don't compress. Better not to use streams at all then. else { // Convert option to boolean in way that code likes it. boolean breakLines = dontBreakLines == 0; int len43 = len * 4 / 3; byte[] outBuff = new byte[(len43) // Main 4:3 + ((len % 3) > 0 ? 4 : 0) // Account for padding + (breakLines ? (len43 / MAX_LINE_LENGTH) : 0)]; // New lines int d = 0; int e = 0; int len2 = len - 2; int lineLength = 0; for (; d < len2; d += 3, e += 4) { encode3to4(source, d + off, 3, outBuff, e, options); lineLength += 4; if (breakLines && lineLength == MAX_LINE_LENGTH) { outBuff[e + 4] = NEW_LINE; e++; lineLength = 0; } // end if: end of line } // en dfor: each piece of array if (d < len) { encode3to4(source, d + off, len - d, outBuff, e, options); e += 4; } // end if: some padding needed // Return value according to relevant encoding. try { return new String(outBuff, 0, e, PREFERRED_ENCODING); } // end try catch (java.io.UnsupportedEncodingException uue) { return new String(outBuff, 0, e); } // end catch } // end else: don't compress } // end encodeBytes /** * Decodes four bytes from array source * and writes the resulting bytes (up to three of them) * to destination. * The source and destination arrays can be manipulated * anywhere along their length by specifying * srcOffset and destOffset. * This method does not check to make sure your arrays * are large enough to accomodate srcOffset + 4 for * the source array or destOffset + 3 for * the destination array. * This method returns the actual number of bytes that * were converted from the Base64 encoding. *

This is the lowest level of the decoding methods with * all possible parameters.

* * @param source the array to convert * @param srcOffset the index where conversion begins * @param destination the array to hold the conversion * @param destOffset the index where output will be put * @param options alphabet type is pulled from this (standard, url-safe, ordered) * @return the number of decoded bytes converted * @since 1.3 */ private static int decode4to3(byte[] source, int srcOffset, byte[] destination, int destOffset, int options) { byte[] DECODABET = getDecodabet(options); // Example: Dk== if (source[srcOffset + 2] == EQUALS_SIGN) { // Two ways to do the same thing. Don't know which way I like best. //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) // | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 ); int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18) | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12); destination[destOffset] = (byte) (outBuff >>> 16); return 1; } // Example: DkL= else if (source[srcOffset + 3] == EQUALS_SIGN) { // Two ways to do the same thing. Don't know which way I like best. //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 ) // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 ); int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18) | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12) | ((DECODABET[source[srcOffset + 2]] & 0xFF) << 6); destination[destOffset] = (byte) (outBuff >>> 16); destination[destOffset + 1] = (byte) (outBuff >>> 8); return 2; } // Example: DkLE else { try { // Two ways to do the same thing. Don't know which way I like best. //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 ) // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 ) // | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 ); int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18) | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12) | ((DECODABET[source[srcOffset + 2]] & 0xFF) << 6) | ((DECODABET[source[srcOffset + 3]] & 0xFF)); destination[destOffset] = (byte) (outBuff >> 16); destination[destOffset + 1] = (byte) (outBuff >> 8); destination[destOffset + 2] = (byte) (outBuff); return 3; } catch (Exception e) { System.out.println("" + source[srcOffset] + ": " + (DECODABET[source[srcOffset]])); System.out.println("" + source[srcOffset + 1] + ": " + (DECODABET[source[srcOffset + 1]])); System.out.println("" + source[srcOffset + 2] + ": " + (DECODABET[source[srcOffset + 2]])); System.out.println("" + source[srcOffset + 3] + ": " + (DECODABET[source[srcOffset + 3]])); return -1; } // end catch } } // end decodeToBytes /** * Very low-level access to decoding ASCII characters in * the form of a byte array. Does not support automatically * gunzipping or any other "fancy" features. * * @param source The Base64 encoded data * @param off The offset of where to begin decoding * @param len The length of characters to decode * @param options the options * @return decoded data * @since 1.3 */ public static byte[] decode(byte[] source, int off, int len, int options) { byte[] DECODABET = getDecodabet(options); int len34 = len * 3 / 4; byte[] outBuff = new byte[len34]; // Upper limit on size of output int outBuffPosn = 0; byte[] b4 = new byte[4]; int b4Posn = 0; int i; byte sbiCrop; byte sbiDecode; for (i = off; i < off + len; i++) { sbiCrop = (byte) (source[i] & 0x7f); // Only the low seven bits sbiDecode = DECODABET[sbiCrop]; if (sbiDecode >= WHITE_SPACE_ENC) // White space, Equals sign or better { if (sbiDecode >= EQUALS_SIGN_ENC) { b4[b4Posn++] = sbiCrop; if (b4Posn > 3) { outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, options); b4Posn = 0; // If that was the equals sign, break out of 'for' loop if (sbiCrop == EQUALS_SIGN) break; } // end if: quartet built } // end if: equals sign or better } // end if: white space, equals sign or better else { System.err.println("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)"); return null; } // end else: } // each input character byte[] out = new byte[outBuffPosn]; System.arraycopy(outBuff, 0, out, 0, outBuffPosn); return out; } // end decode /** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(String s) { return decode(s, NO_OPTIONS); } /** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @param options encode options such as URL_SAFE * @return the decoded data * @since 1.4 */ public static byte[] decode(String s, int options) { byte[] bytes; try { bytes = s.getBytes(PREFERRED_ENCODING); } // end try catch (java.io.UnsupportedEncodingException uee) { bytes = s.getBytes(); } // end catch // // Decode bytes = decode(bytes, 0, bytes.length, options); // Check to see if it's gzip-compressed // GZIP Magic Two-Byte Number: 0x8b1f (35615) if (bytes != null && bytes.length >= 4) { int head = ((int) bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00); if (java.util.zip.GZIPInputStream.GZIP_MAGIC == head) { java.io.ByteArrayInputStream bais = null; java.util.zip.GZIPInputStream gzis = null; java.io.ByteArrayOutputStream baos = null; byte[] buffer = new byte[2048]; int length; try { baos = new java.io.ByteArrayOutputStream(); bais = new java.io.ByteArrayInputStream(bytes); gzis = new java.util.zip.GZIPInputStream(bais); while ((length = gzis.read(buffer)) >= 0) { baos.write(buffer, 0, length); } // end while: reading input // No error? Get new bytes. bytes = baos.toByteArray(); } // end try catch (java.io.IOException e) { // Just return originally-decoded bytes } // end catch finally { try { baos.close(); } catch (Exception e) { // ignore } try { gzis.close(); } catch (Exception e) { // ignore } try { bais.close(); } catch (Exception e) { // ignore } } // end finally } // end if: gzipped } // end if: bytes.length >= 2 return bytes; } // end decode /** * Attempts to decode Base64 data and deserialize a Java * Object within. Returns null if there was an error. * * @param encodedObject The Base64 data to decode * @return The decoded and deserialized object * @since 1.5 */ public static Object decodeToObject(String encodedObject) { // Decode and gunzip if necessary byte[] objBytes = decode(encodedObject); java.io.ByteArrayInputStream bais = null; java.io.ObjectInputStream ois = null; Object obj = null; try { bais = new java.io.ByteArrayInputStream(objBytes); ois = new java.io.ObjectInputStream(bais); obj = ois.readObject(); } // end try catch (java.io.IOException e) { e.printStackTrace(); obj = null; } // end catch catch (java.lang.ClassNotFoundException e) { e.printStackTrace(); obj = null; } // end catch finally { try { if (bais != null) bais.close(); } catch (Exception e) { // ignore } try { if (ois != null) ois.close(); } catch (Exception e) { // ignore } } // end finally return obj; } // end decodeObject /** * A {@link Base64.OutputStream} will write data to another * java.io.OutputStream, given in the constructor, * and encode/decode to/from Base64 notation on the fly. * * @see Base64 * @since 1.3 */ public static class OutputStream extends java.io.FilterOutputStream { private boolean encode; private int position; private byte[] buffer; private int bufferLength; private int lineLength; private boolean breakLines; private byte[] b4; // Scratch used in a few places private boolean suspendEncoding; private int options; // Record for later private byte[] decodabet; // Local copies to avoid extra method calls /** * Constructs a {@link Base64.OutputStream} in ENCODE mode. * * @param out the java.io.OutputStream to which data will be written. * @since 1.3 */ public OutputStream(java.io.OutputStream out) { this(out, ENCODE); } // end constructor /** * Constructs a {@link Base64.OutputStream} in * either ENCODE or DECODE mode. *

* Valid options:

             *   ENCODE or DECODE: Encode or Decode as data is read.
             *   DONT_BREAK_LINES: don't break lines at 76 characters
             *     (only meaningful when encoding)
             *     Note: Technically, this makes your encoding non-compliant.
             * 
*

* Example: new Base64.OutputStream( out, Base64.ENCODE ) * * @param out the java.io.OutputStream to which data will be written. * @param options Specified options. * @see Base64#ENCODE * @see Base64#DECODE * @see Base64#DONT_BREAK_LINES * @since 1.3 */ public OutputStream(java.io.OutputStream out, int options) { super(out); this.breakLines = (options & DONT_BREAK_LINES) != DONT_BREAK_LINES; this.encode = (options & ENCODE) == ENCODE; this.bufferLength = encode ? 3 : 4; this.buffer = new byte[bufferLength]; this.position = 0; this.lineLength = 0; this.suspendEncoding = false; this.b4 = new byte[4]; this.options = options; this.decodabet = getDecodabet(options); } // end constructor /** * Writes the byte to the output stream after * converting to/from Base64 notation. * When encoding, bytes are buffered three * at a time before the output stream actually * gets a write() call. * When decoding, bytes are buffered four * at a time. * * @param theByte the byte to write * @since 1.3 */ public void write(int theByte) throws java.io.IOException { // Encoding suspended? if (suspendEncoding) { super.out.write(theByte); return; } // end if: supsended // Encode? if (encode) { buffer[position++] = (byte) theByte; if (position >= bufferLength) // Enough to encode. { out.write(encode3to4(b4, buffer, bufferLength, options)); lineLength += 4; if (breakLines && lineLength >= MAX_LINE_LENGTH) { out.write(NEW_LINE); lineLength = 0; } // end if: end of line position = 0; } // end if: enough to output } // end if: encoding // Else, Decoding else { // Meaningful Base64 character? if (decodabet[theByte & 0x7f] > WHITE_SPACE_ENC) { buffer[position++] = (byte) theByte; if (position >= bufferLength) // Enough to output. { int len = Base64.decode4to3(buffer, 0, b4, 0, options); out.write(b4, 0, len); //out.write( Base64.decode4to3( buffer ) ); position = 0; } // end if: enough to output } // end if: meaningful base64 character else if (decodabet[theByte & 0x7f] != WHITE_SPACE_ENC) { throw new java.io.IOException("Invalid character in Base64 data."); } // end else: not white space either } // end else: decoding } // end write /** * Calls {@link #write(int)} repeatedly until len * bytes are written. * * @param theBytes array from which to read bytes * @param off offset for array * @param len max number of bytes to read into array * @since 1.3 */ public void write(byte[] theBytes, int off, int len) throws java.io.IOException { // Encoding suspended? if (suspendEncoding) { super.out.write(theBytes, off, len); return; } // end if: supsended for (int i = 0; i < len; i++) { write(theBytes[off + i]); } // end for: each byte written } // end write /** * Method added by PHIL. [Thanks, PHIL. -Rob] * This pads the buffer without closing the stream. * @throws java.io.IOException when wrong padding is used */ public void flushBase64() throws java.io.IOException { if (position > 0) { if (encode) { out.write(encode3to4(b4, buffer, position, options)); position = 0; } // end if: encoding else { throw new java.io.IOException("Base64 input not properly padded."); } // end else: decoding } // end if: buffer partially full } // end flush /** * Flushes and closes (I think, in the superclass) the stream. * * @since 1.3 */ public void close() throws java.io.IOException { // 1. Ensure that pending characters are written flushBase64(); // 2. Actually close the stream // Base class both flushes and closes. super.close(); buffer = null; out = null; } // end close /** * Suspends encoding of the stream. * May be helpful if you need to embed a piece of * base640-encoded data in a stream. * * @since 1.5.1 * @throws java.io.IOException never thrown */ public void suspendEncoding() throws java.io.IOException { flushBase64(); this.suspendEncoding = true; } // end suspendEncoding /** * Resumes encoding of the stream. * May be helpful if you need to embed a piece of * base640-encoded data in a stream. * * @since 1.5.1 */ public void resumeEncoding() { this.suspendEncoding = false; } // end resumeEncoding } // end inner class OutputStream } // end class Base64 } btm-dist-2.1.4/src/bitronix/tm/utils/ExceptionAnalyzer.java0000644000175000017500000000255312147207062022527 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2011, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import javax.transaction.xa.XAException; /** * Exception analyzers are used to extract non-standard information from vendor exceptions. * * @author lorban */ public interface ExceptionAnalyzer extends Service { /** * Extract information from a vendor's XAException that isn't available through standard APIs. * @param ex the {@link XAException} to analyze. * @return extra error details as a human-readable string, or null if nothing extra was found. */ public String extractExtraXAExceptionDetails(XAException ex); } btm-dist-2.1.4/src/bitronix/tm/utils/Scheduler.java0000644000175000017500000002037512147207062021003 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import java.util.*; /** * Positional object container. Objects can be added to a scheduler at a certain position (or priority) and can be * retrieved later on in their position + added order. All the objects of a scheduler can be iterated in order or * objects of a cetain position can be retrieved for iteration. * * @author lorban */ public class Scheduler implements Iterable { public static final Integer DEFAULT_POSITION = 0; public static final Integer ALWAYS_FIRST_POSITION = Integer.MIN_VALUE; public static final Integer ALWAYS_LAST_POSITION = Integer.MAX_VALUE; private List keys = new ArrayList(); private Map> objects = new TreeMap>(); private int size = 0; public Scheduler() { } public synchronized void add(T obj, Integer position) { List list = objects.get(position); if (list == null) { if (!keys.contains(position)) { keys.add(position); Collections.sort(keys); } list = new ArrayList(); objects.put(position, list); } list.add(obj); size++; } public synchronized void remove(T obj) { Iterator it = iterator(); while (it.hasNext()) { T o = it.next(); if (o == obj) { it.remove(); return; } } throw new NoSuchElementException("no such element: " + obj); } public synchronized SortedSet getNaturalOrderPositions() { return new TreeSet(objects.keySet()); } public synchronized SortedSet getReverseOrderPositions() { TreeSet result = new TreeSet(Collections.reverseOrder()); result.addAll(getNaturalOrderPositions()); return result; } public synchronized List getByNaturalOrderForPosition(Integer position) { return objects.get(position); } public synchronized List getByReverseOrderForPosition(Integer position) { List result = new ArrayList(getByNaturalOrderForPosition(position)); Collections.reverse(result); return result; } public synchronized int size() { return size; } public Iterator iterator() { return new SchedulerNaturalOrderIterator(); } public Iterator reverseIterator() { return new SchedulerReverseOrderIterator(); } public String toString() { return "a Scheduler with " + size() + " object(s) in " + getNaturalOrderPositions().size() + " position(s)"; } /** * This iterator supports in-flight updates of the iterated object. */ private final class SchedulerNaturalOrderIterator implements Iterator { private int nextKeyIndex; private List objectsOfCurrentKey; private int objectsOfCurrentKeyIndex; private SchedulerNaturalOrderIterator() { this.nextKeyIndex = 0; } public void remove() { synchronized (Scheduler.this) { if (objectsOfCurrentKey == null) throw new NoSuchElementException("iterator not yet placed on an element"); objectsOfCurrentKeyIndex--; objectsOfCurrentKey.remove(objectsOfCurrentKeyIndex); if (objectsOfCurrentKey.size() == 0) { // there are no more objects in the current position's list -> remove it nextKeyIndex--; Integer key = Scheduler.this.keys.get(nextKeyIndex); Scheduler.this.keys.remove(nextKeyIndex); Scheduler.this.objects.remove(key); objectsOfCurrentKey = null; } Scheduler.this.size--; } } public boolean hasNext() { synchronized (Scheduler.this) { if (objectsOfCurrentKey == null || objectsOfCurrentKeyIndex >= objectsOfCurrentKey.size()) { // we reached the end of the current position's list if (nextKeyIndex < Scheduler.this.keys.size()) { // there is another position after this one Integer currentKey = Scheduler.this.keys.get(nextKeyIndex++); objectsOfCurrentKey = Scheduler.this.objects.get(currentKey); objectsOfCurrentKeyIndex = 0; return true; } else { // there is no other position after this one return false; } } // there are still objects in the current position's list return true; } } public T next() { synchronized (Scheduler.this) { if (!hasNext()) throw new NoSuchElementException("iterator bounds reached"); return objectsOfCurrentKey.get(objectsOfCurrentKeyIndex++); } } } /** * This iterator supports in-flight updates of the iterated object. */ private final class SchedulerReverseOrderIterator implements Iterator { private int nextKeyIndex; private List objectsOfCurrentKey; private int objectsOfCurrentKeyIndex; private SchedulerReverseOrderIterator() { this.nextKeyIndex = Scheduler.this.keys.size() -1; } public void remove() { synchronized (Scheduler.this) { if (objectsOfCurrentKey == null) throw new NoSuchElementException("iterator not yet placed on an element"); objectsOfCurrentKeyIndex--; objectsOfCurrentKey.remove(objectsOfCurrentKeyIndex); if (objectsOfCurrentKey.size() == 0) { // there are no more objects in the current position's list -> remove it Integer key = Scheduler.this.keys.get(nextKeyIndex+1); Scheduler.this.keys.remove(nextKeyIndex+1); Scheduler.this.objects.remove(key); objectsOfCurrentKey = null; } Scheduler.this.size--; } } public boolean hasNext() { synchronized (Scheduler.this) { if (objectsOfCurrentKey == null || objectsOfCurrentKeyIndex >= objectsOfCurrentKey.size()) { // we reached the end of the current position's list if (nextKeyIndex >= 0) { // there is another position after this one Integer currentKey = Scheduler.this.keys.get(nextKeyIndex--); objectsOfCurrentKey = Scheduler.this.objects.get(currentKey); objectsOfCurrentKeyIndex = 0; return true; } else { // there is no other position after this one return false; } } // there are still objects in the current position's list return true; } } public T next() { synchronized (Scheduler.this) { if (!hasNext()) throw new NoSuchElementException("iterator bounds reached"); return objectsOfCurrentKey.get(objectsOfCurrentKeyIndex++); } } } } btm-dist-2.1.4/src/bitronix/tm/utils/Service.java0000644000175000017500000000210512147207062020454 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; /** * All internal services implement this interface. * * @see bitronix.tm.TransactionManagerServices * @author lorban */ public interface Service { /** * Shutdown the service and free all held resources. */ public void shutdown(); } btm-dist-2.1.4/src/bitronix/tm/utils/ExceptionUtils.java0000644000175000017500000000266612147207062022047 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import java.io.PrintWriter; import java.io.StringWriter; /** * Exception related utilities. * * @author Stephane Nicoll */ public final class ExceptionUtils { private ExceptionUtils() { } /** * Returns the stack trace of the specified {@link Throwable}. * * @param t the throwable * @return the string representation of the stack trace */ public static String getStackTrace(Throwable t) { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw, true); t.printStackTrace(pw); return sw.getBuffer().toString(); } } btm-dist-2.1.4/src/bitronix/tm/utils/UidGenerator.java0000644000175000017500000000547212147207062021456 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import bitronix.tm.BitronixXid; import bitronix.tm.TransactionManagerServices; import java.util.concurrent.atomic.AtomicInteger; /** * Helper that offers UID generation (GTRID, XID, sequences) needed by the transaction manager. *

Generated UIDs are at most 64 bytes long and are made of 3 subparts: the current time in milliseconds since * Epoch, a JVM transient atomic sequence number and the configured bitronix.tm.serverId.

*

The reliance on the system clock is critical to the uniqueness of the UID in the network so you have to make sure * all servers of the network running this transaction manager have their clock reasonably in sync. An order of 1 * second synchronicity is generally fine.

* * @author lorban */ public class UidGenerator { private final static AtomicInteger sequenceGenerator = new AtomicInteger(); /** * Generate a UID, globally unique. This method relies on the configured serverId for network uniqueness. * @return the generated UID. */ public static Uid generateUid() { byte[] timestamp = Encoder.longToBytes(MonotonicClock.currentTimeMillis()); byte[] sequence = Encoder.intToBytes(sequenceGenerator.incrementAndGet()); byte[] serverId = TransactionManagerServices.getConfiguration().buildServerIdArray(); int uidLength = serverId.length + timestamp.length + sequence.length; byte[] uidArray = new byte[uidLength]; System.arraycopy(serverId, 0, uidArray, 0, serverId.length); System.arraycopy(timestamp, 0, uidArray, serverId.length, timestamp.length); System.arraycopy(sequence, 0, uidArray, serverId.length + timestamp.length, sequence.length); return new Uid(uidArray); } /** * Generate a XID with the specified globalTransactionId. * @param gtrid the GTRID to use to generate the Xid. * @return the generated Xid. */ public static BitronixXid generateXid(Uid gtrid) { return new BitronixXid(gtrid, generateUid()); } } btm-dist-2.1.4/src/bitronix/tm/utils/MonotonicClock.java0000644000175000017500000000276212147207062022006 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2011, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import java.util.concurrent.atomic.AtomicLong; /** * A System.currentTimeMillis() replacement which guarantees monotonic time increment. * * @author lorban */ public class MonotonicClock { private static final AtomicLong lastTime = new AtomicLong(); /** * Return the current time in milliseconds, guaranteeing monotonic time increment. * @return the current time in milliseconds. */ public static long currentTimeMillis() { long now = System.nanoTime() / 1000000; long time = lastTime.get(); if (now > time) { lastTime.compareAndSet(time, now); return lastTime.get(); } return time; } } btm-dist-2.1.4/src/bitronix/tm/utils/Encoder.java0000644000175000017500000000551212147207062020440 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; /** * Number to byte array and byte array to number encoder. * * @author lorban */ public class Encoder { public static byte[] longToBytes(long aLong) { byte[] array = new byte[8]; array[7] = (byte) (aLong & 0xff); array[6] = (byte) ((aLong >> 8) & 0xff); array[5] = (byte) ((aLong >> 16) & 0xff); array[4] = (byte) ((aLong >> 24) & 0xff); array[3] = (byte) ((aLong >> 32) & 0xff); array[2] = (byte) ((aLong >> 40) & 0xff); array[1] = (byte) ((aLong >> 48) & 0xff); array[0] = (byte) ((aLong >> 56) & 0xff); return array; } public static byte[] intToBytes(int anInt) { byte[] array = new byte[4]; array[3] = (byte) (anInt & 0xff); array[2] = (byte) ((anInt >> 8) & 0xff); array[1] = (byte) ((anInt >> 16) & 0xff); array[0] = (byte) ((anInt >> 24) & 0xff); return array; } public static byte[] shortToBytes(short aShort) { byte[] array = new byte[2]; array[1] = (byte) (aShort & 0xff); array[0] = (byte) ((aShort >> 8) & 0xff); return array; } public static long bytesToLong(byte[] bytes, int pos) { if (bytes.length + pos < 8) throw new IllegalArgumentException("a long can only be decoded from 8 bytes of an array (got a " + bytes.length + " byte(s) array, must start at position " + pos + ")"); long result = 0; for(int i=0; i < 8 ;i++) { result <<= 8; result ^= (long) bytes[i + pos] & 0xFF; } return result; } public static int bytesToInt(byte[] bytes, int pos) { if (bytes.length + pos < 4) throw new IllegalArgumentException("an integer can only be decoded from 4 bytes of an array (got a " + bytes.length + " byte(s) array, must start at position " + pos + ")"); int result = 0; for(int i=0; i < 4 ;i++) { result <<= 8; result ^= (int) bytes[i + pos] & 0xFF; } return result; } } btm-dist-2.1.4/src/bitronix/tm/utils/Uid.java0000644000175000017500000000724312147207062017605 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import java.util.Arrays; /** *

A constant UID byte array container optimized for use with hashed collections.

* * @author lorban */ public final class Uid { private final byte[] array; private final int hashCodeValue; private final String toStringValue; public Uid(byte[] array) { this.array = new byte[array.length]; System.arraycopy(array, 0, this.array, 0, array.length); this.hashCodeValue = arrayHashCode(array); this.toStringValue = arrayToString(array); } public byte[] getArray() { return array; } public byte[] extractServerId() { int serverIdLength = array.length - 4 - 8; // - sequence - timestamp if (serverIdLength < 1) return null; byte[] result = new byte[serverIdLength]; System.arraycopy(array, 0, result, 0, serverIdLength); return result; } public long extractTimestamp() { return Encoder.bytesToLong(array, array.length - 4 - 8); // - sequence - timestamp } public int extractSequence() { return Encoder.bytesToInt(array, array.length - 4); // - sequence } public boolean equals(Object obj) { if (obj instanceof Uid) { Uid otherUid = (Uid) obj; // optimizes performance a bit if (hashCodeValue != otherUid.hashCodeValue) return false; return Arrays.equals(array, otherUid.array); } return false; } public int hashCode() { return hashCodeValue; } public String toString() { return toStringValue; } /** * Compute a UID byte array hashcode value. * @param uid the byte array used for hashcode computation. * @return a constant hash value for the specified uid. */ private static int arrayHashCode(byte[] uid) { int hash = 0; // Common fast but good hash with wide dispersion for (int i = uid.length - 1; i > 0; i--) { // rotate left and xor // (very fast in assembler, a bit clumsy in Java) hash <<= 1; if (hash < 0) { hash |= 1; } hash ^= uid[i]; } return hash; } /** * Decode a UID byte array into a (somewhat) human-readable hex string. * @param uid the uid to decode. * @return the resulting printable string. */ private static String arrayToString(byte[] uid) { char[] hexChars = new char[uid.length * 2]; int c = 0; int v; for (int i = 0; i < uid.length; i++) { v = uid[i] & 0xFF; hexChars[c++] = HEX[v >> 4]; hexChars[c++] = HEX[v & 0xF]; } return new String(hexChars); } private static final char[] HEX = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; } btm-dist-2.1.4/src/bitronix/tm/utils/PropertyUtils.java0000644000175000017500000004127712147207062021736 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.*; /** * Smart reflection helper. * * @author lorban */ public class PropertyUtils { /** * Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object. This method tries * to be smart in the way that intermediate properties currently set to null are set if it is possible to create * and set an object. Conversions from propertyValue to the proper destination type are performed when possible. * @param target the target object on which to set the property. * @param propertyName the name of the property to set. * @param propertyValue the value of the property to set. * @throws PropertyException if an error happened while trying to set the property. */ public static void setProperty(Object target, String propertyName, Object propertyValue) throws PropertyException { String[] propertyNames = propertyName.split("\\."); StringBuffer visitedPropertyName = new StringBuffer(); Object currentTarget = target; int i = 0; while (i < propertyNames.length -1) { String name = propertyNames[i]; Object result = callGetter(currentTarget, name); if (result == null) { // try to instanciate the object & set it in place Class propertyType = getPropertyType(target, name); try { result = propertyType.newInstance(); } catch (InstantiationException ex) { throw new PropertyException("cannot set property '" + propertyName + "' - '" + name + "' is null and cannot be auto-filled", ex); } catch (IllegalAccessException ex) { throw new PropertyException("cannot set property '" + propertyName + "' - '" + name + "' is null and cannot be auto-filled", ex); } callSetter(currentTarget, name, result); } currentTarget = result; visitedPropertyName.append(name); visitedPropertyName.append('.'); i++; // if it's a Properties object -> the non-visited part of the key should be used // as this Properties' object key so stop iterating over the dotted properties. if (currentTarget instanceof Properties) break; } String lastPropertyName = propertyName.substring(visitedPropertyName.length(), propertyName.length()); if (currentTarget instanceof Properties) { Properties p = (Properties) currentTarget; p.setProperty(lastPropertyName, propertyValue.toString()); } else { setDirectProperty(currentTarget, lastPropertyName, propertyValue); } } /** * Build a map of direct javabeans properties of the target object. Only read/write properties (ie: those who have * both a getter and a setter) are returned. * @param target the target object from which to get properties names. * @return a Map of String with properties names as key and their values * @throws PropertyException if an error happened while trying to get a property. */ public static Map getProperties(Object target) throws PropertyException { Map properties = new HashMap(); Class clazz = target.getClass(); Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; String name = method.getName(); if (method.getModifiers() == Modifier.PUBLIC && method.getParameterTypes().length == 0 && (name.startsWith("get") || name.startsWith("is")) && containsSetterForGetter(clazz, method)) { String propertyName; if (name.startsWith("get")) propertyName = Character.toLowerCase(name.charAt(3)) + name.substring(4); else if (name.startsWith("is")) propertyName = Character.toLowerCase(name.charAt(2)) + name.substring(3); else throw new PropertyException("method '" + name + "' is not a getter, thereof no setter can be found"); try { Object propertyValue = method.invoke(target, (Object[]) null); // casting to (Object[]) b/c of javac 1.5 warning if (propertyValue != null && propertyValue instanceof Properties) { Map propertiesContent = getNestedProperties(propertyName, (Properties) propertyValue); properties.putAll(propertiesContent); } else { properties.put(propertyName, propertyValue); } } catch (IllegalAccessException ex) { throw new PropertyException("cannot set property '" + propertyName + "' - '" + name + "' is null and cannot be auto-filled", ex); } catch (InvocationTargetException ex) { throw new PropertyException("cannot set property '" + propertyName + "' - '" + name + "' is null and cannot be auto-filled", ex); } } // if } // for return properties; } private static boolean containsSetterForGetter(Class clazz, Method method) { String methodName = method.getName(); String setterName; if (methodName.startsWith("get")) setterName = "set" + methodName.substring(3); else if (methodName.startsWith("is")) setterName = "set" + methodName.substring(2); else throw new PropertyException("method '" + methodName + "' is not a getter, thereof no setter can be found"); Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { Method method1 = methods[i]; if (method1.getName().equals(setterName)) return true; } return false; } /** * Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object. * @param target the target object from which to get the property. * @param propertyName the name of the property to get. * @return the value of the specified property. * @throws PropertyException if an error happened while trying to get the property. */ public static Object getProperty(Object target, String propertyName) throws PropertyException { String[] propertyNames = propertyName.split("\\."); Object currentTarget = target; for (int i = 0; i < propertyNames.length; i++) { String name = propertyNames[i]; Object result = callGetter(currentTarget, name); if (result == null && i < propertyNames.length -1) throw new PropertyException("cannot get property '" + propertyName + "' - '" + name + "' is null"); currentTarget = result; } return currentTarget; } /** * Set a {@link Map} of direct or indirect properties on the target object. * @param target the target object on which to set the properties. * @param properties a {@link Map} of String/Object pairs. * @throws PropertyException if an error happened while trying to set a property. */ public static void setProperties(Object target, Map properties) throws PropertyException { Iterator it = properties.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); setProperty(target, name, value); } } /** * Return a comma-separated String of r/w properties of the specified object. * @param obj the object to introspect. * @return a a comma-separated String of r/w properties. */ public static String propertiesToString(Object obj) { StringBuffer sb = new StringBuffer(); Map properties = new TreeMap(getProperties(obj)); Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String property = (String) it.next(); Object val = getProperty(obj, property); sb.append(property); sb.append("="); sb.append(val); if (it.hasNext()) sb.append(", "); } return sb.toString(); } /** * Set a direct property on the target object. Conversions from propertyValue to the proper destination type * are performed whenever possible. * @param target the target object on which to set the property. * @param propertyName the name of the property to set. * @param propertyValue the value of the property to set. * @throws PropertyException if an error happened while trying to set the property. */ private static void setDirectProperty(Object target, String propertyName, Object propertyValue) throws PropertyException { Method setter = getSetter(target, propertyName); Class parameterType = setter.getParameterTypes()[0]; try { if (propertyValue != null) { Object transformedPropertyValue = transform(propertyValue, parameterType); setter.invoke(target, new Object[] {transformedPropertyValue}); } else { setter.invoke(target, new Object[] {null}); } } catch (IllegalAccessException ex) { throw new PropertyException("property '" + propertyName + "' is not accessible", ex); } catch (InvocationTargetException ex) { throw new PropertyException("property '" + propertyName + "' access threw an exception", ex); } } private static Map getNestedProperties(String prefix, Properties properties) { Map result = new HashMap(); Iterator it = properties.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String name = (String) entry.getKey(); String value = (String) entry.getValue(); result.put(prefix + '.' + name, value); } return result; } private static Object transform(Object value, Class destinationClass) { if (value.getClass() == destinationClass) return value; if ( value.getClass() == boolean.class || value.getClass() == Boolean.class || value.getClass() == byte.class || value.getClass() == Byte.class || value.getClass() == short.class || value.getClass() == Short.class || value.getClass() == int.class || value.getClass() == Integer.class || value.getClass() == long.class || value.getClass() == Long.class || value.getClass() == float.class || value.getClass() == Float.class || value.getClass() == double.class || value.getClass() == Double.class ) return value; if ((destinationClass == boolean.class || destinationClass == Boolean.class) && value.getClass() == String.class) { return Boolean.valueOf((String) value); } if ((destinationClass == byte.class || destinationClass == Byte.class) && value.getClass() == String.class) { return new Byte((String) value); } if ((destinationClass == short.class || destinationClass == Short.class) && value.getClass() == String.class) { return new Short((String) value); } if ((destinationClass == int.class || destinationClass == Integer.class) && value.getClass() == String.class) { return new Integer((String) value); } if ((destinationClass == long.class || destinationClass == Long.class) && value.getClass() == String.class) { return new Long((String) value); } if ((destinationClass == float.class || destinationClass == Float.class) && value.getClass() == String.class) { return new Float((String) value); } if ((destinationClass == double.class || destinationClass == Double.class) && value.getClass() == String.class) { return new Double((String) value); } throw new PropertyException("cannot convert values of type '" + value.getClass().getName() + "' into type '" + destinationClass + "'"); } private static void callSetter(Object target, String propertyName, Object parameter) throws PropertyException { Method setter = getSetter(target, propertyName); try { setter.invoke(target, new Object[] {parameter}); } catch (IllegalAccessException ex) { throw new PropertyException("property '" + propertyName + "' is not accessible", ex); } catch (InvocationTargetException ex) { throw new PropertyException("property '" + propertyName + "' access threw an exception", ex); } } private static Object callGetter(Object target, String propertyName) throws PropertyException { Method getter = getGetter(target, propertyName); try { return getter.invoke(target, (Object[]) null); // casting to (Object[]) b/c of javac 1.5 warning } catch (IllegalAccessException ex) { throw new PropertyException("property '" + propertyName + "' is not accessible", ex); } catch (InvocationTargetException ex) { throw new PropertyException("property '" + propertyName + "' access threw an exception", ex); } } private static Method getSetter(Object target, String propertyName) { if (propertyName == null || "".equals(propertyName)) throw new PropertyException("encountered invalid null or empty property name"); String setterName = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); Method[] methods = target.getClass().getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (method.getName().equals(setterName) && method.getReturnType().equals(void.class) && method.getParameterTypes().length == 1) { return method; } } throw new PropertyException("no writeable property '" + propertyName + "' in class '" + target.getClass().getName() + "'"); } private static Method getGetter(Object target, String propertyName) { String getterName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); String getterIsName = "is" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); Method[] methods = target.getClass().getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if ((method.getName().equals(getterName) || method.getName().equals(getterIsName)) && !method.getReturnType().equals(void.class) && method.getParameterTypes().length == 0) { return method; } } throw new PropertyException("no readable property '" + propertyName + "' in class '" + target.getClass().getName() + "'"); } private static Class getPropertyType(Object target, String propertyName) { String getterName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); String getterIsName = "is" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); Method[] methods = target.getClass().getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if ((method.getName().equals(getterName) || method.getName().equals(getterIsName)) && !method.getReturnType().equals(void.class) && method.getParameterTypes().length == 0) { return method.getReturnType(); } } throw new PropertyException("no property '" + propertyName + "' in class '" + target.getClass().getName() + "'"); } } btm-dist-2.1.4/src/bitronix/tm/utils/Decoder.java0000644000175000017500000001407312147207062020430 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import bitronix.tm.journal.TransactionLogHeader; import bitronix.tm.resource.common.XAStatefulHolder; import bitronix.tm.internal.XAResourceHolderState; import javax.transaction.Status; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import java.util.Collection; import java.util.Iterator; /** * Constant to string decoder. * * @author lorban */ public class Decoder { public static String decodeXAExceptionErrorCode(XAException ex) { switch (ex.errorCode) { // rollback errors case XAException.XA_RBROLLBACK: return "XA_RBROLLBACK"; case XAException.XA_RBCOMMFAIL: return "XA_RBCOMMFAIL"; case XAException.XA_RBDEADLOCK: return "XA_RBDEADLOCK"; case XAException.XA_RBTRANSIENT: return "XA_RBTRANSIENT"; case XAException.XA_RBINTEGRITY: return "XA_RBINTEGRITY"; case XAException.XA_RBOTHER: return "XA_RBOTHER"; case XAException.XA_RBPROTO: return "XA_RBPROTO"; case XAException.XA_RBTIMEOUT: return "XA_RBTIMEOUT"; // heuristic errors case XAException.XA_HEURCOM: return "XA_HEURCOM"; case XAException.XA_HEURHAZ: return "XA_HEURHAZ"; case XAException.XA_HEURMIX: return "XA_HEURMIX"; case XAException.XA_HEURRB: return "XA_HEURRB"; // misc failures errors case XAException.XAER_RMERR: return "XAER_RMERR"; case XAException.XAER_RMFAIL: return "XAER_RMFAIL"; case XAException.XAER_NOTA: return "XAER_NOTA"; case XAException.XAER_INVAL: return "XAER_INVAL"; case XAException.XAER_PROTO: return "XAER_PROTO"; case XAException.XAER_ASYNC: return "XAER_ASYNC"; case XAException.XAER_DUPID: return "XAER_DUPID"; case XAException.XAER_OUTSIDE: return "XAER_OUTSIDE"; default: return "!invalid error code (" + ex.errorCode + ")!"; } } public static String decodeStatus(int status) { switch (status) { case Status.STATUS_ACTIVE: return "ACTIVE"; case Status.STATUS_COMMITTED: return "COMMITTED"; case Status.STATUS_COMMITTING: return "COMMITTING"; case Status.STATUS_MARKED_ROLLBACK: return "MARKED_ROLLBACK"; case Status.STATUS_NO_TRANSACTION: return "NO_TRANSACTION"; case Status.STATUS_PREPARED: return "PREPARED"; case Status.STATUS_PREPARING: return "PREPARING"; case Status.STATUS_ROLLEDBACK: return "ROLLEDBACK"; case Status.STATUS_ROLLING_BACK: return "ROLLING_BACK"; case Status.STATUS_UNKNOWN: return "UNKNOWN"; default: return "!incorrect status (" + status + ")!"; } } public static String decodeXAResourceFlag(int flag) { switch (flag) { case XAResource.TMENDRSCAN: return "ENDRSCAN"; case XAResource.TMFAIL: return "FAIL"; case XAResource.TMJOIN: return "JOIN"; case XAResource.TMNOFLAGS: return "NOFLAGS"; case XAResource.TMONEPHASE: return "ONEPHASE"; case XAResource.TMRESUME: return "RESUME"; case XAResource.TMSTARTRSCAN: return "STARTRSCAN"; case XAResource.TMSUCCESS: return "SUCCESS"; case XAResource.TMSUSPEND: return "SUSPEND"; default: return "!invalid flag (" + flag + ")!"; } } public static String decodePrepareVote(int vote) { switch (vote) { case XAResource.XA_OK: return "XA_OK"; case XAResource.XA_RDONLY: return "XA_RDONLY"; default: return "!invalid return code (" + vote + ")!"; } } public static String decodeHeaderState(byte state) { switch (state) { case TransactionLogHeader.CLEAN_LOG_STATE: return "CLEAN_LOG_STATE"; case TransactionLogHeader.UNCLEAN_LOG_STATE: return "UNCLEAN_LOG_STATE"; default: return "!invalid state (" + state + ")!"; } } public static String decodeXAStatefulHolderState(int state) { switch (state) { case XAStatefulHolder.STATE_CLOSED: return "CLOSED"; case XAStatefulHolder.STATE_IN_POOL: return "IN_POOL"; case XAStatefulHolder.STATE_ACCESSIBLE: return "ACCESSIBLE"; case XAStatefulHolder.STATE_NOT_ACCESSIBLE: return "NOT_ACCESSIBLE"; default: return "!invalid state (" + state + ")!"; } } /** * Create a String representation of a list of {@link bitronix.tm.resource.common.XAResourceHolder}s. This * String will contain each resource's unique name. * @param resources a list of {@link bitronix.tm.resource.common.XAResourceHolder}s. * @return a String representation of the list. */ public static String collectResourcesNames(Collection resources) { StringBuilder sb = new StringBuilder(); sb.append("["); Iterator it = resources.iterator(); while (it.hasNext()) { XAResourceHolderState resourceHolderState = it.next(); sb.append(resourceHolderState.getUniqueName()); if (it.hasNext()) sb.append(", "); } sb.append("]"); return sb.toString(); } } btm-dist-2.1.4/src/bitronix/tm/recovery/0000755000175000017500000000000012147207062016711 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/recovery/package.html0000644000175000017500000000011412147207062021166 0ustar tonytony

Recovery logic.

btm-dist-2.1.4/src/bitronix/tm/recovery/Recoverer.java0000644000175000017500000006027512147207062021522 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.recovery; import bitronix.tm.BitronixXid; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.ManagementRegistrar; import bitronix.tm.utils.Uid; import bitronix.tm.utils.Service; import bitronix.tm.internal.*; import bitronix.tm.journal.TransactionLogRecord; import bitronix.tm.resource.ResourceLoader; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.common.XAResourceProducer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.Status; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import java.io.IOException; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; /** * Recovery process implementation. Here is Mike Spille's description of XA recovery: *

* Straight Line Recovery: *

    *
  • 1. Find transactions that the TM considers dangling and unresolved
  • *
  • 2. Find and reconstitute any {@link XAResource}s which were being used when chunk blowing occured.
  • *
  • 3. Call the recover() method on each of these {@link XAResource}s.
  • *
  • 4. Throw out any {@link Xid}'s in the {@link XAResource}' recover lists which are not owned by this TM.
  • *
  • 5. Correlate {@link Xid}'s that the TM knows about with remaining {@link Xid}'s that the {@link XAResource}s * reported.
  • *
  • 6. For {@link XAResource} {@link Xid}'s that match the global transaction ID which the TM found dangling with * a "Committing..." record, call commit() on those {@link XAResource}s for those {@link Xid}s.
  • *
  • 7. For {@link XAResource} {@link Xid}'s that do not match any dangling "Committing..." records, call * rollback() on those {@link XAResource}s for those {@link Xid}s.
  • *
* Exceptional conditions: *
    *
  • 1. For any rollback() calls from step 6 which reported a Heuristic Commit, you are in danger or * doubt, so run in circles, scream and shout.
  • *
  • 2. For any commit() calls from step 7 which reported a Heuristic Rollback, you are in danger or * doubt, so run in circles, scream and shout.
  • *
  • 3. For any resource you can't reconstitute in in step #2, or who fails on recover in step #3, or who reports * anything like an XAER_RMFAILURE in step 6 or step 7, keep trying to contact them in some implementation * defined manner.
  • *
  • 4. For any heuristic outcome you see reported from an XAResource, call forget() for that * {@link XAResource}/{@link Xid} pair so that the resource can stop holding onto a reference to that transaction
  • *
*

*

To achieve this, {@link Recoverer} must have access to all previously used resources, even if the journal contains * no trace of some of them. There are two ways of achieving this: either you use the {@link ResourceLoader} to configure * all your resources and everything will be working automatically or by making sure resources are re-created and re-registered.

*

Those are the three steps of the Bitronix implementation: *

    *
  • call recover() on all known resources (Mike's steps 1 to 5)
  • *
  • commit dangling COMMITTING transactions (Mike's step 6)
  • *
  • rollback any remaining recovered transaction (Mike's step 7)
  • *

* * @author lorban */ public class Recoverer implements Runnable, Service, RecovererMBean { private final static Logger log = LoggerFactory.getLogger(Recoverer.class); private final Map registeredResources = new HashMap(); private final Map> recoveredXidSets = new HashMap>(); private volatile Exception completionException; private volatile int committedCount; private volatile int rolledbackCount; private volatile int executionsCount; private final AtomicBoolean isRunning = new AtomicBoolean(false); private final String jmxName; public Recoverer() { String serverId = TransactionManagerServices.getConfiguration().getServerId(); if (serverId == null) serverId = ""; this.jmxName = "bitronix.tm:type=Recoverer,ServerId=" + ManagementRegistrar.makeValidName(serverId); ManagementRegistrar.register(jmxName, this); } public void shutdown() { ManagementRegistrar.unregister(jmxName); } /** * Run the recovery process. This method is automatically called by the transaction manager, you should never * call it manually. */ public void run() { if (!isRunning.compareAndSet(false, true)) { log.info("recoverer is already running, abandoning this recovery request"); return; } try { committedCount = 0; rolledbackCount = 0; long oldestTransactionTimestamp = Long.MAX_VALUE; // Collect dangling records from journal, must run before oldestTransactionTimestamp is calculated Map danglingRecords = TransactionManagerServices.getJournal().collectDanglingRecords(); // Query resources from ResourceRegistrar synchronized (ResourceRegistrar.class) { for (String name : ResourceRegistrar.getResourcesUniqueNames()) { registeredResources.put(name, ResourceRegistrar.get(name)); } if (TransactionManagerServices.isTransactionManagerRunning()) { oldestTransactionTimestamp = TransactionManagerServices.getTransactionManager().getOldestInFlightTransactionTimestamp(); } } // 1. call recover on all known resources recoverAllResources(); // 2. commit dangling COMMITTING transactions Set committedGtrids = commitDanglingTransactions(oldestTransactionTimestamp, danglingRecords); committedCount = committedGtrids.size(); // 3. rollback any remaining recovered transaction rolledbackCount = rollbackAbortedTransactions(oldestTransactionTimestamp, committedGtrids); if (executionsCount == 0 || committedCount > 0 || rolledbackCount > 0) { log.info("recovery committed " + committedCount + " dangling transaction(s) and rolled back " + rolledbackCount + " aborted transaction(s) on " + registeredResources.size() + " resource(s) [" + getRegisteredResourcesUniqueNames() + "]" + ((TransactionManagerServices.getConfiguration().isCurrentNodeOnlyRecovery()) ? " (restricted to serverId '" + TransactionManagerServices.getConfiguration().getServerId() + "')" : "")); } else if (log.isDebugEnabled()) { log.debug("recovery committed " + committedCount + " dangling transaction(s) and rolled back " + rolledbackCount + " aborted transaction(s) on " + registeredResources.size() + " resource(s) [" + getRegisteredResourcesUniqueNames() + "]" + ((TransactionManagerServices.getConfiguration().isCurrentNodeOnlyRecovery()) ? " (restricted to serverId '" + TransactionManagerServices.getConfiguration().getServerId() + "')" : "")); } this.completionException = null; } catch (Exception ex) { this.completionException = ex; log.warn("recovery failed, registered resource(s): " + getRegisteredResourcesUniqueNames(), ex); } finally { recoveredXidSets.clear(); registeredResources.clear(); executionsCount++; isRunning.set(false); } } /** * Get the exception reported when recovery failed. * @return the exception that made recovery fail or null if last recovery execution was successful. */ public Exception getCompletionException() { return completionException; } /** * Get the amount of transactions committed during the last recovery run. * @return the amount of committed transactions. */ public int getCommittedCount() { return committedCount; } /** * Get the amount of transactions rolled back during the last recovery run. * @return the amount of rolled back transactions. */ public int getRolledbackCount() { return rolledbackCount; } /** * Get how many times the recoverer has run since the transaction manager started. * @return how many times the recoverer has run since the transaction manager started. */ public int getExecutionsCount() { return executionsCount; } /** * Check if the recoverer currently is running. * @return true if the recoverer currently is running, false otherwise. */ public boolean isRunning() { return isRunning.get(); } /** * Recover all configured resources and fill the recoveredXidSets with all recovered XIDs. * Step 1. */ private void recoverAllResources() { // a cloned registeredResources Map must be iterated as the original one can be modified in the loop for (Map.Entry entry : new HashMap(registeredResources).entrySet()) { String uniqueName = entry.getKey(); XAResourceProducer producer = entry.getValue(); try { if (log.isDebugEnabled()) log.debug("performing recovery on " + uniqueName); Set xids = recover(producer); if (log.isDebugEnabled()) log.debug("recovered " + xids.size() + " XID(s) from resource " + uniqueName); recoveredXidSets.put(uniqueName, xids); producer.setFailed(false); } catch (XAException ex) { producer.setFailed(true); registeredResources.remove(uniqueName); String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); log.warn("error running recovery on resource '" + uniqueName + "', resource marked as failed (background recoverer will retry recovery)" + " (error=" + Decoder.decodeXAExceptionErrorCode(ex) + ")" + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } catch (Exception ex) { producer.setFailed(true); registeredResources.remove(uniqueName); log.warn("error running recovery on resource '" + uniqueName + "', resource marked as failed (background recoverer will retry recovery)", ex); } } } /** * Run the recovery process on the target resource. * Step 1. * @return a Set of BitronixXids. * @param producer the {@link XAResourceProducer} to recover. * @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} call fails. * @throws RecoveryException if an error preventing recovery happened. */ private Set recover(XAResourceProducer producer) throws XAException, RecoveryException { if (producer == null) throw new IllegalArgumentException("recoverable resource cannot be null"); try { if (log.isDebugEnabled()) log.debug("running recovery on " + producer); XAResourceHolderState xaResourceHolderState = producer.startRecovery(); return RecoveryHelper.recover(xaResourceHolderState); } finally { producer.endRecovery(); } } /** * Commit transactions that have a dangling COMMITTING record in the journal. * Transactions younger than oldestTransactionTimestamp are ignored. * Step 2. * @param oldestTransactionTimestamp the timestamp of the oldest transaction still in-flight. * @param danglingRecords a Map using Uid objects GTRID as key and {@link TransactionLogRecord} as value. * @return a Set of all committed GTRIDs encoded as strings. * @throws java.io.IOException if there is an I/O error reading the journal. * @throws RecoveryException if an error preventing recovery happened. */ private Set commitDanglingTransactions(long oldestTransactionTimestamp, Map danglingRecords) throws IOException, RecoveryException { Set committedGtrids = new HashSet(); if (log.isDebugEnabled()) log.debug("found " + danglingRecords.size() + " dangling record(s) in journal"); for (Map.Entry entry : danglingRecords.entrySet()) { Uid gtrid = entry.getKey(); TransactionLogRecord tlog = entry.getValue(); Set uniqueNames = tlog.getUniqueNames(); Set danglingTransactions = getDanglingTransactionsInRecoveredXids(uniqueNames, tlog.getGtrid()); long txTimestamp = gtrid.extractTimestamp(); if (log.isDebugEnabled()) log.debug("recovered XID timestamp: " + txTimestamp + " - oldest in-flight TX timestamp: " + oldestTransactionTimestamp); if (txTimestamp < oldestTransactionTimestamp) { if (log.isDebugEnabled()) log.debug("committing dangling transaction with GTRID " + gtrid); commit(danglingTransactions); if (log.isDebugEnabled()) log.debug("committed dangling transaction with GTRID " + gtrid); committedGtrids.add(gtrid); Set participatingUniqueNames = filterParticipatingUniqueNamesInRecoveredXids(uniqueNames); if (participatingUniqueNames.size() > 0) { if (log.isDebugEnabled()) log.debug("updating journal's transaction with GTRID " + gtrid + " status to COMMITTED for names [" + buildUniqueNamesString(participatingUniqueNames) + "]"); TransactionManagerServices.getJournal().log(Status.STATUS_COMMITTED, tlog.getGtrid(), participatingUniqueNames); } else { if (log.isDebugEnabled()) log.debug("not updating journal's transaction with GTRID " + gtrid + " status to COMMITTED as no resource could be found (incremental recovery will need to clean this)"); committedGtrids.remove(gtrid); } } else { if (log.isDebugEnabled()) log.debug("skipping in-flight transaction with GTRID " + gtrid); } } if (log.isDebugEnabled()) log.debug("committed " + committedGtrids.size() + " dangling transaction(s)"); return committedGtrids; } /** * Return {@link DanglingTransaction}s with {@link Xid}s corresponding to the GTRID parameter found in resources * specified by their uniqueNames. * recoverAllResources must have been called before or else the returned list will always be empty. * Step 2. * @param uniqueNames a set of uniqueNames. * @param gtrid the GTRID to look for. * @return a set of {@link DanglingTransaction}s. */ private Set getDanglingTransactionsInRecoveredXids(Set uniqueNames, Uid gtrid) { Set danglingTransactions = new HashSet(); for (String uniqueName : uniqueNames) { if (log.isDebugEnabled()) log.debug("finding dangling transaction(s) in recovered XID(s) of resource " + uniqueName); Set recoveredXids = recoveredXidSets.get(uniqueName); if (recoveredXids == null) { if (log.isDebugEnabled()) log.debug("resource " + uniqueName + " did not recover, skipping commit"); continue; } for (BitronixXid recoveredXid : recoveredXids) { if (gtrid.equals(recoveredXid.getGlobalTransactionIdUid())) { if (log.isDebugEnabled()) log.debug("found a recovered XID matching dangling log's GTRID " + gtrid + " in resource " + uniqueName); danglingTransactions.add(new DanglingTransaction(uniqueName, recoveredXid)); } } } return danglingTransactions; } private Set filterParticipatingUniqueNamesInRecoveredXids(Set uniqueNames) { Set recoveredUniqueNames = new HashSet(); for (String uniqueName : uniqueNames) { if (log.isDebugEnabled()) log.debug("finding dangling transaction(s) in recovered XID(s) of resource " + uniqueName); Set recoveredXids = recoveredXidSets.get(uniqueName); if (recoveredXids == null) { if (log.isDebugEnabled()) log.debug("cannot find resource '" + uniqueName + "' present in the journal, leaving it for incremental recovery"); } else { recoveredUniqueNames.add(uniqueName); } } return recoveredUniqueNames; } /** * Commit all branches of a dangling transaction. * Step 2. * @param danglingTransactions a set of {@link DanglingTransaction}s to commit. * @throws RecoveryException if an error preventing recovery happened. */ private void commit(Set danglingTransactions) throws RecoveryException { if (log.isDebugEnabled()) log.debug(danglingTransactions.size() + " branch(es) to commit"); for (DanglingTransaction danglingTransaction : danglingTransactions) { Xid xid = danglingTransaction.getXid(); String uniqueName = danglingTransaction.getUniqueName(); if (log.isDebugEnabled()) log.debug("committing branch with XID " + xid + " on " + uniqueName); commit(uniqueName, xid); } } /** * Commit the specified branch of a dangling transaction. * Step 2. * @param uniqueName the unique name of the resource on which the commit should be done. * @param xid the {@link Xid} to commit. * @return true when commit was successful. * @throws RecoveryException if an error preventing recovery happened. */ private boolean commit(String uniqueName, Xid xid) throws RecoveryException { XAResourceProducer producer = registeredResources.get(uniqueName); try { XAResourceHolderState xaResourceHolderState = producer.startRecovery(); return RecoveryHelper.commit(xaResourceHolderState, xid); } finally { producer.endRecovery(); } } /** * Rollback branches whose {@link Xid} has been recovered on the resource but hasn't been committed. * Those are the 'aborted' transactions of the Presumed Abort protocol. * Step 3. * @param oldestTransactionTimestamp the timestamp of the oldest transaction still in-flight. * @param committedGtrids a set of {@link Uid}s already committed on this resource. * @return the rolled back branches count. * @throws RecoveryException if an error preventing recovery happened. */ private int rollbackAbortedTransactions(long oldestTransactionTimestamp, Set committedGtrids) throws RecoveryException { if (log.isDebugEnabled()) log.debug("rolling back aborted branch(es)"); int rollbackCount = 0; for (Map.Entry> entry : recoveredXidSets.entrySet()) { String uniqueName = entry.getKey(); Set recoveredXids = entry.getValue(); if (log.isDebugEnabled()) log.debug("checking " + recoveredXids.size() + " branch(es) on " + uniqueName + " for rollback"); int count = rollbackAbortedBranchesOfResource(oldestTransactionTimestamp, uniqueName, recoveredXids, committedGtrids); if (log.isDebugEnabled()) log.debug("checked " + recoveredXids.size() + " branch(es) on " + uniqueName + " for rollback"); rollbackCount += count; } if (log.isDebugEnabled()) log.debug("rolled back " + rollbackCount + " aborted branch(es)"); return rollbackCount; } /** * Rollback aborted branches of the resource specified by uniqueName. * Step 3. * @param oldestTransactionTimestamp the timestamp of the oldest transaction still in-flight. * @param uniqueName the unique name of the resource on which to rollback branches. * @param recoveredXids a set of {@link BitronixXid} recovered on the reource. * @param committedGtrids a set of {@link Uid}s already committed on the resource. * @return the rolled back branches count. * @throws RecoveryException if an error preventing recovery happened. */ private int rollbackAbortedBranchesOfResource(long oldestTransactionTimestamp, String uniqueName, Set recoveredXids, Set committedGtrids) throws RecoveryException { int abortedCount = 0; for (BitronixXid recoveredXid : recoveredXids) { if (committedGtrids.contains(recoveredXid.getGlobalTransactionIdUid())) { if (log.isDebugEnabled()) log.debug("XID has been committed, skipping rollback: " + recoveredXid + " on " + uniqueName); continue; } long txTimestamp = recoveredXid.getGlobalTransactionIdUid().extractTimestamp(); if (log.isDebugEnabled()) log.debug("recovered XID timestamp: " + txTimestamp + " - oldest in-flight TX timestamp: " + oldestTransactionTimestamp); if (txTimestamp >= oldestTransactionTimestamp) { if (log.isDebugEnabled()) log.debug("skipping XID of in-flight transaction: " + recoveredXid); continue; } if (log.isDebugEnabled()) log.debug("rolling back in-doubt branch with XID " + recoveredXid + " on " + uniqueName); boolean success = rollback(uniqueName, recoveredXid); if (success) abortedCount++; } return abortedCount; } /** * Rollback the specified branch of a dangling transaction. * Step 3. * @param uniqueName the unique name of the resource on which to rollback branches. * @param xid the {@link Xid} to rollback. * @return true when rollback was successful. * @throws RecoveryException if an error preventing recovery happened. */ private boolean rollback(String uniqueName, Xid xid) throws RecoveryException { XAResourceProducer producer = registeredResources.get(uniqueName); if (producer == null) { if (log.isDebugEnabled()) log.debug("resource " + uniqueName + " has not recovered, skipping rollback"); return false; } try { XAResourceHolderState xaResourceHolderState = producer.startRecovery(); return RecoveryHelper.rollback(xaResourceHolderState, xid); } finally { producer.endRecovery(); } } /** * Build a string with comma-separated resources unique names. * @return the string. */ private String getRegisteredResourcesUniqueNames() { return buildUniqueNamesString(registeredResources.keySet()); } private static String buildUniqueNamesString(Set uniqueNames) { StringBuilder resourcesUniqueNames = new StringBuilder(); Iterator it = uniqueNames.iterator(); while (it.hasNext()) { String uniqueName = it.next(); resourcesUniqueNames.append(uniqueName); if (it.hasNext()) resourcesUniqueNames.append(", "); } return resourcesUniqueNames.toString(); } } btm-dist-2.1.4/src/bitronix/tm/recovery/RecoveryHelper.java0000644000175000017500000003200212147207062022507 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.recovery; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.BitronixXid; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.Uid; import bitronix.tm.utils.Decoder; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import java.util.Collections; import java.util.Set; import java.util.HashSet; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Reovery helper methods. * * @author lorban */ public class RecoveryHelper { private final static Logger log = LoggerFactory.getLogger(RecoveryHelper.class); /** * Run the recovery process on the target resource. * @return a Set of BitronixXids. * @param xaResourceHolderState the {@link XAResourceHolderState} to recover. * @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} calls fail. */ public static Set recover(XAResourceHolderState xaResourceHolderState) throws XAException { Set xids = new HashSet(); if (log.isDebugEnabled()) log.debug("recovering with STARTRSCAN"); int xidCount; try { xidCount = recover(xaResourceHolderState, xids, XAResource.TMSTARTRSCAN); } catch (XAException ex) { if (xaResourceHolderState.getIgnoreRecoveryFailures()) { if (log.isDebugEnabled()) log.debug("ignoring recovery failure on resource " + xaResourceHolderState, ex); return Collections.emptySet(); } throw ex; } if (log.isDebugEnabled()) log.debug("STARTRSCAN recovered " + xidCount + " xid(s) on " + xaResourceHolderState); try { while (xidCount > 0) { if (log.isDebugEnabled()) log.debug("recovering with NOFLAGS"); xidCount = recover(xaResourceHolderState, xids, XAResource.TMNOFLAGS); if (log.isDebugEnabled()) log.debug("NOFLAGS recovered " + xidCount + " xid(s) on " + xaResourceHolderState); } } catch (XAException ex) { if (log.isDebugEnabled()) log.debug("NOFLAGS recovery call failed", ex); } try { if (log.isDebugEnabled()) log.debug("recovering with ENDRSCAN"); xidCount = recover(xaResourceHolderState, xids, XAResource.TMENDRSCAN); if (log.isDebugEnabled()) log.debug("ENDRSCAN recovered " + xidCount + " xid(s) on " + xaResourceHolderState); } catch (XAException ex) { if (log.isDebugEnabled()) log.debug("ENDRSCAN recovery call failed", ex); } return xids; } /** * Call {@link XAResource#recover(int)} on the resource and fill the alreadyRecoveredXids Set * with recovered {@link BitronixXid}s. * Step 1. * @return the amount of recovered {@link Xid}. * @param resourceHolderState the {@link XAResourceHolderState} to recover. * @param alreadyRecoveredXids a set of {@link Xid}s already recovered from this resource in this recovery session. * @param flags any combination of {@link XAResource#TMSTARTRSCAN}, {@link XAResource#TMNOFLAGS} or {@link XAResource#TMENDRSCAN}. * @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} call fails. */ private static int recover(XAResourceHolderState resourceHolderState, Set alreadyRecoveredXids, int flags) throws XAException { Xid[] xids = resourceHolderState.getXAResource().recover(flags); if (xids == null) return 0; boolean currentNodeOnly = TransactionManagerServices.getConfiguration().isCurrentNodeOnlyRecovery(); Set freshlyRecoveredXids = new HashSet(); for (Xid xid : xids) { if (xid.getFormatId() != BitronixXid.FORMAT_ID) { if (log.isDebugEnabled()) log.debug("skipping non-bitronix XID " + xid + "(format ID: " + xid.getFormatId() + " GTRID: " + new Uid(xid.getGlobalTransactionId()) + "BQUAL: " + new Uid(xid.getBranchQualifier()) + ")"); continue; } BitronixXid bitronixXid = new BitronixXid(xid); if (currentNodeOnly) { if (log.isDebugEnabled()) log.debug("recovering XIDs generated by this node only - recovered XIDs' GTRID must contain this JVM uniqueId"); byte[] extractedServerId = bitronixXid.getGlobalTransactionIdUid().extractServerId(); byte[] jvmUniqueId = TransactionManagerServices.getConfiguration().buildServerIdArray(); if (extractedServerId == null) { log.error("skipping XID " + bitronixXid + " as its GTRID's serverId is null. It looks like the disk journal is corrupted!"); continue; } if (!Arrays.equals(jvmUniqueId, extractedServerId)) { String extractedServerIdString = new String(extractedServerId); String jvmUniqueIdString = new String(jvmUniqueId); if (log.isDebugEnabled()) log.debug("skipping XID " + bitronixXid + " as its GTRID's serverId <" + extractedServerIdString + "> does not match this JVM unique ID <" + jvmUniqueIdString + ">"); continue; } } else { if (log.isDebugEnabled()) log.debug("recovering all XIDs regardless of this JVM uniqueId"); } if (alreadyRecoveredXids.contains(bitronixXid)) { if (log.isDebugEnabled()) log.debug("already recovered XID " + bitronixXid + ", skipping it"); continue; } if (freshlyRecoveredXids.contains(bitronixXid)) { log.warn("resource " + resourceHolderState.getUniqueName() + " recovered two identical XIDs within the same recover call: " + bitronixXid); continue; } if (log.isDebugEnabled()) log.debug("recovered " + bitronixXid); freshlyRecoveredXids.add(bitronixXid); } // for i < xids.length alreadyRecoveredXids.addAll(freshlyRecoveredXids); return freshlyRecoveredXids.size(); } /** * Commit the specified branch of a dangling transaction. * @param xaResourceHolderState the {@link XAResourceHolderState} to commit the branch on. * @param xid the {@link Xid} to commit. * @return true when commit was successful. */ public static boolean commit(XAResourceHolderState xaResourceHolderState, Xid xid) { String uniqueName = xaResourceHolderState.getUniqueName(); boolean success = true; boolean forget = false; try { xaResourceHolderState.getXAResource().commit(xid, false); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (ex.errorCode == XAException.XAER_NOTA) { log.error("unable to commit in-doubt branch on resource " + uniqueName + " - error=XAER_NOTA" + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Forgotten heuristic?", ex); } else if (ex.errorCode == XAException.XA_HEURCOM) { log.info("unable to commit in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Heuristic decision compatible with the global state of this transaction."); forget = true; } else if (ex.errorCode == XAException.XA_HEURHAZ || ex.errorCode == XAException.XA_HEURMIX || ex.errorCode == XAException.XA_HEURRB) { log.error("unable to commit in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Heuristic decision incompatible with the global state of this transaction!"); forget = true; success = false; } else { log.error("unable to commit in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ".", ex); success = false; } } if (forget) { try { if (log.isDebugEnabled()) log.debug("forgetting XID " + xid + " on resource " + uniqueName); xaResourceHolderState.getXAResource().forget(xid); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); log.error("unable to forget XID " + xid + " on resource " + uniqueName + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } return success; } /** * Rollback the specified branch of a dangling transaction. * @param xaResourceHolderState the {@link XAResourceHolderState} to rollback the branch on. * @param xid the {@link Xid} to rollback. * @return true when rollback was successful. */ public static boolean rollback(XAResourceHolderState xaResourceHolderState, Xid xid) { String uniqueName = xaResourceHolderState.getUniqueName(); boolean success = true; boolean forget = false; try { xaResourceHolderState.getXAResource().rollback(xid); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (ex.errorCode == XAException.XAER_NOTA) { log.error("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=XAER_NOTA" + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Forgotten heuristic?", ex); } else if (ex.errorCode == XAException.XA_HEURRB) { log.info("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Heuristic decision compatible with the global state of this transaction."); forget = true; } else if (ex.errorCode == XAException.XA_HEURHAZ || ex.errorCode == XAException.XA_HEURMIX || ex.errorCode == XAException.XA_HEURCOM) { log.error("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Heuristic decision incompatible with the global state of this transaction!"); forget = true; success = false; } else { log.error("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ".", ex); success = false; } } if (forget) { try { if (log.isDebugEnabled()) log.debug("forgetting XID " + xid + " on resource " + uniqueName); xaResourceHolderState.getXAResource().forget(xid); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); log.error("unable to forget XID " + xid + " on resource " + uniqueName + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } return success; } } btm-dist-2.1.4/src/bitronix/tm/recovery/DanglingTransaction.java0000644000175000017500000000373612147207062023516 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.recovery; import javax.transaction.xa.Xid; /** * Simple bean containing a unique resource name paired with a XID corresponding to a branch on that resource. * * @author lorban */ public final class DanglingTransaction { private final String uniqueName; private final Xid xid; public DanglingTransaction(String uniqueName, Xid xid) { if (uniqueName == null) throw new NullPointerException("uniqueName cannot be null"); if (xid == null) throw new NullPointerException("xid cannot be null"); this.uniqueName = uniqueName; this.xid = xid; } public String getUniqueName() { return uniqueName; } public Xid getXid() { return xid; } public int hashCode() { return uniqueName.hashCode() + xid.hashCode(); } public boolean equals(Object obj) { if (obj instanceof DanglingTransaction) { DanglingTransaction otherDanglingTransaction = (DanglingTransaction) obj; return uniqueName.equals(otherDanglingTransaction.uniqueName) && xid.equals(otherDanglingTransaction.xid); } return false; } } btm-dist-2.1.4/src/bitronix/tm/recovery/RecovererMBean.java0000644000175000017500000000221412147207062022412 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.recovery; /** * {@link Recoverer} Management interface. * * @author lorban */ public interface RecovererMBean { public void run(); public int getCommittedCount(); public int getRolledbackCount(); public Exception getCompletionException(); public int getExecutionsCount(); public boolean isRunning(); } btm-dist-2.1.4/src/bitronix/tm/recovery/IncrementalRecoverer.java0000644000175000017500000001306312147207062023675 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.recovery; import bitronix.tm.resource.common.XAResourceProducer; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.BitronixXid; import bitronix.tm.TransactionManagerServices; import bitronix.tm.journal.TransactionLogRecord; import bitronix.tm.utils.Uid; import bitronix.tm.utils.Decoder; import java.util.Set; import java.util.Map; import java.util.HashSet; import java.io.IOException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.Status; import javax.transaction.xa.XAException; /** * Incremental resource recoverer. * * @author lorban */ public class IncrementalRecoverer { private final static Logger log = LoggerFactory.getLogger(IncrementalRecoverer.class); /** * Run incremental recovery on the specified resource. * @param xaResourceProducer the resource to recover. * @throws RecoveryException when an error preventing recovery happens. */ public static void recover(XAResourceProducer xaResourceProducer) throws RecoveryException { String uniqueName = xaResourceProducer.getUniqueName(); if (log.isDebugEnabled()) log.debug("start of incremental recovery on resource " + uniqueName); try { XAResourceHolderState xaResourceHolderState = xaResourceProducer.startRecovery(); boolean success = true; Set xids = RecoveryHelper.recover(xaResourceHolderState); if (log.isDebugEnabled()) log.debug(xids.size() + " dangling transaction(s) found on resource"); Map danglingRecords = TransactionManagerServices.getJournal().collectDanglingRecords(); if (log.isDebugEnabled()) log.debug(danglingRecords.size() + " dangling transaction(s) found in journal"); int commitCount = 0; int rollbackCount = 0; for (BitronixXid xid : xids) { Uid gtrid = xid.getGlobalTransactionIdUid(); TransactionLogRecord tlog = (TransactionLogRecord) danglingRecords.get(gtrid); if (tlog != null) { if (log.isDebugEnabled()) log.debug("committing " + xid); success &= RecoveryHelper.commit(xaResourceHolderState, xid); updateJournal(xid.getGlobalTransactionIdUid(), uniqueName, Status.STATUS_COMMITTED); commitCount++; } else { if (log.isDebugEnabled()) log.debug("rolling back " + xid); success &= RecoveryHelper.rollback(xaResourceHolderState, xid); updateJournal(xid.getGlobalTransactionIdUid(), uniqueName, Status.STATUS_ROLLEDBACK); rollbackCount++; } } // if recovery isn't successful we don't mark the resource as failed: heuristics might have happened // but communication with the resouce is working. if (!success) throw new RecoveryException("error recovering resource '" + uniqueName + "' due to an incompatible heuristic decision"); xaResourceProducer.setFailed(false); log.info("incremental recovery committed " + commitCount + " dangling transaction(s) and rolled back " + rollbackCount + " aborted transaction(s) on resource [" + uniqueName + "]" + ((TransactionManagerServices.getConfiguration().isCurrentNodeOnlyRecovery()) ? " (restricted to serverId '" + TransactionManagerServices.getConfiguration().getServerId() + "')" : "")); } catch (XAException ex) { xaResourceProducer.setFailed(true); throw new RecoveryException("failed recovering resource " + uniqueName, ex); } catch (IOException ex) { xaResourceProducer.setFailed(true); throw new RecoveryException("failed recovering resource " + uniqueName, ex); } catch (RuntimeException ex) { xaResourceProducer.setFailed(true); throw new RecoveryException("failed recovering resource " + uniqueName, ex); } catch (RecoveryException ex) { xaResourceProducer.setFailed(true); throw ex; } finally { xaResourceProducer.endRecovery(); if (log.isDebugEnabled()) log.debug("end of incremental recovery on resource " + uniqueName); } } private static void updateJournal(Uid gtrid, String uniqueName, int status) throws IOException { if (log.isDebugEnabled()) log.debug("updating journal, adding " + Decoder.decodeStatus(status) + " entry for [" + uniqueName + "] on GTRID [" + gtrid + "]"); Set participatingUniqueNames = new HashSet(); participatingUniqueNames.add(uniqueName); TransactionManagerServices.getJournal().log(status, gtrid, participatingUniqueNames); } } btm-dist-2.1.4/src/bitronix/tm/recovery/RecoveryException.java0000644000175000017500000000217212147207062023233 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.recovery; /** * Thrown when an error occurs during recovery. * * @author lorban */ public class RecoveryException extends Exception { public RecoveryException(String message, Throwable cause) { super(message, cause); } public RecoveryException(String message) { super(message); } } btm-dist-2.1.4/src/bitronix/tm/BitronixTransactionManagerObjectFactory.java0000644000175000017500000000353012147207062025675 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.naming.Name; import javax.naming.Context; import javax.naming.spi.ObjectFactory; import java.util.Hashtable; /** * {@link BitronixTransactionManager} object factory for JNDI references. * * @author lorban */ public class BitronixTransactionManagerObjectFactory implements ObjectFactory { private final static Logger log = LoggerFactory.getLogger(BitronixTransactionManagerObjectFactory.class); /** * Since there can be only one transaction manager per VM instance, this method always returns a reference * to the unique BitronixTransactionManager object. * @see BitronixTransactionManager * @return the unique transaction manager instance. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { if (log.isDebugEnabled()) log.debug("returning the unique transaction manager instance"); return TransactionManagerServices.getTransactionManager(); } } btm-dist-2.1.4/src/bitronix/tm/BitronixTransaction.java0000644000175000017500000007153212147207062021732 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.internal.BitronixMultiSystemException; import bitronix.tm.internal.BitronixRollbackException; import bitronix.tm.internal.BitronixRollbackSystemException; import bitronix.tm.internal.BitronixSystemException; import bitronix.tm.internal.BitronixXAException; import bitronix.tm.internal.TransactionStatusChangeListener; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.internal.XAResourceManager; import bitronix.tm.journal.Journal; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.timer.TaskScheduler; import bitronix.tm.twopc.Committer; import bitronix.tm.twopc.PhaseException; import bitronix.tm.twopc.Preparer; import bitronix.tm.twopc.Rollbacker; import bitronix.tm.twopc.executor.Executor; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.ExceptionUtils; import bitronix.tm.utils.ManagementRegistrar; import bitronix.tm.utils.MonotonicClock; import bitronix.tm.utils.Scheduler; import bitronix.tm.utils.StackTrace; import bitronix.tm.utils.Uid; import bitronix.tm.utils.UidGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.HeuristicCommitException; import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicRollbackException; import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.Synchronization; import javax.transaction.SystemException; import javax.transaction.Transaction; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; /** * Implementation of {@link Transaction}. * * @author lorban */ public class BitronixTransaction implements Transaction, BitronixTransactionMBean { private final static Logger log = LoggerFactory.getLogger(BitronixTransaction.class); private final XAResourceManager resourceManager; private final Scheduler synchronizationScheduler = new Scheduler(); private final List transactionStatusListeners = new ArrayList(); private volatile int status = Status.STATUS_NO_TRANSACTION; private volatile boolean timeout = false; private volatile Date timeoutDate; private final Executor executor = TransactionManagerServices.getExecutor(); private final TaskScheduler taskScheduler = TransactionManagerServices.getTaskScheduler(); private final Journal journal = TransactionManagerServices.getJournal(); private final Preparer preparer = new Preparer(executor); private final Committer committer = new Committer(executor); private final Rollbacker rollbacker = new Rollbacker(executor); /* management */ private volatile String threadName; private volatile Date startDate; private volatile StackTrace activationStackTrace; public BitronixTransaction() { Uid gtrid = UidGenerator.generateUid(); if (log.isDebugEnabled()) log.debug("creating new transaction with GTRID [" + gtrid + "]"); this.resourceManager = new XAResourceManager(gtrid); this.threadName = Thread.currentThread().getName(); } public int getStatus() throws SystemException { return status; } public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (status == Status.STATUS_MARKED_ROLLBACK) throw new BitronixRollbackException("transaction has been marked as rollback only"); if (isDone()) throw new IllegalStateException("transaction started or finished 2PC, cannot enlist any more resource"); XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource); if (resourceHolder == null) throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource"); XAResourceHolderState resourceHolderState = new XAResourceHolderState(resourceHolder, resourceHolder.getResourceBean()); // resource timeout must be set here so manually enlisted resources can receive it resourceHolderState.setTransactionTimeoutDate(timeoutDate); try { resourceManager.enlist(resourceHolderState); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (BitronixXAException.isUnilateralRollback(ex)) { // if the resource unilaterally rolled back, the transaction will never be able to commit -> mark it as rollback only setStatus(Status.STATUS_MARKED_ROLLBACK); throw new BitronixRollbackException("resource " + resourceHolderState + " unilaterally rolled back, error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } throw new BitronixSystemException("cannot enlist " + resourceHolderState + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } resourceHolder.putXAResourceHolderState(resourceHolderState.getXid(), resourceHolderState); return true; } public boolean delistResource(XAResource xaResource, int flag) throws IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (flag != XAResource.TMSUCCESS && flag != XAResource.TMSUSPEND && flag != XAResource.TMFAIL) throw new BitronixSystemException("can only delist with SUCCESS, SUSPEND, FAIL - was: " + Decoder.decodeXAResourceFlag(flag)); if (isWorking()) throw new IllegalStateException("transaction is being committed or rolled back, cannot delist any resource now"); XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource); if (resourceHolder == null) throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource"); Map statesForGtrid = resourceHolder.getXAResourceHolderStatesForGtrid(resourceManager.getGtrid()); boolean result = true; List exceptions = new ArrayList(); List resourceStates = new ArrayList(); for (XAResourceHolderState resourceHolderState : statesForGtrid.values()) { try { result &= delistResource(resourceHolderState, flag); } catch (BitronixSystemException ex) { if (log.isDebugEnabled()) log.debug("failed to delist resource state " + resourceHolderState); exceptions.add(ex); resourceStates.add(resourceHolderState); } } if (!exceptions.isEmpty()) { BitronixMultiSystemException multiSystemException = new BitronixMultiSystemException("error delisting resource", exceptions, resourceStates); if (!multiSystemException.isUnilateralRollback()) throw multiSystemException; else if (log.isDebugEnabled()) log.debug("unilateral rollback of resource " + resourceHolder, multiSystemException); } return result; } private boolean delistResource(XAResourceHolderState resourceHolderState, int flag) throws BitronixSystemException { try { return resourceManager.delist(resourceHolderState, flag); } catch (XAException ex) { // if the resource could not be delisted, the transaction must not commit -> mark it as rollback only if (status != Status.STATUS_MARKED_ROLLBACK) setStatus(Status.STATUS_MARKED_ROLLBACK); String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (BitronixXAException.isUnilateralRollback(ex)) { // The resource unilaterally rolled back here. We have to throw an exception to indicate this but // The signature of this method is inherited from javax.transaction.Transaction. Thereof, we have choice // between creating a sub-exception of SystemException or using a RuntimeException. Is that the best way // forward as this 'hidden' exception can be left throw out at unexpected locations where SystemException // should be rethrown but the exception thrown here should be catched & handled... ? throw new BitronixRollbackSystemException("resource " + resourceHolderState + " unilaterally rolled back, error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } throw new BitronixSystemException("cannot delist " + resourceHolderState + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } public void registerSynchronization(Synchronization synchronization) throws RollbackException, IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (status == Status.STATUS_MARKED_ROLLBACK) throw new BitronixRollbackException("transaction has been marked as rollback only"); if (isDone()) throw new IllegalStateException("transaction is done, cannot register any more synchronization"); if (log.isDebugEnabled()) log.debug("registering synchronization " + synchronization); synchronizationScheduler.add(synchronization, Scheduler.DEFAULT_POSITION); } public Scheduler getSynchronizationScheduler() { return synchronizationScheduler; } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (isDone()) throw new IllegalStateException("transaction is done, cannot commit it"); taskScheduler.cancelTransactionTimeout(this); // beforeCompletion must be called before the check to STATUS_MARKED_ROLLBACK as the synchronization // can still set the status to STATUS_MARKED_ROLLBACK. try { fireBeforeCompletionEvent(); } catch (BitronixSystemException ex) { rollback(); throw new BitronixRollbackException("SystemException thrown during beforeCompletion cycle caused transaction rollback", ex); } catch (RuntimeException ex) { rollback(); throw new BitronixRollbackException("RuntimeException thrown during beforeCompletion cycle caused transaction rollback", ex); } // The following if statements and try/catch block must not be included in the prepare try-catch block as // they call rollback(). // Doing so would call fireAfterCompletionEvent() twice in case one of those conditions are true. if (timedOut()) { if (log.isDebugEnabled()) log.debug("transaction timed out"); rollback(); throw new BitronixRollbackException("transaction timed out and has been rolled back"); } try { delistUnclosedResources(XAResource.TMSUCCESS); } catch (BitronixRollbackException ex) { if (log.isDebugEnabled()) log.debug("delistment error causing transaction rollback", ex); rollback(); // the caught BitronixRollbackException's message is pre-formatted to be appended to this message throw new BitronixRollbackException("delistment error caused transaction rollback" + ex.getMessage()); } if (status == Status.STATUS_MARKED_ROLLBACK) { if (log.isDebugEnabled()) log.debug("transaction marked as rollback only"); rollback(); throw new BitronixRollbackException("transaction was marked as rollback only and has been rolled back"); } try { List interestedResources; // prepare phase try { if (log.isDebugEnabled()) log.debug("committing, " + resourceManager.size() + " enlisted resource(s)"); interestedResources = preparer.prepare(this); } catch (RollbackException ex) { if (log.isDebugEnabled()) log.debug("caught rollback exception during prepare, trying to rollback"); // rollbackPrepareFailure might throw a SystemException that will 'swallow' the RollbackException which is // what we want in that case as the transaction has not been rolled back and some resources are now left in-doubt. rollbackPrepareFailure(ex); throw new BitronixRollbackException("transaction failed to prepare: " + this, ex); } // commit phase if (log.isDebugEnabled()) log.debug(interestedResources.size() + " interested resource(s)"); committer.commit(this, interestedResources); if (resourceManager.size() == 0 && TransactionManagerServices.getConfiguration().isDebugZeroResourceTransaction()) { log.warn(buildZeroTransactionDebugMessage(activationStackTrace, new StackTrace())); } if (log.isDebugEnabled()) log.debug("successfully committed " + this); } finally { fireAfterCompletionEvent(); } } public void rollback() throws IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (isDone()) throw new IllegalStateException("transaction is done, cannot roll it back"); taskScheduler.cancelTransactionTimeout(this); try { delistUnclosedResources(XAResource.TMSUCCESS); } catch (BitronixRollbackException ex) { if (log.isDebugEnabled()) log.debug("some resource(s) failed delistment", ex); } try { try { if (log.isDebugEnabled()) log.debug("rolling back, " + resourceManager.size() + " enlisted resource(s)"); List resourcesToRollback = new ArrayList(); List allResources = resourceManager.getAllResources(); for (XAResourceHolderState resource : allResources) { if (!resource.isFailed()) resourcesToRollback.add(resource); } rollbacker.rollback(this, resourcesToRollback); if (log.isDebugEnabled()) log.debug("successfully rolled back " + this); } catch (HeuristicMixedException ex) { throw new BitronixSystemException("transaction partly committed and partly rolled back. Resources are now inconsistent !", ex); } catch (HeuristicCommitException ex) { throw new BitronixSystemException("transaction committed instead of rolled back. Resources are now inconsistent !", ex); } } finally { fireAfterCompletionEvent(); } } public void setRollbackOnly() throws IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (isDone()) throw new IllegalStateException("transaction is done, cannot change its status"); setStatus(Status.STATUS_MARKED_ROLLBACK); } public XAResourceManager getResourceManager() { return resourceManager; } public void timeout() throws BitronixSystemException { this.timeout = true; setStatus(Status.STATUS_MARKED_ROLLBACK); log.warn("transaction timed out: " + this); } public boolean timedOut() { return timeout; } public void setActive(int timeout) throws IllegalStateException, SystemException { if (status != Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction has already started"); setStatus(Status.STATUS_ACTIVE); this.startDate = new Date(MonotonicClock.currentTimeMillis()); this.timeoutDate = new Date(MonotonicClock.currentTimeMillis() + (timeout * 1000L)); if (TransactionManagerServices.getConfiguration().isDebugZeroResourceTransaction()) { this.activationStackTrace = new StackTrace(); } taskScheduler.scheduleTransactionTimeout(this, timeoutDate); } public void setStatus(int status) throws BitronixSystemException { setStatus(status, resourceManager.collectUniqueNames()); } public void setStatus(int status, Set uniqueNames) throws BitronixSystemException { try { boolean force = (resourceManager.size() > 1) && (status == Status.STATUS_COMMITTING); if (log.isDebugEnabled()) log.debug("changing transaction status to " + Decoder.decodeStatus(status) + (force ? " (forced)" : "")); int oldStatus = this.status; this.status = status; journal.log(status, resourceManager.getGtrid(), uniqueNames); if (force) { journal.force(); } if (status == Status.STATUS_ACTIVE) ManagementRegistrar.register("bitronix.tm:type=Transaction,Gtrid=" + resourceManager.getGtrid(), this); fireTransactionStatusChangedEvent(oldStatus, status); } catch (IOException ex) { // if we cannot log, the TM must stop managing TX until the problem is fixed throw new BitronixSystemException("error logging status", ex); } } private void fireTransactionStatusChangedEvent(int oldStatus, int newStatus) { if (log.isDebugEnabled()) log.debug("transaction status is changing from " + Decoder.decodeStatus(oldStatus) + " to " + Decoder.decodeStatus(newStatus) + " - executing " + transactionStatusListeners.size() + " listener(s)"); for (TransactionStatusChangeListener listener : transactionStatusListeners) { if (log.isDebugEnabled()) log.debug("executing TransactionStatusChangeListener " + listener); listener.statusChanged(oldStatus, newStatus); if (log.isDebugEnabled()) log.debug("executed TransactionStatusChangeListener " + listener); } } public void addTransactionStatusChangeListener(TransactionStatusChangeListener listener) { transactionStatusListeners.add(listener); } public int hashCode() { return resourceManager.getGtrid().hashCode(); } public boolean equals(Object obj) { if (obj instanceof BitronixTransaction) { BitronixTransaction tx = (BitronixTransaction) obj; return resourceManager.getGtrid().equals(tx.resourceManager.getGtrid()); } return false; } public String toString() { return "a Bitronix Transaction with GTRID [" + resourceManager.getGtrid() + "], status=" + Decoder.decodeStatus(status) + ", " + resourceManager.size() + " resource(s) enlisted (started " + startDate + ")"; } /* * Internal impl */ /** * Delist all resources that have not been closed before calling tm.commit(). This basically means calling * XAResource.end() on all resource that has not been ended yet. * @param flag the flag to pass to XAResource.end(). Either TMSUCCESS or TMFAIL. * @throws bitronix.tm.internal.BitronixRollbackException if some resources unilaterally rolled back before end() call. */ private void delistUnclosedResources(int flag) throws BitronixRollbackException { List allResources = resourceManager.getAllResources(); List rolledBackResources = new ArrayList(); List failedResources = new ArrayList(); for (XAResourceHolderState resource : allResources) { if (!resource.isEnded()) { if (log.isDebugEnabled()) log.debug("found unclosed resource to delist: " + resource); try { delistResource(resource, flag); } catch (BitronixRollbackSystemException ex) { rolledBackResources.add(resource); if (log.isDebugEnabled()) log.debug("resource unilaterally rolled back: " + resource, ex); } catch (SystemException ex) { failedResources.add(resource); log.warn("error delisting resource, assuming unilateral rollback: " + resource, ex); } } else if (log.isDebugEnabled()) log.debug("no need to delist already closed resource: " + resource); } // for if (!rolledBackResources.isEmpty() || !failedResources.isEmpty()) { String lineSeparator = System.getProperty("line.separator"); StringBuilder sb = new StringBuilder(); if (!rolledBackResources.isEmpty()) { sb.append(lineSeparator); sb.append(" resource(s) "); sb.append(Decoder.collectResourcesNames(rolledBackResources)); sb.append(" unilaterally rolled back"); } if (!failedResources.isEmpty()) { sb.append(lineSeparator); sb.append(" resource(s) "); sb.append(Decoder.collectResourcesNames(failedResources)); sb.append(" could not be delisted"); } throw new BitronixRollbackException(sb.toString()); } } /** * Rollback resources after a phase 1 prepare failure. All resources must be rolled back as prepared ones * are in-doubt and non-prepared ones have started/ended work done that must also be cleaned. * @param rbEx the thrown rollback exception. * @throws BitronixSystemException when a resource could not rollback prepapared state. */ private void rollbackPrepareFailure(RollbackException rbEx) throws BitronixSystemException { List interestedResources = resourceManager.getAllResources(); try { rollbacker.rollback(this, interestedResources); if (log.isDebugEnabled()) log.debug("rollback after prepare failure succeeded"); } catch (Exception ex) { // let's merge both exceptions' PhaseException to report a complete error message PhaseException preparePhaseEx = (PhaseException) rbEx.getCause(); PhaseException rollbackPhaseEx = (PhaseException) ex.getCause(); List exceptions = new ArrayList(); List resources = new ArrayList(); exceptions.addAll(preparePhaseEx.getExceptions()); exceptions.addAll(rollbackPhaseEx.getExceptions()); resources.addAll(preparePhaseEx.getResourceStates()); resources.addAll(rollbackPhaseEx.getResourceStates()); throw new BitronixSystemException("transaction partially prepared and only partially rolled back. Some resources might be left in doubt!", new PhaseException(exceptions, resources)); } } /** * Run all registered Synchronizations' beforeCompletion() method. Be aware that this method can change the * transaction status to mark it as rollback only for instance. * @throws bitronix.tm.internal.BitronixSystemException if status changing due to a synchronization throwing an * exception fails. */ private void fireBeforeCompletionEvent() throws BitronixSystemException { if (log.isDebugEnabled()) log.debug("before completion, " + synchronizationScheduler.size() + " synchronization(s) to execute"); Iterator it = synchronizationScheduler.reverseIterator(); while (it.hasNext()) { Synchronization synchronization = (Synchronization) it.next(); try { if (log.isDebugEnabled()) log.debug("executing synchronization " + synchronization); synchronization.beforeCompletion(); } catch (RuntimeException ex) { if (log.isDebugEnabled()) log.debug("Synchronization.beforeCompletion() call failed for " + synchronization + ", marking transaction as rollback only - " + ex); setStatus(Status.STATUS_MARKED_ROLLBACK); throw ex; } } } private void fireAfterCompletionEvent() { // this TX is no longer in-flight -> remove this transaction's state from all XAResourceHolders getResourceManager().clearXAResourceHolderStates(); if (log.isDebugEnabled()) log.debug("after completion, " + synchronizationScheduler.size() + " synchronization(s) to execute"); for (Synchronization synchronization : synchronizationScheduler) { try { if (log.isDebugEnabled()) log.debug("executing synchronization " + synchronization + " with status=" + Decoder.decodeStatus(status)); synchronization.afterCompletion(status); } catch (Exception ex) { log.warn("Synchronization.afterCompletion() call failed for " + synchronization, ex); } } ManagementRegistrar.unregister("bitronix.tm:type=Transaction,Gtrid=" + resourceManager.getGtrid()); } static String buildZeroTransactionDebugMessage(StackTrace activationStackTrace, StackTrace commitStackTrace) { String lineSeparator = System.getProperty("line.separator"); final StringBuilder sb = new StringBuilder(); sb.append("committed transaction with 0 enlisted resource").append(lineSeparator); sb.append("==================== Began at ====================").append(lineSeparator); sb.append(ExceptionUtils.getStackTrace(activationStackTrace)).append(lineSeparator); sb.append("==================== Committed at ====================").append(lineSeparator); sb.append(ExceptionUtils.getStackTrace(commitStackTrace)).append(lineSeparator); return sb.toString(); } private boolean isDone() { switch (status) { case Status.STATUS_PREPARING: case Status.STATUS_PREPARED: case Status.STATUS_COMMITTING: case Status.STATUS_COMMITTED: case Status.STATUS_ROLLING_BACK: case Status.STATUS_ROLLEDBACK: return true; } return false; } private boolean isWorking() { switch (status) { case Status.STATUS_PREPARING: case Status.STATUS_PREPARED: case Status.STATUS_COMMITTING: case Status.STATUS_ROLLING_BACK: return true; } return false; } /* management */ public String getGtrid() { return resourceManager.getGtrid().toString(); } public String getStatusDescription() { return Decoder.decodeStatus(status); } public Collection getEnlistedResourcesUniqueNames() { return resourceManager.collectUniqueNames(); } public String getThreadName() { return threadName; } public Date getStartDate() { return startDate; } /** * Returns the activation {@link StackTrace} if it is available. * * @return the call stack of where the transaction began */ StackTrace getActivationStackTrace() { return activationStackTrace; } } btm-dist-2.1.4/src/bitronix/tm/jndi/0000755000175000017500000000000012147207062015777 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/jndi/package.html0000644000175000017500000000022312147207062020255 0ustar tonytony

JNDI provider implementation that allows looking up transaction manager and resources.

btm-dist-2.1.4/src/bitronix/tm/jndi/BitronixInitialContextFactory.java0000644000175000017500000000433412147207062024653 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.jndi; import javax.naming.spi.InitialContextFactory; import javax.naming.Context; import javax.naming.NamingException; import java.util.Hashtable; /** * Implementation of {@link InitialContextFactory} that allows lookup of transaction manager * and registered resources. *

* The easiest way to use this provider is to create a jndi.properties file * in your classpath with this content: *

java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
* Alternatively, you can create a {@link javax.naming.InitialContext} object with an environment * pointing to this class: *
 * Hashtable env = new Hashtable();
 * env.put(Context.INITIAL_CONTEXT_FACTORY, "bitronix.tm.jndi.BitronixInitialContextFactory");
 * Context ctx = new InitialContext(env);
 * 
*

*

The transaction manager can be looked up at the standard URL java:comp/UserTransaction * while resources can be looked up using their unique name as set in * {@link bitronix.tm.resource.common.ResourceBean#getUniqueName()}. *

* * @author lorban * @see bitronix.tm.jndi.BitronixContext */ public class BitronixInitialContextFactory implements InitialContextFactory { public Context getInitialContext(Hashtable hashtable) throws NamingException { return new BitronixContext(); } public String toString() { return "a BitronixInitialContextFactory"; } } btm-dist-2.1.4/src/bitronix/tm/jndi/BitronixContext.java0000644000175000017500000001563312147207062022015 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.jndi; import bitronix.tm.TransactionManagerServices; import bitronix.tm.resource.ResourceRegistrar; import javax.naming.*; import java.util.Hashtable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Implementation of {@link javax.naming.Context} that allows lookup of transaction manager * and registered resources. *

This implementation is trivial as only the lookup methods are implemented, * all the other ones will throw a {@link OperationNotSupportedException}.

* * @author lorban * @see bitronix.tm.jndi.BitronixInitialContextFactory */ public class BitronixContext implements Context { private final static Logger log = LoggerFactory.getLogger(BitronixContext.class); private boolean closed = false; private final String userTransactionName; private final String synchronizationRegistryName; public BitronixContext() { userTransactionName = TransactionManagerServices.getConfiguration().getJndiUserTransactionName(); if (log.isDebugEnabled()) log.debug("binding transaction manager at name '" + userTransactionName + "'"); synchronizationRegistryName = TransactionManagerServices.getConfiguration().getJndiTransactionSynchronizationRegistryName(); if (log.isDebugEnabled()) log.debug("binding synchronization registry at name '" + synchronizationRegistryName + "'"); } private void checkClosed() throws ServiceUnavailableException { if (closed) throw new ServiceUnavailableException("context is closed"); } public void close() throws NamingException { closed = true; } public Object lookup(Name name) throws NamingException { return lookup(name.toString()); } public Object lookup(String s) throws NamingException { checkClosed(); if (log.isDebugEnabled()) log.debug("looking up '" + s + "'"); Object o; if (userTransactionName.equals(s)) o = TransactionManagerServices.getTransactionManager(); else if (synchronizationRegistryName.equals(s)) o = TransactionManagerServices.getTransactionSynchronizationRegistry(); else o = ResourceRegistrar.get(s); if (o == null) throw new NameNotFoundException("unable to find a bound object at name '" + s + "'"); return o; } public String toString() { return "a BitronixContext with userTransactionName='" + userTransactionName + "' and synchronizationRegistryName='" + synchronizationRegistryName + "'"; } public void bind(Name name, Object o) throws NamingException { throw new OperationNotSupportedException(); } public void bind(String s, Object o) throws NamingException { throw new OperationNotSupportedException(); } public void rebind(Name name, Object o) throws NamingException { throw new OperationNotSupportedException(); } public void rebind(String s, Object o) throws NamingException { throw new OperationNotSupportedException(); } public void unbind(Name name) throws NamingException { throw new OperationNotSupportedException(); } public void unbind(String s) throws NamingException { throw new OperationNotSupportedException(); } public void rename(Name name, Name name1) throws NamingException { throw new OperationNotSupportedException(); } public void rename(String s, String s1) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration list(Name name) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration list(String s) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration listBindings(Name name) throws NamingException { throw new OperationNotSupportedException(); } public NamingEnumeration listBindings(String s) throws NamingException { throw new OperationNotSupportedException(); } public void destroySubcontext(Name name) throws NamingException { throw new OperationNotSupportedException(); } public void destroySubcontext(String s) throws NamingException { throw new OperationNotSupportedException(); } public Context createSubcontext(Name name) throws NamingException { throw new OperationNotSupportedException(); } public Context createSubcontext(String s) throws NamingException { throw new OperationNotSupportedException(); } public Object lookupLink(Name name) throws NamingException { throw new OperationNotSupportedException(); } public Object lookupLink(String s) throws NamingException { throw new OperationNotSupportedException(); } public NameParser getNameParser(Name name) throws NamingException { return BitronixNameParser.INSTANCE; } public NameParser getNameParser(String s) throws NamingException { return BitronixNameParser.INSTANCE; } public Name composeName(Name name, Name name1) throws NamingException { throw new OperationNotSupportedException(); } public String composeName(String s, String s1) throws NamingException { throw new OperationNotSupportedException(); } public Object addToEnvironment(String s, Object o) throws NamingException { throw new OperationNotSupportedException(); } public Object removeFromEnvironment(String s) throws NamingException { throw new OperationNotSupportedException(); } public Hashtable getEnvironment() throws NamingException { throw new OperationNotSupportedException(); } public String getNameInNamespace() throws NamingException { throw new OperationNotSupportedException(); } private final static class BitronixNameParser implements NameParser { private static final BitronixNameParser INSTANCE = new BitronixNameParser(); public Name parse(final String name) throws NamingException { return new CompositeName(name); } } } btm-dist-2.1.4/src/bitronix/tm/BitronixXid.java0000644000175000017500000001243212147207062020163 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.utils.Uid; import javax.transaction.xa.Xid; /** * Implementation of {@link javax.transaction.xa.Xid}. *

A XID is divided in two parts: globalTransactionId (GTRID) and branchQualifier (BQUAL). The first one uniquely * identifies the global transaction while the latter uniquely identifies the transaction branch, or the local part of * the global transaction inside a resource.

*

Technically in the Bitronix implementation, GTRID and BQUAL have the same format as described by Mike Spille. * Each {@link bitronix.tm.BitronixTransaction} get assigned a GTRID at creation time and full XIDs are created and * assigned to every {@link bitronix.tm.internal.XAResourceHolderState} when enlisted in the transaction's * {@link bitronix.tm.internal.XAResourceManager}. Both GTRID and XIDs are generated * by the {@link bitronix.tm.utils.UidGenerator}.

* * @author lorban * @see bitronix.tm.utils.UidGenerator * @see bitronix.tm.BitronixTransaction * @see bitronix.tm.internal.XAResourceManager * @see XA Exposed, Part III: The Implementor's Notebook */ public class BitronixXid implements Xid { /** * int-encoded "Btnx" string. This is used as the globally unique ID to discriminate BTM XIDs. */ public static final int FORMAT_ID = 0x42746e78; private final Uid globalTransactionId; private final Uid branchQualifier; private final int hashCodeValue; private final String toStringValue; /** * Create a new XID using the specified GTRID and BQUAL. * @param globalTransactionId the GTRID. * @param branchQualifier the BQUAL. */ public BitronixXid(Uid globalTransactionId, Uid branchQualifier) { this.globalTransactionId = globalTransactionId; this.branchQualifier = branchQualifier; this.toStringValue = precalculateToString(); this.hashCodeValue = precalculateHashCode(); } public BitronixXid(Xid xid) { this.globalTransactionId = new Uid(xid.getGlobalTransactionId()); this.branchQualifier = new Uid(xid.getBranchQualifier()); this.toStringValue = precalculateToString(); this.hashCodeValue = precalculateHashCode(); } /** * Get Bitronix XID format ID. Defined by {@link BitronixXid#FORMAT_ID}. * @return the Bitronix XID format ID. */ public int getFormatId() { return FORMAT_ID; } /** * Get the BQUAL of the XID. * @return the XID branch qualifier. */ public byte[] getBranchQualifier() { return branchQualifier.getArray(); } public Uid getBranchQualifierUid() { return branchQualifier; } /** * Get the GTRID of the XID. * @return the XID global transaction ID. */ public byte[] getGlobalTransactionId() { return globalTransactionId.getArray(); } public Uid getGlobalTransactionIdUid() { return globalTransactionId; } /** * Get a human-readable string representation of the XID. * @return a human-readable string representation. */ public String toString() { return toStringValue; } private String precalculateToString() { StringBuilder sb = new StringBuilder(288); sb.append("a Bitronix XID ["); sb.append(globalTransactionId.toString()); sb.append(" : "); sb.append(branchQualifier.toString()); sb.append("]"); return sb.toString(); } /** * Compare two XIDs for equality. * @param obj the XID to compare to. * @return true if both XIDs have the same format ID and contain exactly the same GTRID and BQUAL. */ public boolean equals(Object obj) { if (!(obj instanceof BitronixXid)) return false; BitronixXid otherXid = (BitronixXid) obj; return FORMAT_ID == otherXid.getFormatId() && globalTransactionId.equals(otherXid.getGlobalTransactionIdUid()) && branchQualifier.equals(otherXid.getBranchQualifierUid()); } /** * Get an integer hash for the XID. * @return a constant hash value. */ public int hashCode() { return hashCodeValue; } private int precalculateHashCode() { int hashCode = FORMAT_ID; if (globalTransactionId != null) hashCode += globalTransactionId.hashCode(); if (branchQualifier != null) hashCode += branchQualifier.hashCode(); return hashCode; } } btm-dist-2.1.4/src/bitronix/tm/BitronixTransactionSynchronizationRegistryObjectFactory.java0000644000175000017500000000373712147207062031266 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.naming.Context; import javax.naming.Name; import javax.naming.spi.ObjectFactory; import java.util.Hashtable; /** * {@link bitronix.tm.BitronixTransactionSynchronizationRegistry} object factory for JNDI references. * * @author lorban */ public class BitronixTransactionSynchronizationRegistryObjectFactory implements ObjectFactory { private final static Logger log = LoggerFactory.getLogger(BitronixTransactionSynchronizationRegistryObjectFactory.class); /** * Since there can be only one synchronization registry per VM instance, this method always returns a reference * to the unique BitronixTransactionSynchronizationRegistry object. * @see bitronix.tm.BitronixTransactionSynchronizationRegistry * @return the unique synchronization registry instance. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { if (log.isDebugEnabled()) log.debug("returning the unique synchronization registry instance"); return TransactionManagerServices.getTransactionSynchronizationRegistry(); } } btm-dist-2.1.4/src/bitronix/tm/journal/0000755000175000017500000000000012147207062016525 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/journal/package.html0000644000175000017500000000012712147207062021006 0ustar tonytony

Transactions disk journal.

btm-dist-2.1.4/src/bitronix/tm/journal/TransactionLogAppender.java0000644000175000017500000002123212147207062023776 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import bitronix.tm.TransactionManagerServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.util.Set; /** * Used to write {@link TransactionLogRecord} objects to a log file. * * @author lorban */ public class TransactionLogAppender { private final static Logger log = LoggerFactory.getLogger(TransactionLogAppender.class); /** * int-encoded "xntB" ASCII string. * This will be useful after swapping log files since we will potentially overwrite old logs not necessarily of the * same size. Very useful when debugging and eventually restoring broken log files. */ public static final int END_RECORD = 0x786e7442; private final File file; private final FileChannel fc; private final FileLock lock; private final TransactionLogHeader header; private final long maxFileLength; private static volatile DiskForceBatcherThread diskForceBatcherThread; /** * Create an appender that will write to specified file up to the specified maximum length. * All disk access are synchronized arround the RandomAccessFile object, including header calls. * @param file the underlying File used to write to disk. * @param maxFileLength size of the file on disk that can never be bypassed. * @throws IOException if an I/O error occurs. */ public TransactionLogAppender(File file, long maxFileLength) throws IOException { this.maxFileLength = maxFileLength; this.file = file; this.fc = new RandomAccessFile(file, "rw").getChannel(); this.header = new TransactionLogHeader(fc, maxFileLength); this.lock = fc.tryLock(0, TransactionLogHeader.TIMESTAMP_HEADER, false); if (this.lock == null) throw new IOException("transaction log file " + file.getName() + " is locked. Is another instance already running?"); spawnBatcherThread(); } /** * Return a {@link TransactionLogHeader} that allows reading and controlling the log file's header. * @return this log file's TransactionLogHeader */ public TransactionLogHeader getHeader() { return header; } /** * Write a {@link TransactionLogRecord} to disk. * @param tlog the record to write to disk. * @return true if there was room in the log file and the log was written, false otherwise. * @throws IOException if an I/O error occurs. */ public boolean writeLog(TransactionLogRecord tlog) throws IOException { synchronized (fc) { int recordSize = tlog.calculateTotalRecordSize(); long futureFilePosition = getHeader().getPosition() + recordSize; if (futureFilePosition >= maxFileLength) { // see TransactionLogHeader.setPosition() as it double-checks this if (log.isDebugEnabled()) log.debug("log file is full (size would be: " + futureFilePosition + ", max allowed: " + maxFileLength + ")"); return false; } if (log.isDebugEnabled()) log.debug("between " + getHeader().getPosition() + " and " + futureFilePosition + ", writing " + tlog); ByteBuffer buf = ByteBuffer.allocate(recordSize); buf.putInt(tlog.getStatus()); buf.putInt(tlog.getRecordLength()); buf.putInt(tlog.getHeaderLength()); buf.putLong(tlog.getTime()); buf.putInt(tlog.getSequenceNumber()); buf.putInt(tlog.getCrc32()); buf.put((byte) tlog.getGtrid().getArray().length); buf.put(tlog.getGtrid().getArray()); Set uniqueNames = tlog.getUniqueNames(); buf.putInt(uniqueNames.size()); for (String uniqueName : uniqueNames) { buf.putShort((short) uniqueName.length()); buf.put(uniqueName.getBytes()); } buf.putInt(tlog.getEndRecord()); buf.flip(); while (buf.hasRemaining()) { this.fc.write(buf); } getHeader().goAhead(tlog.calculateTotalRecordSize()); if (log.isDebugEnabled()) log.debug("disk journal appender now at position " + getHeader().getPosition()); return true; } } /** * Close the appender and the underlying file. * @throws IOException if an I/O error occurs. */ public void close() throws IOException { synchronized (fc) { shutdownBatcherThread(); getHeader().setState(TransactionLogHeader.CLEAN_LOG_STATE); fc.force(false); lock.release(); fc.close(); } } /** * Creates a cursor on this journal file allowing iteration of its records. * This opens a new read-only file descriptor independent of the write-only one * still used for writing transaction logs. * @return a TransactionLogCursor. * @throws IOException if an I/O error occurs. */ public TransactionLogCursor getCursor() throws IOException { return new TransactionLogCursor(file); } /** * Force flushing the logs to disk * @throws IOException if an I/O error occurs. */ public void force() throws IOException { if (!TransactionManagerServices.getConfiguration().isForcedWriteEnabled()) { if (log.isDebugEnabled()) log.debug("disk forces have been disabled"); return; } if (!TransactionManagerServices.getConfiguration().isForceBatchingEnabled()) { if (log.isDebugEnabled()) log.debug("not batching disk force"); doForce(); } else { diskForceBatcherThread.enqueue(this); } } public String toString() { return "a TransactionLogAppender on " + file.getName(); } protected void doForce() throws IOException { synchronized (fc) { if (log.isDebugEnabled()) log.debug("forcing log writing"); fc.force(false); if (log.isDebugEnabled()) log.debug("done forcing log"); } } private void spawnBatcherThread() { synchronized (TransactionLogAppender.class) { if (diskForceBatcherThread != null) return; if (log.isDebugEnabled()) log.debug("spawning disk force batcher thread"); diskForceBatcherThread = DiskForceBatcherThread.getInstance(); if (!TransactionManagerServices.getConfiguration().isForcedWriteEnabled()) { log.warn("transaction journal disk syncs have been disabled, transaction logs integrity is not guaranteed !"); return; } if (!TransactionManagerServices.getConfiguration().isForceBatchingEnabled()) { log.warn("transaction journal disk syncs batching has been disabled, this will seriously impact performance !"); return; } } } private void shutdownBatcherThread() { synchronized (TransactionLogAppender.class) { if (diskForceBatcherThread == null) return; if (log.isDebugEnabled()) log.debug("requesting disk force batcher thread to shutdown"); diskForceBatcherThread.setAlive(false); diskForceBatcherThread.interrupt(); do { try { if (log.isDebugEnabled()) log.debug("waiting for disk force batcher thread to die"); diskForceBatcherThread.join(); } catch (InterruptedException ex) { //ignore } } while (diskForceBatcherThread.isInterrupted()); if (log.isDebugEnabled()) log.debug("disk force batcher thread has shutdown"); diskForceBatcherThread = null; } // synchronized } } btm-dist-2.1.4/src/bitronix/tm/journal/Journal.java0000644000175000017500000000521212147207062021002 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import bitronix.tm.utils.Uid; import bitronix.tm.utils.Service; import java.io.IOException; import java.util.Map; import java.util.Set; /** * Transaction logs journal implementations must implement this interface to provide functionality required by the * transaction manager. * * @author lorban */ public interface Journal extends Service { /** * Log a new transaction status to journal. Note that the journal will not check the flow of the transactions. * If you call this method with erroneous data, it will be added to the journal as-is. * @param status transaction status to log. * @param gtrid GTRID of the transaction. * @param uniqueNames unique names of the RecoverableXAResourceProducers participating in the transaction. * @throws IOException if an I/O error occurs. */ public void log(int status, Uid gtrid, Set uniqueNames) throws IOException; /** * Open the journal. Integrity should be checked and an exception should be thrown in case the journal is corrupt. * @throws IOException if an I/O error occurs. */ public void open() throws IOException; /** * Close this journal and release all underlying resources. * @throws IOException if an I/O error occurs. */ public void close() throws IOException; /** * Force journal to synchronize with permanent storage. * @throws IOException if an I/O error occurs. */ public void force() throws IOException; /** * Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record. * @return a Map using Uid objects GTRID as key and {@link TransactionLogRecord} as value * @throws IOException if an I/O error occurs. */ public Map collectDanglingRecords() throws IOException; } btm-dist-2.1.4/src/bitronix/tm/journal/TransactionLogCursor.java0000644000175000017500000001607312147207062023524 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.util.Set; import java.util.HashSet; import bitronix.tm.utils.Uid; /** * Used to read {@link TransactionLogRecord} objects from a log file. * * @author lorban */ public class TransactionLogCursor { private final static Logger log = LoggerFactory.getLogger(TransactionLogCursor.class); private final RandomAccessFile randomAccessFile; private long endPosition; /** * Create a TransactionLogCursor that will read from the specified file. * This opens a new read-only file descriptor. * @param file the file to read logs from * @throws IOException if an I/O error occurs. */ public TransactionLogCursor(File file) throws IOException { this.randomAccessFile = new RandomAccessFile(file, "r"); this.randomAccessFile.seek(TransactionLogHeader.CURRENT_POSITION_HEADER); synchronized (randomAccessFile) { endPosition = this.randomAccessFile.readLong(); } } /** * Fetch the next TransactionLogRecord from log, recalculating the CRC and checking it against the stored one. * InvalidChecksumException is thrown if the check fails. * @return the TransactionLogRecord or null if the end of the log file has been reached * @throws IOException if an I/O error occurs. */ public TransactionLogRecord readLog() throws IOException { return readLog(false); } /** * Fetch the next TransactionLogRecord from log. * @param skipCrcCheck if set to false, the method will thow an InvalidChecksumException if the CRC on disk does * not match the recalculated one. Otherwise, the CRC is not recalculated nor checked agains the stored one. * @return the TransactionLogRecord or null if the end of the log file has been reached * @throws IOException if an I/O error occurs. */ public TransactionLogRecord readLog(boolean skipCrcCheck) throws IOException { synchronized (randomAccessFile) { long currentPosition = randomAccessFile.getFilePointer(); if (currentPosition >= endPosition) { if (log.isDebugEnabled()) log.debug("end of transaction log file reached at " + randomAccessFile.getFilePointer()); return null; } int status = randomAccessFile.readInt(); int recordLength = randomAccessFile.readInt(); // check that log is in file bounds long savedPos = randomAccessFile.getFilePointer(); randomAccessFile.skipBytes(recordLength - 4); if (randomAccessFile.getFilePointer() + 4 > endPosition) { randomAccessFile.skipBytes(4); throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (record terminator outside of file bounds: " + randomAccessFile.getFilePointer() + " of " + endPosition + ", recordLength: " + recordLength + ")"); } // check for log terminator int endCode = randomAccessFile.readInt(); long endOfRecordPosition = randomAccessFile.getFilePointer(); if (endCode != TransactionLogAppender.END_RECORD) throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (no record terminator found)"); randomAccessFile.seek(savedPos); int headerLength = randomAccessFile.readInt(); long time = randomAccessFile.readLong(); int sequenceNumber = randomAccessFile.readInt(); int crc32 = randomAccessFile.readInt(); byte gtridSize = randomAccessFile.readByte(); // check that GTRID is not too long if (4 + 8 + 4 + 4 + 1 + gtridSize > recordLength) { randomAccessFile.seek(endOfRecordPosition); throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (GTRID size too long)"); } byte[] gtridArray = new byte[gtridSize]; randomAccessFile.readFully(gtridArray); Uid gtrid = new Uid(gtridArray); int uniqueNamesCount = randomAccessFile.readInt(); Set uniqueNames = new HashSet(); int currentReadCount = 4 + 8 + 4 + 4 + 1 + gtridSize + 4; for (int i=0; i recordLength) { randomAccessFile.seek(endOfRecordPosition); throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (unique names too long, " + (i+1) + " out of " + uniqueNamesCount + ", length: " + length + ", currentReadCount: " + currentReadCount + ", recordLength: " + recordLength + ")"); } byte[] nameBytes = new byte[length]; randomAccessFile.readFully(nameBytes); uniqueNames.add(new String(nameBytes, "US-ASCII")); } int cEndRecord = randomAccessFile.readInt(); TransactionLogRecord tlog = new TransactionLogRecord(status, recordLength, headerLength, time, sequenceNumber, crc32, gtrid, uniqueNames, cEndRecord); // check that CRC is okay if (!skipCrcCheck && !tlog.isCrc32Correct()) { randomAccessFile.seek(endOfRecordPosition); throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + "(invalid CRC, recorded: " + tlog.getCrc32() + ", calculated: " + tlog.calculateCrc32() + ")"); } return tlog; } } /** * Close the cursor and the underlying file * @throws IOException if an I/O error occurs. */ public void close() throws IOException { synchronized (randomAccessFile) { randomAccessFile.close(); } } } btm-dist-2.1.4/src/bitronix/tm/journal/DiskForceBatcherThread.java0000644000175000017500000001114012147207062023657 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; /** * Thread that executes disk force batches. * * @author lorban */ public final class DiskForceBatcherThread extends Thread { private final static Logger log = LoggerFactory.getLogger(DiskForceBatcherThread.class); private static volatile DiskForceBatcherThread instance; private final AtomicBoolean alive = new AtomicBoolean(); private volatile DiskForceWaitQueue waitQueue = new DiskForceWaitQueue(); /** * Get the single instance of the DiskForceBatcherThread. * @return the single instance of the DiskForceBatcherThread. */ public synchronized static DiskForceBatcherThread getInstance() { if (instance == null) { instance = new DiskForceBatcherThread(); } return instance; } private DiskForceBatcherThread() { setName("bitronix-disk-force-batcher"); setPriority(Thread.NORM_PRIORITY - 1); setDaemon(true); alive.set(true); start(); } /** * Thread will run for as long as this flag is not false. * @param alive The new flag value. * @return the old flag value. */ public boolean setAlive(boolean alive) { return this.alive.getAndSet(alive); } /** * Add the TransactionLogAppender to the wait queue and wait until the disk force is done. * @param tla the TransactionLogAppender */ public void enqueue(TransactionLogAppender tla) { DiskForceWaitQueue currrentWaitQueue = waitQueue; while (!currrentWaitQueue.enqueue(tla)) { if (log.isDebugEnabled()) log.debug("current DiskForceWaitQueue [" + currrentWaitQueue + "] is cleared, trying next one: [" + waitQueue + "]"); currrentWaitQueue = waitQueue; } if (log.isDebugEnabled()) log.debug("batching disk force, there are " + currrentWaitQueue.size() + " TransactionLogAppender(s) in the wait queue"); try { currrentWaitQueue.waitUntilNotContains(tla); } catch (InterruptedException ex) { if (log.isDebugEnabled()) log.debug("interrupted while waiting for journal log to be forced, ignored as disk force will happen anyway"); } if (log.isDebugEnabled()) log.debug("wait queue got emptied, disk force is done"); } private void runForceBatch() throws IOException { if (log.isDebugEnabled()) log.debug("waiting for the wait queue to fill up"); while(alive.get() && waitQueue.isEmpty()) { try { waitQueue.waitUntilNotEmpty(); } catch (InterruptedException ex) { // ignore } } if (!alive.get()) { if (log.isDebugEnabled()) log.debug("interrupted while waiting for the queue to fill up"); return; } if (log.isDebugEnabled()) log.debug("wait queue is not empty anymore (" + waitQueue.size() + " in queue)"); DiskForceWaitQueue oldWaitQueue = waitQueue; waitQueue = new DiskForceWaitQueue(); if (log.isDebugEnabled()) log.debug("forcing..."); oldWaitQueue.head().doForce(); oldWaitQueue.clear(); // notify threads waiting in this wait queue that the disk force is done } public void run() { if (log.isDebugEnabled()) log.debug("disk force thread is up and running"); while (alive.get()) { try { runForceBatch(); } catch (Exception ex) { log.warn("unexpected Exception", ex); } } // while instance = null; if (log.isDebugEnabled()) log.debug("disk force thread has terminated"); } public String toString() { return "a DiskForceBatcherThread"; } } btm-dist-2.1.4/src/bitronix/tm/journal/DiskJournal.java0000644000175000017500000004064512147207062021626 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import bitronix.tm.BitronixXid; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.MonotonicClock; import bitronix.tm.utils.Uid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.Status; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.util.*; /** * Simple implementation of a journal that writes on a two-files disk log. *

Files are pre-allocated in size, never grow and when the first one is full, dangling records are copied to the * second file and logging starts again on the latter.

*

This implementation is not highly efficient but quite robust and simple. It is based on one of the implementations * proposed by Mike Spille.

*

Configurable properties are all starting with bitronix.tm.journal.disk.

* * @see bitronix.tm.Configuration * @see XA Exposed, Part III: The Implementor's Notebook * @author lorban */ public class DiskJournal implements Journal { private final static Logger log = LoggerFactory.getLogger(DiskJournal.class); /** * The active log appender. This is exactly the same reference as tla1 or tla2 depending on which one is * currently active */ private volatile TransactionLogAppender activeTla; /** * The transaction log appender writing on the 1st file */ private TransactionLogAppender tla1; /** * The transaction log appender writing on the 2nd file */ private TransactionLogAppender tla2; /** * Create an uninitialized disk journal. You must call open() prior you can use it. */ public DiskJournal() { } /** * Log a new transaction status to journal. Note that the DiskJournal will not check the flow of the transaction. * If you call this method with erroneous data, it will be added to the journal anyway. * @param status transaction status to log. See {@link javax.transaction.Status} constants. * @param gtrid raw GTRID of the transaction. * @param uniqueNames unique names of the {@link bitronix.tm.resource.common.ResourceBean}s participating in * this transaction. * @throws java.io.IOException in case of disk IO failure or if the disk journal is not open. */ public void log(int status, Uid gtrid, Set uniqueNames) throws IOException { if (activeTla == null) throw new IOException("cannot write log, disk logger is not open"); if (TransactionManagerServices.getConfiguration().isFilterLogStatus()) { if (status != Status.STATUS_COMMITTING && status != Status.STATUS_COMMITTED && status != Status.STATUS_UNKNOWN) { if (log.isDebugEnabled()) log.debug("filtered out write to log for status " + Decoder.decodeStatus(status)); return; } } TransactionLogRecord tlog = new TransactionLogRecord(status, gtrid, uniqueNames); synchronized (this) { boolean written = activeTla.writeLog(tlog); if (!written) { // time to swap log files swapJournalFiles(); written = activeTla.writeLog(tlog); if (!written) throw new IOException("no room to write log to journal even after swap, circular collision avoided"); } } //synchronized } /** * Force active log file to synchronize with the underlying disk device. * @throws java.io.IOException in case of disk IO failure or if the disk journal is not open. */ public void force() throws IOException { if (activeTla == null) throw new IOException("cannot force log writing, disk logger is not open"); activeTla.force(); } /** * Open the disk journal. Files are checked for integrity and DiskJournal will refuse to open corrupted log files. * If files are not present on disk, this method will create and pre-allocate them. * @throws java.io.IOException in case of disk IO failure. */ public synchronized void open() throws IOException { if (activeTla != null) { log.warn("disk journal already open"); return; } File file1 = new File(TransactionManagerServices.getConfiguration().getLogPart1Filename()); File file2 = new File(TransactionManagerServices.getConfiguration().getLogPart2Filename()); if (!file1.exists() && !file2.exists()) { log.debug("creation of log files"); createLogfile(file2, TransactionManagerServices.getConfiguration().getMaxLogSizeInMb()); // make the clock run a little before creating the 2nd log file to ensure the timestamp headers are not the same long before = MonotonicClock.currentTimeMillis(); while (MonotonicClock.currentTimeMillis() < before + 100L) { try { Thread.sleep(100); } catch (InterruptedException ex) { /* ignore */ } } createLogfile(file1, TransactionManagerServices.getConfiguration().getMaxLogSizeInMb()); } if (file1.length() != file2.length()) { if (!TransactionManagerServices.getConfiguration().isSkipCorruptedLogs()) throw new IOException("transaction log files are not of the same length, assuming they're corrupt"); log.error("transaction log files are not of the same length: corrupted files?"); } long maxFileLength = Math.max(file1.length(), file2.length()); if (log.isDebugEnabled()) log.debug("disk journal files max length: " + maxFileLength); tla1 = new TransactionLogAppender(file1, maxFileLength); tla2 = new TransactionLogAppender(file2, maxFileLength); byte cleanStatus = pickActiveJournalFile(tla1, tla2); if (cleanStatus != TransactionLogHeader.CLEAN_LOG_STATE) { log.warn("active log file is unclean, did you call BitronixTransactionManager.shutdown() at the end of the last run?"); } if (log.isDebugEnabled()) log.debug("disk journal opened"); } /** * Close the disk journal and the underlying files. * @throws java.io.IOException in case of disk IO failure. */ public synchronized void close() throws IOException { if (activeTla == null) { return; } try { tla1.close(); } catch (IOException ex) { log.error("cannot close " + tla1, ex); } tla1 = null; try { tla2.close(); } catch (IOException ex) { log.error("cannot close " + tla2, ex); } tla2 = null; activeTla = null; if (log.isDebugEnabled()) log.debug("disk journal closed"); } public void shutdown() { try { close(); } catch (IOException ex) { log.error("error shutting down disk journal. Transaction log integrity could be compromised!", ex); } } /** * Collect all dangling records of the active log file. * @return a Map using Uid objects GTRID as key and {@link TransactionLogRecord} as value * @throws java.io.IOException in case of disk IO failure or if the disk journal is not open. */ public Map collectDanglingRecords() throws IOException { if (activeTla == null) throw new IOException("cannot collect dangling records, disk logger is not open"); return collectDanglingRecords(activeTla); } /* * Internal impl. */ /** * Create a fresh log file on disk. If the specified file already exists it will be deleted then recreated. * @param logfile the file to create * @param maxLogSizeInMb the file size in megabytes to preallocate * @throws java.io.IOException in case of disk IO failure. */ private static void createLogfile(File logfile, int maxLogSizeInMb) throws IOException { if (logfile.isDirectory()) throw new IOException("log file is referring to a directory: " + logfile.getAbsolutePath()); if (logfile.exists()) { boolean deleted = logfile.delete(); if (!deleted) throw new IOException("log file exists but cannot be overwritten: " + logfile.getAbsolutePath()); } if (logfile.getParentFile() != null) { logfile.getParentFile().mkdirs(); } RandomAccessFile raf = null; try { raf = new RandomAccessFile(logfile, "rw"); raf.seek(TransactionLogHeader.FORMAT_ID_HEADER); raf.writeInt(BitronixXid.FORMAT_ID); raf.writeLong(MonotonicClock.currentTimeMillis()); raf.writeByte(TransactionLogHeader.CLEAN_LOG_STATE); raf.writeLong((long) TransactionLogHeader.HEADER_LENGTH); byte[] buffer = new byte[4096]; int length = (maxLogSizeInMb *1024 *1024) /4096; for (int i = 0; i < length; i++) { raf.write(buffer); } } finally { if (raf != null) raf.close(); } } /** * Initialize the activeTla member variable with the TransactionLogAppender object having the latest timestamp * header. * @see TransactionLogHeader * @param tla1 the first of the two candidate active TransactionLogAppenders * @param tla2 the second of the two candidate active TransactionLogAppenders * @return the state of the designated active TransactionLogAppender as returned by TransactionLogHeader.getState() * @throws java.io.IOException in case of disk IO failure. */ private synchronized byte pickActiveJournalFile(TransactionLogAppender tla1, TransactionLogAppender tla2) throws IOException { if (tla1.getHeader().getTimestamp() > tla2.getHeader().getTimestamp()) { activeTla = tla1; if (log.isDebugEnabled()) log.debug("logging to file 1: " + activeTla); } else { activeTla = tla2; if (log.isDebugEnabled()) log.debug("logging to file 2: " + activeTla); } byte cleanState = activeTla.getHeader().getState(); activeTla.getHeader().setState(TransactionLogHeader.UNCLEAN_LOG_STATE); if (log.isDebugEnabled()) log.debug("log file activated, forcing file state to disk"); activeTla.force(); return cleanState; } /** *

Swap the active and the passive journal files so that the active one becomes passive and the passive one * becomes active.

* List of actions taken by this method: *
    *
  • copy dangling COMMITTING records to the passive log file.
  • *
  • update header timestamp of passive log file (makes it become active).
  • *
  • do a force on passive log file. It is now the active file.
  • *
  • switch references of active/passive files.
  • *
* @throws java.io.IOException in case of disk IO failure. */ private synchronized void swapJournalFiles() throws IOException { if (log.isDebugEnabled()) log.debug("swapping journal log file to " + getPassiveTransactionLogAppender()); //step 1 TransactionLogAppender passiveTla = getPassiveTransactionLogAppender(); passiveTla.getHeader().rewind(); copyDanglingRecords(activeTla, passiveTla); //step 2 passiveTla.getHeader().setTimestamp(MonotonicClock.currentTimeMillis()); //step 3 passiveTla.force(); //step 4 if (activeTla == tla1) { activeTla = tla2; } else { activeTla = tla1; } if (log.isDebugEnabled()) log.debug("journal log files swapped"); } /** * @return the TransactionFileAppender of the passive journal file. */ private synchronized TransactionLogAppender getPassiveTransactionLogAppender() { if (tla1 == activeTla) return tla2; return tla1; } /** * Copy all records that have status COMMITTING and no corresponding COMMITTED record from the fromTla to the toTla. * @param fromTla the source where to search for COMMITTING records with no corresponding COMMITTED record * @param toTla the destination where the COMMITTING records will be copied to * @throws java.io.IOException in case of disk IO failure. */ private static void copyDanglingRecords(TransactionLogAppender fromTla, TransactionLogAppender toTla) throws IOException { if (log.isDebugEnabled()) log.debug("starting copy of dangling records"); Map danglingRecords = collectDanglingRecords(fromTla); for (TransactionLogRecord tlog : danglingRecords.values()) { toTla.writeLog(tlog); } if (log.isDebugEnabled()) log.debug(danglingRecords.size() + " dangling record(s) copied to passive log file"); } /** * Create a Map of TransactionLogRecord with COMMITTING status objects using the GTRID byte[] as key that have * no corresponding COMMITTED record * @param tla the TransactionLogAppender to scan * @return a Map using Uid objects GTRID as key and {@link TransactionLogRecord} as value * @throws java.io.IOException in case of disk IO failure. */ private static Map collectDanglingRecords(TransactionLogAppender tla) throws IOException { Map danglingRecords = new HashMap(64); TransactionLogCursor tlc = tla.getCursor(); try { int committing = 0; int committed = 0; while (true) { TransactionLogRecord tlog; try { tlog = tlc.readLog(); } catch (CorruptedTransactionLogException ex) { if (TransactionManagerServices.getConfiguration().isSkipCorruptedLogs()) { log.error("skipping corrupted log", ex); continue; } throw ex; } if (tlog == null) break; int status = tlog.getStatus(); if (status == Status.STATUS_COMMITTING) { danglingRecords.put(tlog.getGtrid(), tlog); committing++; } // COMMITTED is when there was no problem in the transaction // UNKNOWN is when a 2PC transaction heuristically terminated // ROLLEDBACK is when a 1PC transaction rolled back during commit if (status == Status.STATUS_COMMITTED || status == Status.STATUS_UNKNOWN || status == Status.STATUS_ROLLEDBACK) { TransactionLogRecord rec = danglingRecords.get(tlog.getGtrid()); if (rec != null) { Set recUniqueNames = new HashSet(rec.getUniqueNames()); recUniqueNames.removeAll(tlog.getUniqueNames()); if (recUniqueNames.isEmpty()) { danglingRecords.remove(tlog.getGtrid()); committed++; } else { danglingRecords.put(tlog.getGtrid(), new TransactionLogRecord(rec.getStatus(), rec.getGtrid(), recUniqueNames)); } } } } if (log.isDebugEnabled()) log.debug("collected dangling records of " + tla + ", committing: " + committing + ", committed: " + committed + ", delta: " + danglingRecords.size()); } finally { tlc.close(); } return danglingRecords; } } btm-dist-2.1.4/src/bitronix/tm/journal/TransactionLogHeader.java0000644000175000017500000001754412147207062023443 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import bitronix.tm.utils.Decoder; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; /** * Used to control a log file's header. *

The physical data is read when this object is created then cached. Calling setter methods sets the header field * then moves the file pointer back to the previous location.

* * @author lorban */ public class TransactionLogHeader { private final static Logger log = LoggerFactory.getLogger(TransactionLogHeader.class); /** * Position of the format ID in the header (see {@link bitronix.tm.BitronixXid#FORMAT_ID}). */ public final static int FORMAT_ID_HEADER = 0; /** * Position of the timestamp in the header. */ public final static int TIMESTAMP_HEADER = FORMAT_ID_HEADER + 4; /** * Position of the log file state in the header. */ public final static int STATE_HEADER = TIMESTAMP_HEADER + 8; /** * Position of the current log position in the header. */ public final static int CURRENT_POSITION_HEADER = STATE_HEADER + 1; /** * Total length of the header. */ public final static int HEADER_LENGTH = CURRENT_POSITION_HEADER + 8; /** * State of the log file when it has been closed properly. */ public final static byte CLEAN_LOG_STATE = 0; /** * State of the log file when it hasn't been closed properly or it is still open. */ public final static byte UNCLEAN_LOG_STATE = -1; private final FileChannel fc; private final long maxFileLength; private volatile int formatId; private volatile long timestamp; private volatile byte state; private volatile long position; /** * TransactionLogHeader are used to control headers of the specified RandomAccessFile. * All calls to setters are synchronized on the passed-in RandomAccessFile. * @param fc the file channel to read from. * @param maxFileLength the max file length. * @throws IOException if an I/O error occurs. */ public TransactionLogHeader(FileChannel fc, long maxFileLength) throws IOException { this.fc = fc; this.maxFileLength = maxFileLength; synchronized (this.fc) { fc.position(FORMAT_ID_HEADER); ByteBuffer buf = ByteBuffer.allocate(4 + 8 + 1 + 8); while (buf.hasRemaining()) { this.fc.read(buf); } buf.flip(); formatId = buf.getInt(); timestamp = buf.getLong(); state = buf.get(); position = buf.getLong(); fc.position(position); } if (log.isDebugEnabled()) log.debug("read header " + this); } /** * Get FORMAT_ID_HEADER. * @see #FORMAT_ID_HEADER * @return the FORMAT_ID_HEADER value. */ public int getFormatId() { return formatId; } /** * Get TIMESTAMP_HEADER. * @see #TIMESTAMP_HEADER * @return the TIMESTAMP_HEADER value. */ public long getTimestamp() { return timestamp; } /** * Get STATE_HEADER. * @see #STATE_HEADER * @return the STATE_HEADER value. */ public byte getState() { return state; } /** * Get CURRENT_POSITION_HEADER. * @see #CURRENT_POSITION_HEADER * @return the CURRENT_POSITION_HEADER value. */ public long getPosition() { return position; } /** * Set FORMAT_ID_HEADER. * @see #FORMAT_ID_HEADER * @param formatId the FORMAT_ID_HEADER value. * @throws IOException if an I/O error occurs. */ public void setFormatId(int formatId) throws IOException { ByteBuffer buf = ByteBuffer.allocate(8); buf.putInt(formatId); buf.flip(); synchronized (fc) { long currentPos = fc.position(); fc.position(FORMAT_ID_HEADER); while (buf.hasRemaining()) { this.fc.write(buf); } fc.position(currentPos); this.formatId = formatId; } } /** * Set TIMESTAMP_HEADER. * @see #TIMESTAMP_HEADER * @param timestamp the TIMESTAMP_HEADER value. * @throws IOException if an I/O error occurs. */ public void setTimestamp(long timestamp) throws IOException { ByteBuffer buf = ByteBuffer.allocate(8); buf.putLong(position); buf.flip(); synchronized (fc) { long currentPos = fc.position(); fc.position(TIMESTAMP_HEADER); while (buf.hasRemaining()) { this.fc.write(buf); } fc.position(currentPos); this.timestamp = timestamp; } } /** * Set STATE_HEADER. * @see #STATE_HEADER * @param state the STATE_HEADER value. * @throws IOException if an I/O error occurs. */ public void setState(byte state) throws IOException { ByteBuffer buf = ByteBuffer.allocate(1); buf.put(state); buf.flip(); synchronized (fc) { long currentPos = fc.position(); fc.position(STATE_HEADER); while (buf.hasRemaining()) { this.fc.write(buf); } fc.position(currentPos); this.state = state; } } /** * Set CURRENT_POSITION_HEADER. * @see #CURRENT_POSITION_HEADER * @param position the CURRENT_POSITION_HEADER value. * @throws IOException if an I/O error occurs. */ public void setPosition(long position) throws IOException { if (position < HEADER_LENGTH) throw new IOException("invalid position " + position + " (too low)"); if (position >= maxFileLength) throw new IOException("invalid position " + position + " (too high)"); ByteBuffer buf = ByteBuffer.allocate(8); buf.putLong(position); buf.flip(); synchronized (fc) { fc.position(CURRENT_POSITION_HEADER); while (buf.hasRemaining()) { this.fc.write(buf); } fc.position(position); this.position = position; } } /** * Advance CURRENT_POSITION_HEADER. * @see #setPosition * @param distance the value to add to the current position. * @throws IOException if an I/O error occurs. */ public void goAhead(long distance) throws IOException { setPosition(getPosition() + distance); } /** * Rewind CURRENT_POSITION_HEADER back to the beginning of the file. * @see #setPosition * @throws IOException if an I/O error occurs. */ public void rewind() throws IOException { setPosition(HEADER_LENGTH); } /** * Create human-readable String representation. * @return a human-readable String representing this object's state. */ public String toString() { return "a Bitronix TransactionLogHeader with timestamp=" + timestamp + ", state=" + Decoder.decodeHeaderState(state) + ", position=" + position; } } btm-dist-2.1.4/src/bitronix/tm/journal/CorruptedTransactionLogException.java0000644000175000017500000000216312147207062026070 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import java.io.IOException; /** * Thrown by {@link TransactionLogCursor} when an integrity check fails upon reading a record. * * @author lorban */ public class CorruptedTransactionLogException extends IOException { public CorruptedTransactionLogException(String s) { super(s); } } btm-dist-2.1.4/src/bitronix/tm/journal/NullJournal.java0000644000175000017500000000330112147207062021632 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import bitronix.tm.utils.Uid; import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.Set; /** * No-op journal. Do not use for anything else than testing as the transaction manager cannot guarantee * data integrity with this journal implementation. * * @author lorban */ public class NullJournal implements Journal { public NullJournal() { } public void log(int status, Uid gtrid, Set uniqueNames) throws IOException { } public void open() throws IOException { } public void close() throws IOException { } public void force() throws IOException { } public Map collectDanglingRecords() throws IOException { return Collections.emptyMap(); } public void shutdown() { } public String toString() { return "a NullJournal"; } } btm-dist-2.1.4/src/bitronix/tm/journal/DiskForceWaitQueue.java0000644000175000017500000000570012147207062023075 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import bitronix.tm.utils.CollectionUtils; /** * {@link TransactionLogAppender}s waiting for a disk force get enqueued here. * * @author lorban */ public class DiskForceWaitQueue { private final static Logger log = LoggerFactory.getLogger(DiskForceWaitQueue.class); private final List objects = new ArrayList(); private boolean isCleared = false; public DiskForceWaitQueue() { } /** * @return true if the tla was successfully enqueued, false otherwise */ public synchronized boolean enqueue(TransactionLogAppender tla) { if (isCleared) { return false; } objects.add(tla); if (log.isDebugEnabled()) log.debug("enqueued " + tla + ", " + objects.size() + " TransactionLogAppender waiting for a disk force in " + this); notifyAll(); return true; } public synchronized TransactionLogAppender head() { if (log.isDebugEnabled()) log.debug("returning head TransactionLogAppender"); return objects.get(0); } public synchronized void clear() { if (log.isDebugEnabled()) log.debug("clearing list of " + objects.size() + " waiting TransactionLogAppender(s) in " + this); objects.clear(); isCleared = true; notifyAll(); } public synchronized boolean isEmpty() { return objects.isEmpty(); } public synchronized void waitUntilNotEmpty() throws InterruptedException { while (objects.isEmpty()) { if (log.isDebugEnabled()) log.debug("waiting for some TransactionLogAppender to get enqueued"); wait(); } } public synchronized int size() { return objects.size(); } public synchronized void waitUntilNotContains(TransactionLogAppender tla) throws InterruptedException { while (CollectionUtils.containsByIdentity(objects, tla)) { if (log.isDebugEnabled()) log.debug("waiting for " + tla + " to get dequeued"); wait(); } } } btm-dist-2.1.4/src/bitronix/tm/journal/TransactionLogRecord.java0000644000175000017500000002406212147207062023462 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.Encoder; import bitronix.tm.utils.MonotonicClock; import bitronix.tm.utils.Uid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.UnsupportedEncodingException; import java.util.Collections; import java.util.Iterator; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicInteger; import java.util.zip.CRC32; /** * Representation of a transaction log record on disk. *

On-disk format has been implemented following Mike Spille's recommendations. Quoting him:

* *

[RECORD_TYPE :4] [RECORD_LEN :4] [HEADER_LEN :4] [System.currentTimeMillis :8] [Sequence number :4] * [Checksum :4] [Payload :X] [END_RECORD_INDICATOR :4]

*

Where [RECORD_TYPE] is a passed-in record type from the TM. [RECORD_LEN] is the overall record length * (sans [RECORD_TYPE and [RECORD_LEN]). [HEADER_LEN] is the length of the remainder of the header - important if you * want to support easy upgrades of your format. The remaining pieces are the rest of the header, and the payload. The * header at least should have [System.currentTimeMillis] and [Sequence number], with the [sequence number] coming from * some monotically increasing sequence generator unique to the process. The [checksum] is optional for the paranoid * among us. The time information can be very useful for profiling and tracking down problems in production, and in * conjunction with the sequence number it can give you precise ordering. This doesn't give you much in this solution, * but can be priceless if you ever move to a system with multiple dual log file pairs to lessen single-threading on a * single log file pair. Finally, I like having an [END_RECORD_INDICATOR] as an extra corruption detector device - I'm * a suspenders and belt kind of guy. Actually, the END_RECORD_INDICATOR and [RECORD_LEN] in conjunction are very * useful in development, as well, to catch programming mistakes in the log system early.

* *

Payload contains [GTRID LENGTH :1] [GTRID :A] [UNIQUE NAMES COUNT :4] ([UNIQUE NAME LENGTH :2] [UNIQUE NAME :Y] ...) * which makes a major difference with Mike's proposed format because here a record can vary in length: the GTRID size * is A bytes long (A being the GTRID length) and there can be X unique names that are Y characters long, Y being eventually * different for each name.

* * @see XA Exposed, Part III: The Implementor's Notebook * @author lorban */ public class TransactionLogRecord { private final static Logger log = LoggerFactory.getLogger(TransactionLogRecord.class); private final static AtomicInteger sequenceGenerator = new AtomicInteger(); private final int status; private final int recordLength; private final int headerLength; private final long time; private final int sequenceNumber; private final int crc32; private final Uid gtrid; private final SortedSet uniqueNames; private final int endRecord; /** * Use this constructor when restoring a log from the disk. * @param status record type * @param recordLength record length excluding status and recordLength * @param headerLength length of all fields except gtrid, uniqueNames and endRecord * @param time current time in milliseconds * @param sequenceNumber atomically generated sequence number during a JVM's lifespan * @param crc32 checksum of the full record * @param gtrid global transaction id * @param uniqueNames unique names of XA data sources used in this transaction * @param endRecord end of record marker */ public TransactionLogRecord(int status, int recordLength, int headerLength, long time, int sequenceNumber, int crc32, Uid gtrid, Set uniqueNames, int endRecord) { this.status = status; this.recordLength = recordLength; this.headerLength = headerLength; this.time = time; this.sequenceNumber = sequenceNumber; this.crc32 = crc32; this.gtrid = gtrid; this.uniqueNames = new TreeSet(uniqueNames); this.endRecord = endRecord; } /** * Create a new transaction log ready to be stored. * @param status record type * @param gtrid global transaction id * @param uniqueNames unique names of XA data sources used in this transaction */ public TransactionLogRecord(int status, Uid gtrid, Set uniqueNames) { this.status = status; this.time = MonotonicClock.currentTimeMillis(); this.sequenceNumber = sequenceGenerator.incrementAndGet(); this.gtrid = gtrid; this.uniqueNames = new TreeSet(uniqueNames); this.endRecord = TransactionLogAppender.END_RECORD; this.recordLength = calculateRecordLength(this.uniqueNames); this.headerLength = getRecordHeaderLength(); this.crc32 = calculateCrc32(); } public int getStatus() { return status; } public int getRecordLength() { return recordLength; } public int getHeaderLength() { return headerLength; } public long getTime() { return time; } public int getSequenceNumber() { return sequenceNumber; } public int getCrc32() { return crc32; } public Uid getGtrid() { return gtrid; } public Set getUniqueNames() { return Collections.unmodifiableSortedSet(uniqueNames); } public int getEndRecord() { return endRecord; } /** * Recalculate the CRC32 value of this record (using {@link #calculateCrc32()}) and compare it with the stored value. * @return true if the recalculated value equals the stored one, false otherwise. */ public boolean isCrc32Correct() { return calculateCrc32() == getCrc32(); } /** * Calculate the CRC32 value of this record. * @return the CRC32 value of this record. */ public int calculateCrc32() { CRC32 crc32 = new CRC32(); crc32.update(Encoder.intToBytes(status)); crc32.update(Encoder.intToBytes(recordLength)); crc32.update(Encoder.intToBytes(headerLength)); crc32.update(Encoder.longToBytes(time)); crc32.update(Encoder.intToBytes(sequenceNumber)); crc32.update(gtrid.getArray()); crc32.update(Encoder.intToBytes(uniqueNames.size())); for (String name : uniqueNames) { crc32.update(Encoder.shortToBytes((short) name.length())); try { crc32.update(name.getBytes("US-ASCII")); } catch (UnsupportedEncodingException ex) { log.error("unable to convert unique name bytes to US-ASCII", ex); } } crc32.update(Encoder.intToBytes(endRecord)); return (int) crc32.getValue(); } public String toString() { StringBuilder sb = new StringBuilder(128); sb.append("a Bitronix TransactionLogRecord with "); sb.append("status="); sb.append(Decoder.decodeStatus(status)); sb.append(", "); sb.append("recordLength="); sb.append(recordLength); sb.append(", "); sb.append("headerLength="); sb.append(headerLength); sb.append(", "); sb.append("time="); sb.append(time); sb.append(", "); sb.append("sequenceNumber="); sb.append(sequenceNumber); sb.append(", "); sb.append("crc32="); sb.append(crc32); sb.append(", "); sb.append("gtrid="); sb.append(gtrid.toString()); sb.append(", "); sb.append("uniqueNames="); Iterator it = uniqueNames.iterator(); while (it.hasNext()) { String s = it.next(); sb.append(s); if (it.hasNext()) sb.append(','); } return sb.toString(); } /** * this is the total size on disk of a TransactionLog. * @return recordLength */ int calculateTotalRecordSize() { return calculateRecordLength(uniqueNames) + 4 + 4; // + status + record length } /** * this is the value needed by field recordLength in the TransactionLog. * @param uniqueNames the unique names ofthe record. * @return recordLength */ private int calculateRecordLength(Set uniqueNames) { int totalSize = 0; for (String uniqueName : uniqueNames) { totalSize += 2 + uniqueName.length(); // 2 bytes for storing the unique name length + unique name length } totalSize += getFixedRecordLength(); return totalSize; } /** * Length of all the fixed size fields part of the record length header except status and record length. * @return fixedRecordLength */ private int getFixedRecordLength() { return 4 + 8 + 4 + 4 + 1 + gtrid.getArray().length + 4 + 4; // record header length + current time + sequence number + checksum + GTRID size + GTRID + unique names count + end record marker } /** * Value needed by field headerLength in the TransactionLog. * @return headerLength */ private int getRecordHeaderLength() { return 4 + 4 + 4 + 8 + 4 + 4; // status + record length + record header length + current time + sequence number + checksum } } btm-dist-2.1.4/src/bitronix/tm/TransactionManagerServices.java0000644000175000017500000002417612147207062023214 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.journal.DiskJournal; import bitronix.tm.journal.Journal; import bitronix.tm.journal.NullJournal; import bitronix.tm.recovery.Recoverer; import bitronix.tm.resource.ResourceLoader; import bitronix.tm.timer.TaskScheduler; import bitronix.tm.twopc.executor.AsyncExecutor; import bitronix.tm.twopc.executor.Executor; import bitronix.tm.twopc.executor.SyncExecutor; import bitronix.tm.utils.ClassLoaderUtils; import bitronix.tm.utils.DefaultExceptionAnalyzer; import bitronix.tm.utils.ExceptionAnalyzer; import bitronix.tm.utils.InitializationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** * Container for all BTM services. *

The different services available are: {@link BitronixTransactionManager}, {@link BitronixTransactionSynchronizationRegistry} * {@link Configuration}, {@link Journal}, {@link TaskScheduler}, {@link ResourceLoader}, {@link Recoverer} and {@link Executor}. * They are used in all places of the TM so they must be globally reachable.

* * @author lorban */ public class TransactionManagerServices { private final static Logger log = LoggerFactory.getLogger(TransactionManagerServices.class); private static final Lock transactionManagerLock = new ReentrantLock(); private static volatile BitronixTransactionManager transactionManager; private static final AtomicReference transactionSynchronizationRegistryRef = new AtomicReference(); private static final AtomicReference configurationRef = new AtomicReference(); private static final AtomicReference journalRef = new AtomicReference(); private static final AtomicReference taskSchedulerRef = new AtomicReference(); private static final AtomicReference resourceLoaderRef = new AtomicReference(); private static final AtomicReference recovererRef = new AtomicReference(); private static final AtomicReference executorRef = new AtomicReference(); private static final AtomicReference exceptionAnalyzerRef = new AtomicReference(); /** * Create an initialized transaction manager. * @return the transaction manager. */ public static BitronixTransactionManager getTransactionManager() { transactionManagerLock.lock(); try { if (transactionManager == null) { transactionManager = new BitronixTransactionManager(); } return transactionManager; } finally { transactionManagerLock.unlock(); } } /** * Create the JTA 1.1 TransactionSynchronizationRegistry. * @return the TransactionSynchronizationRegistry. */ public static BitronixTransactionSynchronizationRegistry getTransactionSynchronizationRegistry() { BitronixTransactionSynchronizationRegistry transactionSynchronizationRegistry = transactionSynchronizationRegistryRef.get(); if (transactionSynchronizationRegistry == null) { transactionSynchronizationRegistry = new BitronixTransactionSynchronizationRegistry(); if (!transactionSynchronizationRegistryRef.compareAndSet(null, transactionSynchronizationRegistry)) { transactionSynchronizationRegistry = transactionSynchronizationRegistryRef.get(); } } return transactionSynchronizationRegistry; } /** * Create the configuration of all the components of the transaction manager. * @return the global configuration. */ public static Configuration getConfiguration() { Configuration configuration = configurationRef.get(); if (configuration == null) { configuration = new Configuration(); if (!configurationRef.compareAndSet(null, configuration)) { configuration = configurationRef.get(); } } return configuration; } /** * Create the transactions journal. * @return the transactions journal. */ public static Journal getJournal() { Journal journal = journalRef.get(); if (journal == null) { String configuredJournal = getConfiguration().getJournal(); if ("null".equals(configuredJournal) || null == configuredJournal) { journal = new NullJournal(); } else if ("disk".equals(configuredJournal)) { journal = new DiskJournal(); } else { try { Class clazz = ClassLoaderUtils.loadClass(configuredJournal); journal = (Journal) clazz.newInstance(); } catch (Exception ex) { throw new InitializationException("invalid journal implementation '" + configuredJournal + "'", ex); } } if (log.isDebugEnabled()) log.debug("using journal " + configuredJournal); if (!journalRef.compareAndSet(null, journal)) { journal = journalRef.get(); } } return journal; } /** * Create the task scheduler. * @return the task scheduler. */ public static TaskScheduler getTaskScheduler() { TaskScheduler taskScheduler = taskSchedulerRef.get(); if (taskScheduler == null) { taskScheduler = new TaskScheduler(); if (!taskSchedulerRef.compareAndSet(null, taskScheduler)) { taskScheduler = taskSchedulerRef.get(); } else { taskScheduler.start(); } } return taskScheduler; } /** * Create the resource loader. * @return the resource loader. */ public static ResourceLoader getResourceLoader() { ResourceLoader resourceLoader = resourceLoaderRef.get(); if (resourceLoader == null) { resourceLoader = new ResourceLoader(); if (!resourceLoaderRef.compareAndSet(null, resourceLoader)) { resourceLoader = resourceLoaderRef.get(); } } return resourceLoader; } /** * Create the transaction recoverer. * @return the transaction recoverer. */ public static Recoverer getRecoverer() { Recoverer recoverer = recovererRef.get(); if (recoverer == null) { recoverer = new Recoverer(); if (!recovererRef.compareAndSet(null, recoverer)) { recoverer = recovererRef.get(); } } return recoverer; } /** * Create the 2PC executor. * @return the 2PC executor. */ public static Executor getExecutor() { Executor executor = executorRef.get(); if (executor == null) { if (getConfiguration().isAsynchronous2Pc()) { if (log.isDebugEnabled()) log.debug("using AsyncExecutor"); executor = new AsyncExecutor(); } else { if (log.isDebugEnabled()) log.debug("using SyncExecutor"); executor = new SyncExecutor(); } if (!executorRef.compareAndSet(null, executor)) { executor.shutdown(); executor = executorRef.get(); } } return executor; } /** * Create the exception analyzer. * @return the exception analyzer. */ public static ExceptionAnalyzer getExceptionAnalyzer() { ExceptionAnalyzer analyzer = exceptionAnalyzerRef.get(); if (analyzer == null) { String exceptionAnalyzerName = getConfiguration().getExceptionAnalyzer(); analyzer = new DefaultExceptionAnalyzer(); if (exceptionAnalyzerName != null) { try { analyzer = (ExceptionAnalyzer) ClassLoaderUtils.loadClass(exceptionAnalyzerName).newInstance(); } catch (Exception ex) { log.warn("failed to initialize custom exception analyzer, using default one instead", ex); } } if (!exceptionAnalyzerRef.compareAndSet(null, analyzer)) { analyzer.shutdown(); analyzer = exceptionAnalyzerRef.get(); } } return analyzer; } /** * Check if the transaction manager has started. * @return true if the transaction manager has started. */ public static boolean isTransactionManagerRunning() { return transactionManager != null; } /** * Check if the task scheduler has started. * @return true if the task scheduler has started. */ public static boolean isTaskSchedulerRunning() { return taskSchedulerRef.get() != null; } /** * Clear services references. Called at the end of the shutdown procedure. */ protected static synchronized void clear() { transactionManager = null; transactionSynchronizationRegistryRef.set(null); configurationRef.set(null); journalRef.set(null); taskSchedulerRef.set(null); resourceLoaderRef.set(null); recovererRef.set(null); executorRef.set(null); exceptionAnalyzerRef.set(null); } } btm-dist-2.1.4/src/bitronix/tm/BitronixTransactionMBean.java0000644000175000017500000000222412147207062022625 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import java.util.Collection; import java.util.Date; /** * {@link BitronixTransaction} Management interface. * * @author lorban */ public interface BitronixTransactionMBean { String getGtrid(); String getStatusDescription(); String getThreadName(); Date getStartDate(); Collection getEnlistedResourcesUniqueNames(); } btm-dist-2.1.4/src/bitronix/tm/twopc/0000755000175000017500000000000012147207062016207 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/twopc/package.html0000644000175000017500000000012412147207062020465 0ustar tonytony

Two-phase commit logic.

btm-dist-2.1.4/src/bitronix/tm/twopc/executor/0000755000175000017500000000000012147207062020045 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/twopc/executor/package.html0000644000175000017500000000014112147207062022322 0ustar tonytony

Two-phase commit commands executors.

btm-dist-2.1.4/src/bitronix/tm/twopc/executor/AsyncExecutor.java0000644000175000017500000000432112147207062023504 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2011, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc.executor; import bitronix.tm.internal.BitronixRuntimeException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** * This implementation executes submitted jobs using a java.util.concurrent cached thread pool. * * @author lorban */ public class AsyncExecutor implements Executor { private final ExecutorService executorService; public AsyncExecutor() { executorService = Executors.newCachedThreadPool(); } public Object submit(Job job) { return executorService.submit(job); } public void waitFor(Object future, long timeout) { Future f = (Future) future; try { f.get(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException ex) { throw new BitronixRuntimeException("job interrupted", ex); } catch (ExecutionException ex) { throw new BitronixRuntimeException("job execution exception", ex); } catch (TimeoutException ex) { // ok, just return } } public boolean isDone(Object future) { Future f = (Future) future; return f.isDone(); } public void shutdown() { executorService.shutdownNow(); } } btm-dist-2.1.4/src/bitronix/tm/twopc/executor/SyncExecutor.java0000644000175000017500000000233412147207062023345 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc.executor; /** * This implementation executes submitted jobs synchronously. * * @author lorban */ public class SyncExecutor implements Executor { public Object submit(Job job) { job.run(); return new Object(); } public void waitFor(Object future, long timeout) { } public boolean isDone(Object future) { return true; } public void shutdown() { } } btm-dist-2.1.4/src/bitronix/tm/twopc/executor/Job.java0000644000175000017500000000450212147207062021423 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc.executor; import bitronix.tm.TransactionManagerServices; import bitronix.tm.internal.XAResourceHolderState; import javax.transaction.xa.XAException; /** * Abstract job definition executable by the 2PC thread pools. * * @author lorban */ public abstract class Job implements Runnable { private final XAResourceHolderState resourceHolder; private volatile Object future; protected volatile XAException xaException; protected volatile RuntimeException runtimeException; public Job(XAResourceHolderState resourceHolder) { this.resourceHolder = resourceHolder; } public XAResourceHolderState getResource() { return resourceHolder; } public XAException getXAException() { return xaException; } public RuntimeException getRuntimeException() { return runtimeException; } public void setFuture(Object future) { this.future = future; } public Object getFuture() { return future; } public final void run() { String oldThreadName = null; if (TransactionManagerServices.getConfiguration().isAsynchronous2Pc()) { oldThreadName = Thread.currentThread().getName(); Thread.currentThread().setName("bitronix-2pc [ " + resourceHolder.getXid().toString() + " ]"); } execute(); if (oldThreadName != null) { Thread.currentThread().setName(oldThreadName); } } protected abstract void execute(); } btm-dist-2.1.4/src/bitronix/tm/twopc/executor/Executor.java0000644000175000017500000000406512147207062022513 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc.executor; import bitronix.tm.utils.Service; /** * Thread pool interface required by the two-phase commit logic. * * @author lorban */ public interface Executor extends Service { /** * Submit a job to be executed by the thread pool. * @param job the {@link Runnable} to execute. * @return an object used to monitor the execution of the submitted {@link Runnable}. */ public Object submit(Job job); /** * Wait for the job represented by the future to terminate. The call to this method will block until the job * finished its execution or the specified timeout elapsed. * @param future the future representing the job as returned by {@link #submit}. * @param timeout if the job did not finish during the specified timeout in milliseconds, this method returns anyway. */ public void waitFor(Object future, long timeout); /** * Check if the thread pool has terminated the execution of the job represented by a future. * @param future the future representing the job as returned by {@link #submit}. * @return true if the job is done, false otherwise. */ public boolean isDone(Object future); /** * Shutdown the thead pool. */ public void shutdown(); } btm-dist-2.1.4/src/bitronix/tm/twopc/AbstractPhaseEngine.java0000644000175000017500000002301212147207062022722 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc; import bitronix.tm.TransactionManagerServices; import bitronix.tm.internal.XAResourceManager; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.twopc.executor.Job; import bitronix.tm.twopc.executor.Executor; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.CollectionUtils; import javax.transaction.xa.XAException; import java.util.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Abstract phase execution engine. * * @author lorban */ public abstract class AbstractPhaseEngine { private final static Logger log = LoggerFactory.getLogger(AbstractPhaseEngine.class); private final Executor executor; protected AbstractPhaseEngine(Executor executor) { this.executor = executor; } /** * Execute the phase. Resources receive the phase command in position order (reversed or not). If there is more than * once resource in a position, command is sent in enlistment order (again reversed or not). * If {@link bitronix.tm.Configuration#isAsynchronous2Pc()} is true, all commands in a given position are sent * in parallel by using the detected {@link Executor} implementation. * @param resourceManager the {@link XAResourceManager} containing the enlisted resources to execute the phase on. * @param reverse true if jobs should be executed in reverse position / enlistment order, false for natural position / enlistment order. * @throws PhaseException if one or more resource threw an exception during phase execution. * @see bitronix.tm.twopc.executor.SyncExecutor * @see bitronix.tm.twopc.executor.AsyncExecutor */ protected void executePhase(XAResourceManager resourceManager, boolean reverse) throws PhaseException { SortedSet positions; if (reverse) { positions = resourceManager.getReverseOrderPositions(); if (log.isDebugEnabled()) log.debug("executing phase on " + resourceManager.size() + " resource(s) enlisted in " + positions.size() + " position(s) in reverse position order"); } else { positions = resourceManager.getNaturalOrderPositions(); if (log.isDebugEnabled()) log.debug("executing phase on " + resourceManager.size() + " resource(s) enlisted in " + positions.size() + " position(s) in natural position order"); } List positionErrorReports = new ArrayList(); for (Integer positionKey : positions) { List resources; if (reverse) { resources = resourceManager.getReverseOrderResourcesForPosition(positionKey); } else { resources = resourceManager.getNaturalOrderResourcesForPosition(positionKey); } if (log.isDebugEnabled()) log.debug("running " + resources.size() + " job(s) for position '" + positionKey + "'"); JobsExecutionReport report = runJobsForPosition(resources); if (report.getExceptions().size() > 0) { if (log.isDebugEnabled()) log.debug(report.getExceptions().size() + " error(s) happened during execution of position '" + positionKey + "'"); positionErrorReports.add(report); break; } if (log.isDebugEnabled()) log.debug("ran " + resources.size() + " job(s) for position '" + positionKey + "'"); } if (positionErrorReports.size() > 0) { // merge all resources and exceptions lists List exceptions = new ArrayList(); List resources = new ArrayList(); for (JobsExecutionReport report : positionErrorReports) { exceptions.addAll(report.getExceptions()); resources.addAll(report.getResources()); } throw new PhaseException(exceptions, resources); } } private JobsExecutionReport runJobsForPosition(List resources) { List jobs = new ArrayList(); List exceptions = new ArrayList(); List errorResources = new ArrayList(); // start threads for (XAResourceHolderState resource : resources) { if (!isParticipating(resource)) { if (log.isDebugEnabled()) log.debug("skipping not participating resource " + resource); continue; } Job job = createJob(resource); Object future = executor.submit(job); job.setFuture(future); jobs.add(job); } // wait for threads to finish and check results for (Job job : jobs) { Object future = job.getFuture(); while (!executor.isDone(future)) { executor.waitFor(future, 1000L); } XAException xaException = job.getXAException(); RuntimeException runtimeException = job.getRuntimeException(); if (xaException != null) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(xaException); if (log.isDebugEnabled()) log.debug("error executing " + job + ", errorCode=" + Decoder.decodeXAExceptionErrorCode(xaException) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails)); exceptions.add(xaException); errorResources.add(job.getResource()); } else if (runtimeException != null) { if (log.isDebugEnabled()) log.debug("error executing " + job); exceptions.add(runtimeException); errorResources.add(job.getResource()); } } if (log.isDebugEnabled()) log.debug("phase executed with " + exceptions.size() + " exception(s)"); return new JobsExecutionReport(exceptions, errorResources); } /** * Determine if a resource is participating in the phase or not. A participating resource gets * a job created to execute the phase's command on it. * @param xaResourceHolderState the resource to check for its participation. * @return true if the resource must participate in the phase. */ protected abstract boolean isParticipating(XAResourceHolderState xaResourceHolderState); /** * Create a {@link Job} that is going to execute the phase command on the given resource. * @param xaResourceHolderState the resource that is going to receive a command. * @return the {@link Job} that is going to execute the command. */ protected abstract Job createJob(XAResourceHolderState xaResourceHolderState); /** * Log exceptions that happened during a phase failure. * @param ex the phase exception. */ protected void logFailedResources(PhaseException ex) { List exceptions = ex.getExceptions(); List resources = ex.getResourceStates(); for (int i = 0; i < exceptions.size(); i++) { Exception e = exceptions.get(i); XAResourceHolderState holderState = resources.get(i); log.error("resource " + holderState.getUniqueName() + " failed on " + holderState.getXid(), e); } } protected static Set collectResourcesUniqueNames(List resources) { Set uniqueNames = new HashSet(); for (XAResourceHolderState resourceHolderState : resources) { uniqueNames.add(resourceHolderState.getUniqueName()); } return uniqueNames; } protected static List collectNotInterestedResources(List allResources, List interestedResources) { List result = new ArrayList(); for (XAResourceHolderState resourceHolderState : allResources) { if (!CollectionUtils.containsByIdentity(interestedResources, resourceHolderState)) result.add(resourceHolderState); } return result; } private final static class JobsExecutionReport { private final List exceptions; private final List resources; private JobsExecutionReport(List exceptions, List resources) { this.exceptions = Collections.unmodifiableList(exceptions); this.resources = Collections.unmodifiableList(resources); } public List getExceptions() { return exceptions; } public List getResources() { return resources; } } } btm-dist-2.1.4/src/bitronix/tm/twopc/Rollbacker.java0000644000175000017500000002541312147207062021137 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc; import bitronix.tm.TransactionManagerServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import bitronix.tm.BitronixTransaction; import bitronix.tm.utils.Decoder; import bitronix.tm.twopc.executor.Executor; import bitronix.tm.twopc.executor.Job; import bitronix.tm.internal.*; import javax.transaction.Status; import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicCommitException; import javax.transaction.xa.XAException; import java.util.List; import java.util.ArrayList; import java.util.HashSet; import java.util.Collections; import java.util.Set; /** * Phase 1 & 2 Rollback logic engine. * * @author lorban */ public final class Rollbacker extends AbstractPhaseEngine { private final static Logger log = LoggerFactory.getLogger(Rollbacker.class); private final List interestedResources = Collections.synchronizedList(new ArrayList()); // this list has to be thread-safe as the RollbackJobs can be executed in parallel (when async 2PC is configured) private final List rolledbackResources = Collections.synchronizedList(new ArrayList()); public Rollbacker(Executor executor) { super(executor); } /** * Rollback the current XA transaction. Transaction will not timeout while changing status but rather by some * extra logic that will manually throw the exception after doing as much cleanup as possible. * * @param transaction the transaction to rollback. * @param interestedResources resources that should be rolled back. * @throws HeuristicCommitException when all resources committed instead. * @throws HeuristicMixedException when some resources committed and some rolled back. * @throws bitronix.tm.internal.BitronixSystemException when an internal error occured. */ public void rollback(BitronixTransaction transaction, List interestedResources) throws HeuristicMixedException, HeuristicCommitException, BitronixSystemException { XAResourceManager resourceManager = transaction.getResourceManager(); transaction.setStatus(Status.STATUS_ROLLING_BACK); this.interestedResources.clear(); this.interestedResources.addAll(interestedResources); try { executePhase(resourceManager, true); } catch (PhaseException ex) { logFailedResources(ex); transaction.setStatus(Status.STATUS_UNKNOWN); throwException("transaction failed during rollback of " + transaction, ex, interestedResources.size()); } if (log.isDebugEnabled()) log.debug("rollback executed on resources " + Decoder.collectResourcesNames(rolledbackResources)); // Some resources might have failed the 2nd phase of 2PC. // Only resources which successfully rolled back should be registered in the journal, the other // ones should be picked up by the recoverer. // Not interested resources have to be included as well since they returned XA_RDONLY and they // don't participate in phase 2: the TX succeded for them. Set rolledbackAndNotInterestedUniqueNames = new HashSet(); rolledbackAndNotInterestedUniqueNames.addAll(collectResourcesUniqueNames(rolledbackResources)); List notInterestedResources = collectNotInterestedResources(resourceManager.getAllResources(), interestedResources); rolledbackAndNotInterestedUniqueNames.addAll(collectResourcesUniqueNames(notInterestedResources)); if (log.isDebugEnabled()) { List rolledbackAndNotInterestedResources = new ArrayList(); rolledbackAndNotInterestedResources.addAll(rolledbackResources); rolledbackAndNotInterestedResources.addAll(notInterestedResources); log.debug("rollback succeeded on resources " + Decoder.collectResourcesNames(rolledbackAndNotInterestedResources)); } transaction.setStatus(Status.STATUS_ROLLEDBACK, rolledbackAndNotInterestedUniqueNames); } private void throwException(String message, PhaseException phaseException, int totalResourceCount) throws HeuristicMixedException, HeuristicCommitException { List exceptions = phaseException.getExceptions(); List resources = phaseException.getResourceStates(); boolean hazard = false; List heuristicResources = new ArrayList(); List errorResources = new ArrayList(); for (int i = 0; i < exceptions.size(); i++) { Exception ex = exceptions.get(i); XAResourceHolderState resourceHolder = resources.get(i); if (ex instanceof XAException) { XAException xaEx = (XAException) ex; switch (xaEx.errorCode) { case XAException.XA_HEURHAZ: hazard = true; case XAException.XA_HEURCOM: case XAException.XA_HEURRB: case XAException.XA_HEURMIX: heuristicResources.add(resourceHolder); break; default: errorResources.add(resourceHolder); } } else errorResources.add(resourceHolder); } if (!hazard && heuristicResources.size() == totalResourceCount) throw new BitronixHeuristicCommitException(message + ":" + " all resource(s) " + Decoder.collectResourcesNames(heuristicResources) + " improperly unilaterally committed", phaseException); else throw new BitronixHeuristicMixedException(message + ":" + (errorResources.size() > 0 ? " resource(s) " + Decoder.collectResourcesNames(errorResources) + " threw unexpected exception" : "") + (errorResources.size() > 0 && heuristicResources.size() > 0 ? " and" : "") + (heuristicResources.size() > 0 ? " resource(s) " + Decoder.collectResourcesNames(heuristicResources) + " improperly unilaterally committed" + (hazard ? " (or hazard happened)" : "") : ""), phaseException); } protected Job createJob(XAResourceHolderState resourceHolder) { return new RollbackJob(resourceHolder); } protected boolean isParticipating(XAResourceHolderState xaResourceHolderState) { for (XAResourceHolderState resourceHolderState : interestedResources) { if (xaResourceHolderState == resourceHolderState) return true; } return false; } private final class RollbackJob extends Job { public RollbackJob(XAResourceHolderState resourceHolder) { super(resourceHolder); } public void execute() { try { rollbackResource(getResource()); } catch (RuntimeException ex) { runtimeException = ex; } catch (XAException ex) { xaException = ex; } } private void rollbackResource(XAResourceHolderState resourceHolder) throws XAException { try { if (log.isDebugEnabled()) log.debug("trying to rollback resource " + resourceHolder); resourceHolder.getXAResource().rollback(resourceHolder.getXid()); rolledbackResources.add(resourceHolder); if (log.isDebugEnabled()) log.debug("rolled back resource " + resourceHolder); } catch (XAException ex) { handleXAException(resourceHolder, ex); } } private void handleXAException(XAResourceHolderState failedResourceHolder, XAException xaException) throws XAException { switch (xaException.errorCode) { case XAException.XA_HEURRB: forgetHeuristicRollback(failedResourceHolder); return; case XAException.XA_HEURCOM: case XAException.XA_HEURHAZ: case XAException.XA_HEURMIX: log.error("heuristic rollback is incompatible with the global state of this transaction - guilty: " + failedResourceHolder); throw xaException; default: String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(xaException); log.warn("resource '" + failedResourceHolder.getUniqueName() + "' reported " + Decoder.decodeXAExceptionErrorCode(xaException) + " when asked to rollback transaction branch. Transaction is prepared and will rollback via recovery service when resource availability allows." + (extraErrorDetails == null ? "" : " Extra error=" + extraErrorDetails), xaException); } } private void forgetHeuristicRollback(XAResourceHolderState resourceHolder) { try { if (log.isDebugEnabled()) log.debug("handling heuristic rollback on resource " + resourceHolder.getXAResource()); resourceHolder.getXAResource().forget(resourceHolder.getXid()); if (log.isDebugEnabled()) log.debug("forgotten heuristically rolled back resource " + resourceHolder.getXAResource()); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); log.error("cannot forget " + resourceHolder.getXid() + " assigned to " + resourceHolder.getXAResource() + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } public String toString() { return "a RollbackJob with " + getResource(); } } } btm-dist-2.1.4/src/bitronix/tm/twopc/PhaseException.java0000644000175000017500000000734612147207062022003 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc; import bitronix.tm.TransactionManagerServices; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.utils.Decoder; import javax.transaction.xa.XAException; import java.util.Collections; import java.util.List; /** * Thrown when a phase exection has thrown one or more exception(s). * * @author lorban */ public class PhaseException extends Exception { private final List exceptions; private final List resourceStates; public PhaseException(List exceptions, List resourceStates) { this.exceptions = Collections.unmodifiableList(exceptions); this.resourceStates = Collections.unmodifiableList(resourceStates); } public String getMessage() { StringBuilder errorMessage = new StringBuilder(); errorMessage.append("collected "); errorMessage.append(exceptions.size()); errorMessage.append(" exception(s):"); for (int i = 0; i < exceptions.size(); i++) { errorMessage.append(System.getProperty("line.separator")); Throwable throwable = exceptions.get(i); String message = throwable.getMessage(); XAResourceHolderState holderState = resourceStates.get(i); if (holderState != null) { errorMessage.append(" ["); errorMessage.append(holderState.getUniqueName()); errorMessage.append(" - "); } errorMessage.append(throwable.getClass().getName()); if (throwable instanceof XAException) { XAException xaEx = (XAException) throwable; errorMessage.append("("); errorMessage.append(Decoder.decodeXAExceptionErrorCode(xaEx)); String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(xaEx); if (extraErrorDetails != null) errorMessage.append(" - ").append(extraErrorDetails); errorMessage.append(")"); } errorMessage.append(" - "); errorMessage.append(message); errorMessage.append("]"); } return errorMessage.toString(); } /** * Get the list of exceptions that have been thrown during a phase execution. * @return the list of exceptions that have been thrown during a phase execution. */ public List getExceptions() { return exceptions; } /** * Get the list of resource which threw an exception during a phase execution. * This list always contains exactly one resource per exception present in {@link #getExceptions} list. * Indices of both list always match a resource against the exception it threw. * @return the list of resource which threw an exception during a phase execution. */ public List getResourceStates() { return resourceStates; } } btm-dist-2.1.4/src/bitronix/tm/twopc/Preparer.java0000644000175000017500000001564712147207062020647 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc; import bitronix.tm.BitronixTransaction; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.Decoder; import bitronix.tm.internal.*; import bitronix.tm.twopc.executor.Executor; import bitronix.tm.twopc.executor.Job; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.Status; import javax.transaction.RollbackException; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import java.util.*; /** * Phase 1 Prepare logic engine. * * @author lorban */ public final class Preparer extends AbstractPhaseEngine { private final static Logger log = LoggerFactory.getLogger(Preparer.class); // this list has to be thread-safe as the PrepareJobs can be executed in parallel (when async 2PC is configured) private final List preparedResources = Collections.synchronizedList(new ArrayList()); public Preparer(Executor executor) { super(executor); } /** * Execute phase 1 prepare. * @param transaction the transaction to prepare. * @return a list that will be filled with all resources that received the prepare command * and replied with {@link javax.transaction.xa.XAResource#XA_OK}. * @throws RollbackException when an error occured that can be fixed with a rollback. * @throws bitronix.tm.internal.BitronixSystemException when an internal error occured. */ public List prepare(BitronixTransaction transaction) throws RollbackException, BitronixSystemException { XAResourceManager resourceManager = transaction.getResourceManager(); transaction.setStatus(Status.STATUS_PREPARING); preparedResources.clear(); if (resourceManager.size() == 0) { if (TransactionManagerServices.getConfiguration().isWarnAboutZeroResourceTransaction()) log.warn("executing transaction with 0 enlisted resource"); else if (log.isDebugEnabled()) log.debug("0 resource enlisted, no prepare needed"); transaction.setStatus(Status.STATUS_PREPARED); return preparedResources; } // 1PC optimization if (resourceManager.size() == 1) { XAResourceHolderState resourceHolder = resourceManager.getAllResources().get(0); preparedResources.add(resourceHolder); if (log.isDebugEnabled()) log.debug("1 resource enlisted, no prepare needed (1PC)"); transaction.setStatus(Status.STATUS_PREPARED); return preparedResources; } try { executePhase(resourceManager, false); } catch (PhaseException ex) { logFailedResources(ex); throwException("transaction failed during prepare of " + transaction, ex); } transaction.setStatus(Status.STATUS_PREPARED); if (log.isDebugEnabled()) log.debug("successfully prepared " + preparedResources.size() + " resource(s)"); return Collections.unmodifiableList(preparedResources); } private void throwException(String message, PhaseException phaseException) throws BitronixRollbackException { List exceptions = phaseException.getExceptions(); List resources = phaseException.getResourceStates(); List heuristicResources = new ArrayList(); List errorResources = new ArrayList(); for (int i = 0; i < exceptions.size(); i++) { Exception ex = exceptions.get(i); XAResourceHolderState resourceHolder = resources.get(i); if (ex instanceof XAException) { XAException xaEx = (XAException) ex; /** * Sybase ASE can sometimes forget a transaction before prepare. For instance, when executing * a stored procedure that contains a rollback statement. In that case it throws XAException(XAER_NOTA) * when asked to prepare. */ if (xaEx.errorCode == XAException.XAER_NOTA) heuristicResources.add(resourceHolder); else errorResources.add(resourceHolder); } else errorResources.add(resourceHolder); } if (heuristicResources.size() > 0) throw new BitronixRollbackException(message + ":" + " resource(s) " + Decoder.collectResourcesNames(heuristicResources) + " unilaterally finished transaction branch before being asked to prepare", phaseException); else throw new BitronixRollbackException(message + ":" + " resource(s) " + Decoder.collectResourcesNames(errorResources) + " threw unexpected exception", phaseException); } protected Job createJob(XAResourceHolderState xaResourceHolderState) { return new PrepareJob(xaResourceHolderState); } protected boolean isParticipating(XAResourceHolderState xaResourceHolderState) { return true; } private final class PrepareJob extends Job { public PrepareJob(XAResourceHolderState resourceHolder) { super(resourceHolder); } public void execute() { try { XAResourceHolderState resourceHolder = getResource(); if (log.isDebugEnabled()) log.debug("preparing resource " + resourceHolder); int vote = resourceHolder.getXAResource().prepare(resourceHolder.getXid()); if (vote != XAResource.XA_RDONLY) { preparedResources.add(resourceHolder); } if (log.isDebugEnabled()) log.debug("prepared resource " + resourceHolder + " voted " + Decoder.decodePrepareVote(vote)); } catch (RuntimeException ex) { runtimeException = ex; } catch (XAException ex) { xaException = ex; } } public String toString() { return "a PrepareJob with " + getResource(); } } } btm-dist-2.1.4/src/bitronix/tm/twopc/Committer.java0000644000175000017500000003111712147207062021020 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc; import bitronix.tm.TransactionManagerServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import bitronix.tm.BitronixTransaction; import bitronix.tm.utils.Decoder; import bitronix.tm.twopc.executor.Executor; import bitronix.tm.twopc.executor.Job; import bitronix.tm.internal.*; import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicRollbackException; import javax.transaction.Status; import javax.transaction.xa.XAException; import java.util.List; import java.util.ArrayList; import java.util.HashSet; import java.util.Collections; import java.util.Set; /** * Phase 2 Commit logic engine. * * @author lorban */ public final class Committer extends AbstractPhaseEngine { private final static Logger log = LoggerFactory.getLogger(Committer.class); private volatile boolean onePhase; private final List interestedResources = Collections.synchronizedList(new ArrayList()); // this list has to be thread-safe as the CommitJobs can be executed in parallel (when async 2PC is configured) private final List committedResources = Collections.synchronizedList(new ArrayList()); public Committer(Executor executor) { super(executor); } /** * Execute phase 2 commit. * @param transaction the transaction wanting to commit phase 2 * @param interestedResources a map of phase 1 prepared resources wanting to participate in phase 2 using Xids as keys * @throws HeuristicRollbackException when all resources committed instead. * @throws HeuristicMixedException when some resources committed and some rolled back. * @throws bitronix.tm.internal.BitronixSystemException when an internal error occured. * @throws bitronix.tm.internal.BitronixRollbackException during 1PC when resource fails to commit */ public void commit(BitronixTransaction transaction, List interestedResources) throws HeuristicMixedException, HeuristicRollbackException, BitronixSystemException, BitronixRollbackException { XAResourceManager resourceManager = transaction.getResourceManager(); if (resourceManager.size() == 0) { transaction.setStatus(Status.STATUS_COMMITTING); //TODO: there is a disk force here that could be avoided transaction.setStatus(Status.STATUS_COMMITTED); if (log.isDebugEnabled()) log.debug("phase 2 commit succeeded with no interested resource"); return; } transaction.setStatus(Status.STATUS_COMMITTING); this.interestedResources.clear(); this.interestedResources.addAll(interestedResources); this.onePhase = resourceManager.size() == 1; try { executePhase(resourceManager, true); } catch (PhaseException ex) { logFailedResources(ex); if (onePhase) { transaction.setStatus(Status.STATUS_ROLLEDBACK); throw new BitronixRollbackException("transaction failed during 1PC commit of " + transaction, ex); } else { transaction.setStatus(Status.STATUS_UNKNOWN); throwException("transaction failed during commit of " + transaction, ex, interestedResources.size()); } } if (log.isDebugEnabled()) log.debug("phase 2 commit executed on resources " + Decoder.collectResourcesNames(committedResources)); // Some resources might have failed the 2nd phase of 2PC. // Only resources which successfully committed should be registered in the journal, the other // ones should be picked up by the recoverer. // Not interested resources have to be included as well since they returned XA_RDONLY and they // don't participate in phase 2: the TX succeded for them. Set committedAndNotInterestedUniqueNames = new HashSet(); committedAndNotInterestedUniqueNames.addAll(collectResourcesUniqueNames(committedResources)); List notInterestedResources = collectNotInterestedResources(resourceManager.getAllResources(), interestedResources); committedAndNotInterestedUniqueNames.addAll(collectResourcesUniqueNames(notInterestedResources)); if (log.isDebugEnabled()) { List committedAndNotInterestedResources = new ArrayList(); committedAndNotInterestedResources.addAll(committedResources); committedAndNotInterestedResources.addAll(notInterestedResources); log.debug("phase 2 commit succeeded on resources " + Decoder.collectResourcesNames(committedAndNotInterestedResources)); } transaction.setStatus(Status.STATUS_COMMITTED, committedAndNotInterestedUniqueNames); } private void throwException(String message, PhaseException phaseException, int totalResourceCount) throws HeuristicMixedException, HeuristicRollbackException { List exceptions = phaseException.getExceptions(); List resources = phaseException.getResourceStates(); boolean hazard = false; List heuristicResources = new ArrayList(); List errorResources = new ArrayList(); for (int i = 0; i < exceptions.size(); i++) { Exception ex = exceptions.get(i); XAResourceHolderState resourceHolder = resources.get(i); if (ex instanceof XAException) { XAException xaEx = (XAException) ex; switch (xaEx.errorCode) { case XAException.XA_HEURHAZ: hazard = true; case XAException.XA_HEURCOM: case XAException.XA_HEURRB: case XAException.XA_HEURMIX: heuristicResources.add(resourceHolder); break; default: errorResources.add(resourceHolder); } } else errorResources.add(resourceHolder); } if (!hazard && heuristicResources.size() == totalResourceCount) throw new BitronixHeuristicRollbackException(message + ":" + " all resource(s) " + Decoder.collectResourcesNames(heuristicResources) + " improperly unilaterally rolled back", phaseException); else throw new BitronixHeuristicMixedException(message + ":" + (errorResources.size() > 0 ? " resource(s) " + Decoder.collectResourcesNames(errorResources) + " threw unexpected exception" : "") + (errorResources.size() > 0 && heuristicResources.size() > 0 ? " and" : "") + (heuristicResources.size() > 0 ? " resource(s) " + Decoder.collectResourcesNames(heuristicResources) + " improperly unilaterally rolled back" + (hazard ? " (or hazard happened)" : "") : ""), phaseException); } protected Job createJob(XAResourceHolderState resourceHolder) { return new CommitJob(resourceHolder); } protected boolean isParticipating(XAResourceHolderState xaResourceHolderState) { for (XAResourceHolderState resourceHolderState : interestedResources) { if (xaResourceHolderState == resourceHolderState) return true; } return false; } private final class CommitJob extends Job { public CommitJob(XAResourceHolderState resourceHolder) { super(resourceHolder); } public XAException getXAException() { return xaException; } public RuntimeException getRuntimeException() { return runtimeException; } public void execute() { try { commitResource(getResource(), onePhase); } catch (RuntimeException ex) { runtimeException = ex; } catch (XAException ex) { xaException = ex; } } private void commitResource(XAResourceHolderState resourceHolder, boolean onePhase) throws XAException { try { if (log.isDebugEnabled()) log.debug("committing resource " + resourceHolder + (onePhase ? " (with one-phase optimization)" : "")); resourceHolder.getXAResource().commit(resourceHolder.getXid(), onePhase); committedResources.add(resourceHolder); if (log.isDebugEnabled()) log.debug("committed resource " + resourceHolder); } catch (XAException ex) { handleXAException(resourceHolder, ex, onePhase); } } private void handleXAException(XAResourceHolderState failedResourceHolder, XAException xaException, boolean onePhase) throws XAException { switch (xaException.errorCode) { case XAException.XA_HEURCOM: forgetHeuristicCommit(failedResourceHolder); return; case XAException.XAER_NOTA: throw new BitronixXAException("unknown heuristic termination, global state of this transaction is unknown - guilty: " + failedResourceHolder, XAException.XA_HEURHAZ, xaException); case XAException.XA_HEURHAZ: case XAException.XA_HEURMIX: case XAException.XA_HEURRB: case XAException.XA_RBCOMMFAIL: case XAException.XA_RBDEADLOCK: case XAException.XA_RBINTEGRITY: case XAException.XA_RBOTHER: case XAException.XA_RBPROTO: case XAException.XA_RBROLLBACK: case XAException.XA_RBTIMEOUT: case XAException.XA_RBTRANSIENT: log.error("heuristic rollback is incompatible with the global state of this transaction - guilty: " + failedResourceHolder); throw xaException; default: if (onePhase) { if (log.isDebugEnabled()) log.debug("XAException thrown in commit phase of 1PC optimization, rethrowing it"); throw xaException; } String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(xaException); log.warn("resource '" + failedResourceHolder.getUniqueName() + "' reported " + Decoder.decodeXAExceptionErrorCode(xaException) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + " when asked to commit transaction branch." + " Transaction is prepared and will commit via recovery service when resource availability allows.", xaException); } } private void forgetHeuristicCommit(XAResourceHolderState resourceHolder) { try { if (log.isDebugEnabled()) log.debug("handling heuristic commit on resource " + resourceHolder.getXAResource()); resourceHolder.getXAResource().forget(resourceHolder.getXid()); if (log.isDebugEnabled()) log.debug("forgotten heuristically committed resource " + resourceHolder.getXAResource()); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); log.error("cannot forget " + resourceHolder.getXid() + " assigned to " + resourceHolder.getXAResource() + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } public String toString() { return "a CommitJob " + (onePhase ? "(one phase) " : "") + "with " + getResource(); } } } btm-dist-2.1.4/src/bitronix/tm/Configuration.java0000644000175000017500000007640012147207062020534 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.utils.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.util.Properties; /** * Configuration repository of the transaction manager. You can set configurable values either via the properties file * or by setting properties of the {@link Configuration} object. * Once the transaction manager has started it is not possible to change the configuration: all calls to setters will * throw a {@link IllegalStateException}. *

The configuration filename must be specified with the bitronix.tm.configuration system property.

*

The default settings are good enough for running in a test environment but certainly not for production usage. * Also, all properties are reset to their default value after the transaction manager has shut down.

*

All those properties can refer to other defined ones or to system properties using the Ant notation: * ${some.property.name}.

* * @author lorban */ public class Configuration implements Service { private final static Logger log = LoggerFactory.getLogger(Configuration.class); private final static int MAX_SERVER_ID_LENGTH = 51; private volatile String serverId; private volatile byte[] serverIdArray; private volatile String logPart1Filename; private volatile String logPart2Filename; private volatile boolean forcedWriteEnabled; private volatile boolean forceBatchingEnabled; private volatile int maxLogSizeInMb; private volatile boolean filterLogStatus; private volatile boolean skipCorruptedLogs; private volatile boolean asynchronous2Pc; private volatile boolean warnAboutZeroResourceTransaction; private volatile boolean debugZeroResourceTransaction; private volatile int defaultTransactionTimeout; private volatile int gracefulShutdownInterval; private volatile int backgroundRecoveryIntervalSeconds; private volatile boolean disableJmx; private volatile String jndiUserTransactionName; private volatile String jndiTransactionSynchronizationRegistryName; private volatile String journal; private volatile String exceptionAnalyzer; private volatile boolean currentNodeOnlyRecovery; private volatile boolean allowMultipleLrc; private volatile String resourceConfigurationFilename; protected Configuration() { try { InputStream in = null; Properties properties; try { String configurationFilename = System.getProperty("bitronix.tm.configuration"); if (configurationFilename != null) { if (log.isDebugEnabled()) log.debug("loading configuration file " + configurationFilename); in = new FileInputStream(configurationFilename); } else { if (log.isDebugEnabled()) log.debug("loading default configuration"); in = ClassLoaderUtils.getResourceAsStream("bitronix-default-config.properties"); } properties = new Properties(); if (in != null) properties.load(in); else if (log.isDebugEnabled()) log.debug("no configuration file found, using default settings"); } finally { if (in != null) in.close(); } serverId = getString(properties, "bitronix.tm.serverId", null); logPart1Filename = getString(properties, "bitronix.tm.journal.disk.logPart1Filename", "btm1.tlog"); logPart2Filename = getString(properties, "bitronix.tm.journal.disk.logPart2Filename", "btm2.tlog"); forcedWriteEnabled = getBoolean(properties, "bitronix.tm.journal.disk.forcedWriteEnabled", true); forceBatchingEnabled = getBoolean(properties, "bitronix.tm.journal.disk.forceBatchingEnabled", true); maxLogSizeInMb = getInt(properties, "bitronix.tm.journal.disk.maxLogSize", 2); filterLogStatus = getBoolean(properties, "bitronix.tm.journal.disk.filterLogStatus", false); skipCorruptedLogs = getBoolean(properties, "bitronix.tm.journal.disk.skipCorruptedLogs", false); asynchronous2Pc = getBoolean(properties, "bitronix.tm.2pc.async", false); warnAboutZeroResourceTransaction = getBoolean(properties, "bitronix.tm.2pc.warnAboutZeroResourceTransactions", true); debugZeroResourceTransaction = getBoolean(properties, "bitronix.tm.2pc.debugZeroResourceTransactions", false); defaultTransactionTimeout = getInt(properties, "bitronix.tm.timer.defaultTransactionTimeout", 60); gracefulShutdownInterval = getInt(properties, "bitronix.tm.timer.gracefulShutdownInterval", 60); backgroundRecoveryIntervalSeconds = getInt(properties, "bitronix.tm.timer.backgroundRecoveryIntervalSeconds", 60); disableJmx = getBoolean(properties, "bitronix.tm.disableJmx", false); jndiUserTransactionName = getString(properties, "bitronix.tm.jndi.userTransactionName", "java:comp/UserTransaction"); jndiTransactionSynchronizationRegistryName = getString(properties, "bitronix.tm.jndi.transactionSynchronizationRegistryName", "java:comp/TransactionSynchronizationRegistry"); journal = getString(properties, "bitronix.tm.journal", "disk"); exceptionAnalyzer = getString(properties, "bitronix.tm.exceptionAnalyzer", null); currentNodeOnlyRecovery = getBoolean(properties, "bitronix.tm.currentNodeOnlyRecovery", true); allowMultipleLrc = getBoolean(properties, "bitronix.tm.allowMultipleLrc", false); resourceConfigurationFilename = getString(properties, "bitronix.tm.resource.configuration", null); } catch (IOException ex) { throw new InitializationException("error loading configuration", ex); } } /** * ASCII ID that must uniquely identify this TM instance. It must not exceed 51 characters or it will be truncated. *

Property name:
bitronix.tm.serverId - (defaults to server's IP address but that's unsafe for * production use)

* @return the unique ID of this TM instance. */ public String getServerId() { return serverId; } /** * Set the ASCII ID that must uniquely identify this TM instance. It must not exceed 51 characters or it will be * truncated. * @see #getServerId() * @param serverId the unique ID of this TM instance. * @return this. */ public Configuration setServerId(String serverId) { checkNotStarted(); this.serverId = serverId; return this; } /** * Get the journal fragment file 1 name. *

Property name:
bitronix.tm.journal.disk.logPart1Filename - (defaults to btm1.tlog)

* @return the journal fragment file 1 name. */ public String getLogPart1Filename() { return logPart1Filename; } /** * Set the journal fragment file 1 name. * @see #getLogPart1Filename() * @param logPart1Filename the journal fragment file 1 name. * @return this. */ public Configuration setLogPart1Filename(String logPart1Filename) { checkNotStarted(); this.logPart1Filename = logPart1Filename; return this; } /** * Get the journal fragment file 2 name. *

Property name:
bitronix.tm.journal.disk.logPart2Filename - (defaults to btm2.tlog)

* @return the journal fragment file 2 name. */ public String getLogPart2Filename() { return logPart2Filename; } /** * Set the journal fragment file 2 name. * @see #getLogPart2Filename() * @param logPart2Filename the journal fragment file 2 name. * @return this. */ public Configuration setLogPart2Filename(String logPart2Filename) { checkNotStarted(); this.logPart2Filename = logPart2Filename; return this; } /** * Are logs forced to disk? Do not set to false in production since without disk force, integrity is not * guaranteed. *

Property name:
bitronix.tm.journal.disk.forcedWriteEnabled - (defaults to true)

* @return true if logs are forced to disk, false otherwise. */ public boolean isForcedWriteEnabled() { return forcedWriteEnabled; } /** * Set if logs are forced to disk. Do not set to false in production since without disk force, integrity is not * guaranteed. * @see #isForcedWriteEnabled() * @param forcedWriteEnabled true if logs should be forced to disk, false otherwise. * @return this. */ public Configuration setForcedWriteEnabled(boolean forcedWriteEnabled) { checkNotStarted(); this.forcedWriteEnabled = forcedWriteEnabled; return this; } /** * Are disk forces batched? Disabling batching can seriously lower the transaction manager's throughput. *

Property name:
bitronix.tm.journal.disk.forceBatchingEnabled - (defaults to true)

* @return true if disk forces are batched, false otherwise. */ public boolean isForceBatchingEnabled() { return forceBatchingEnabled; } /** * Set if disk forces are batched. Disabling batching can seriously lower the transaction manager's throughput. * @see #isForceBatchingEnabled() * @param forceBatchingEnabled true if disk forces are batched, false otherwise. * @return this. */ public Configuration setForceBatchingEnabled(boolean forceBatchingEnabled) { checkNotStarted(); this.forceBatchingEnabled = forceBatchingEnabled; return this; } /** * Maximum size in megabytes of the journal fragments. Larger logs allow transactions to stay longer in-doubt but * the TM pauses longer when a fragment is full. *

Property name:
bitronix.tm.journal.disk.maxLogSize - (defaults to 2)

* @return the maximum size in megabytes of the journal fragments. */ public int getMaxLogSizeInMb() { return maxLogSizeInMb; } /** * Set the Maximum size in megabytes of the journal fragments. Larger logs allow transactions to stay longer * in-doubt but the TM pauses longer when a fragment is full. * @see #getMaxLogSizeInMb() * @param maxLogSizeInMb the maximum size in megabytes of the journal fragments. * @return this. */ public Configuration setMaxLogSizeInMb(int maxLogSizeInMb) { checkNotStarted(); this.maxLogSizeInMb = maxLogSizeInMb; return this; } /** * Should only mandatory logs be written? Enabling this parameter lowers space usage of the fragments but makes * debugging more complex. *

Property name:
bitronix.tm.journal.disk.filterLogStatus - (defaults to false)

* @return true if only mandatory logs should be written. */ public boolean isFilterLogStatus() { return filterLogStatus; } /** * Set if only mandatory logs should be written. Enabling this parameter lowers space usage of the fragments but * makes debugging more complex. * @see #isFilterLogStatus() * @param filterLogStatus true if only mandatory logs should be written. * @return this. */ public Configuration setFilterLogStatus(boolean filterLogStatus) { checkNotStarted(); this.filterLogStatus = filterLogStatus; return this; } /** * Should corrupted logs be skipped? *

Property name:
bitronix.tm.journal.disk.skipCorruptedLogs - (defaults to false)

* @return true if corrupted logs should be skipped. */ public boolean isSkipCorruptedLogs() { return skipCorruptedLogs; } /** * Set if corrupted logs should be skipped. * @see #isSkipCorruptedLogs() * @param skipCorruptedLogs true if corrupted logs should be skipped. * @return this. */ public Configuration setSkipCorruptedLogs(boolean skipCorruptedLogs) { checkNotStarted(); this.skipCorruptedLogs = skipCorruptedLogs; return this; } /** * Should two phase commit be executed asynchronously? Asynchronous two phase commit can improve performance when * there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread spawning * requirements. It also makes debugging more complex. *

Property name:
bitronix.tm.2pc.async - (defaults to false)

* @return true if two phase commit should be executed asynchronously. */ public boolean isAsynchronous2Pc() { return asynchronous2Pc; } /** * Set if two phase commit should be executed asynchronously. Asynchronous two phase commit can improve performance * when there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread * spawning requirements. It also makes debugging more complex. * @see #isAsynchronous2Pc() * @param asynchronous2Pc true if two phase commit should be executed asynchronously. * @return this. */ public Configuration setAsynchronous2Pc(boolean asynchronous2Pc) { checkNotStarted(); this.asynchronous2Pc = asynchronous2Pc; return this; } /** * Should transactions executed without a single enlisted resource result in a warning or not? Most of the time * transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere. *

Property name:
bitronix.tm.2pc.warnAboutZeroResourceTransactions - (defaults to true)

* @return true if transactions executed without a single enlisted resource should result in a warning. */ public boolean isWarnAboutZeroResourceTransaction() { return warnAboutZeroResourceTransaction; } /** * Set if transactions executed without a single enlisted resource should result in a warning or not. Most of the * time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere. * @see #isWarnAboutZeroResourceTransaction() * @param warnAboutZeroResourceTransaction true if transactions executed without a single enlisted resource should * result in a warning. * @return this. */ public Configuration setWarnAboutZeroResourceTransaction(boolean warnAboutZeroResourceTransaction) { checkNotStarted(); this.warnAboutZeroResourceTransaction = warnAboutZeroResourceTransaction; return this; } /** * Should creation and commit call stacks of transactions executed without a single enlisted tracked and logged * or not? *

Property name:
bitronix.tm.2pc.debugZeroResourceTransactions - (defaults to false)

* @return true if creation and commit call stacks of transactions executed without a single enlisted resource * should be tracked and logged. */ public boolean isDebugZeroResourceTransaction() { return debugZeroResourceTransaction; } /** * Set if creation and commit call stacks of transactions executed without a single enlisted resource should be * tracked and logged. * @see #isDebugZeroResourceTransaction() * @see #isWarnAboutZeroResourceTransaction() * @param debugZeroResourceTransaction true if the creation and commit call stacks of transaction executed without * a single enlisted resource should be tracked and logged. * @return this. */ public Configuration setDebugZeroResourceTransaction(boolean debugZeroResourceTransaction) { checkNotStarted(); this.debugZeroResourceTransaction = debugZeroResourceTransaction; return this; } /** * Default transaction timeout in seconds. *

Property name:
bitronix.tm.timer.defaultTransactionTimeout - (defaults to 60)

* @return the default transaction timeout in seconds. */ public int getDefaultTransactionTimeout() { return defaultTransactionTimeout; } /** * Set the default transaction timeout in seconds. * @see #getDefaultTransactionTimeout() * @param defaultTransactionTimeout the default transaction timeout in seconds. * @return this. */ public Configuration setDefaultTransactionTimeout(int defaultTransactionTimeout) { checkNotStarted(); this.defaultTransactionTimeout = defaultTransactionTimeout; return this; } /** * Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time. *

Property name:
bitronix.tm.timer.gracefulShutdownInterval - (defaults to 60)

* @return the maximum amount of time in seconds. */ public int getGracefulShutdownInterval() { return gracefulShutdownInterval; } /** * Set the maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown * time. * @see #getGracefulShutdownInterval() * @param gracefulShutdownInterval the maximum amount of time in seconds. * @return this. */ public Configuration setGracefulShutdownInterval(int gracefulShutdownInterval) { checkNotStarted(); this.gracefulShutdownInterval = gracefulShutdownInterval; return this; } /** * Interval in minutes at which to run the recovery process in the background. Disabled when set to 0. *

Property name:
bitronix.tm.timer.backgroundRecoveryInterval - (defaults to 0)

* @return the interval in minutes. * @deprecated superceded by #getBackgroundRecoveryIntervalSeconds(). */ public int getBackgroundRecoveryInterval() { return getBackgroundRecoveryIntervalSeconds() / 60; } /** * Set the interval in minutes at which to run the recovery process in the background. Disabled when set to 0. * @see #getBackgroundRecoveryInterval() * @param backgroundRecoveryInterval the interval in minutes. * @deprecated superceded by #setBackgroundRecoveryIntervalSeconds(int). * @return this. */ public Configuration setBackgroundRecoveryInterval(int backgroundRecoveryInterval) { log.warn("setBackgroundRecoveryInterval() is deprecated, consider using setBackgroundRecoveryIntervalSeconds() instead."); setBackgroundRecoveryIntervalSeconds(backgroundRecoveryInterval * 60); return this; } /** * Interval in seconds at which to run the recovery process in the background. Disabled when set to 0. *

Property name:
bitronix.tm.timer.backgroundRecoveryIntervalSeconds - (defaults to 60)

* @return the interval in seconds. */ public int getBackgroundRecoveryIntervalSeconds() { return backgroundRecoveryIntervalSeconds; } /** * Set the interval in seconds at which to run the recovery process in the background. Disabled when set to 0. * @see #getBackgroundRecoveryIntervalSeconds() * @param backgroundRecoveryIntervalSeconds the interval in minutes. * @return this. */ public Configuration setBackgroundRecoveryIntervalSeconds(int backgroundRecoveryIntervalSeconds) { checkNotStarted(); this.backgroundRecoveryIntervalSeconds = backgroundRecoveryIntervalSeconds; return this; } /** * Should JMX Mbeans not be registered even if a JMX MBean server is detected? *

Property name:
bitronix.tm.disableJmx - (defaults to false)

* @return true if JMX MBeans should never be registered. */ public boolean isDisableJmx() { return disableJmx; } /** * Set to true if JMX Mbeans should not be registered even if a JMX MBean server is detected. * @see #isDisableJmx() * @param disableJmx true if JMX MBeans should never be registered. * @return this. */ public Configuration setDisableJmx(boolean disableJmx) { checkNotStarted(); this.disableJmx = disableJmx; return this; } /** * Get the name the {@link javax.transaction.UserTransaction} should be bound under in the * {@link bitronix.tm.jndi.BitronixContext}. * @return the name the {@link javax.transaction.UserTransaction} should * be bound under in the {@link bitronix.tm.jndi.BitronixContext}. */ public String getJndiUserTransactionName() { return jndiUserTransactionName; } /** * Set the name the {@link javax.transaction.UserTransaction} should be bound under in the * {@link bitronix.tm.jndi.BitronixContext}. * @see #getJndiUserTransactionName() * @param jndiUserTransactionName the name the {@link javax.transaction.UserTransaction} should * be bound under in the {@link bitronix.tm.jndi.BitronixContext}. * @return this. */ public Configuration setJndiUserTransactionName(String jndiUserTransactionName) { checkNotStarted(); this.jndiUserTransactionName = jndiUserTransactionName; return this; } /** * Get the name the {@link javax.transaction.TransactionSynchronizationRegistry} should be bound under in the * {@link bitronix.tm.jndi.BitronixContext}. * @return the name the {@link javax.transaction.TransactionSynchronizationRegistry} should * be bound under in the {@link bitronix.tm.jndi.BitronixContext}. */ public String getJndiTransactionSynchronizationRegistryName() { return jndiTransactionSynchronizationRegistryName; } /** * Set the name the {@link javax.transaction.TransactionSynchronizationRegistry} should be bound under in the * {@link bitronix.tm.jndi.BitronixContext}. * @see #getJndiUserTransactionName() * @param jndiTransactionSynchronizationRegistryName the name the {@link javax.transaction.TransactionSynchronizationRegistry} should * be bound under in the {@link bitronix.tm.jndi.BitronixContext}. * @return this. */ public Configuration setJndiTransactionSynchronizationRegistryName(String jndiTransactionSynchronizationRegistryName) { checkNotStarted(); this.jndiTransactionSynchronizationRegistryName = jndiTransactionSynchronizationRegistryName; return this; } /** * Get the journal implementation. Can be disk, null or a class name. * @return the journal name. */ public String getJournal() { return journal; } /** * Set the journal name. Can be disk, null or a class name. * @see #getJournal() * @param journal the journal name. * @return this. */ public Configuration setJournal(String journal) { checkNotStarted(); this.journal = journal; return this; } /** * Get the exception analyzer implementation. Can be null for the default one or a class name. * @return the exception analyzer name. */ public String getExceptionAnalyzer() { return exceptionAnalyzer; } /** * Set the exception analyzer implementation. Can be null for the default one or a class name. * @see #getExceptionAnalyzer() * @param exceptionAnalyzer the exception analyzer name. * @return this. */ public Configuration setExceptionAnalyzer(String exceptionAnalyzer) { checkNotStarted(); this.exceptionAnalyzer = exceptionAnalyzer; return this; } /** * Should the recovery process not recover XIDs generated with another JVM unique ID? Setting this property to true * is useful in clustered environments where multiple instances of BTM are running on different nodes. * @see #getServerId() contains the value used as the JVM unique ID. * @return true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise. */ public boolean isCurrentNodeOnlyRecovery() { return currentNodeOnlyRecovery; } /** * Set to true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise. * @see #isCurrentNodeOnlyRecovery() * @param currentNodeOnlyRecovery true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise. * @return this. */ public Configuration setCurrentNodeOnlyRecovery(boolean currentNodeOnlyRecovery) { checkNotStarted(); this.currentNodeOnlyRecovery = currentNodeOnlyRecovery; return this; } /** * Should the transaction manager allow enlistment of multiple LRC resources in a single transaction? * This is highly unsafe but could be useful for testing. * @return true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction, false otherwise. */ public boolean isAllowMultipleLrc() { return allowMultipleLrc; } /** * Set to true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction. * @param allowMultipleLrc true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction, false otherwise. * @return this */ public Configuration setAllowMultipleLrc(boolean allowMultipleLrc) { checkNotStarted(); this.allowMultipleLrc = allowMultipleLrc; return this; } /** * {@link bitronix.tm.resource.ResourceLoader} configuration file name. {@link bitronix.tm.resource.ResourceLoader} * will be disabled if this value is null. *

Property name:
bitronix.tm.resource.configuration - (defaults to null)

* @return the filename of the resources configuration file or null if not configured. */ public String getResourceConfigurationFilename() { return resourceConfigurationFilename; } /** * Set the {@link bitronix.tm.resource.ResourceLoader} configuration file name. * @see #getResourceConfigurationFilename() * @param resourceConfigurationFilename the filename of the resources configuration file or null you do not want to * use the {@link bitronix.tm.resource.ResourceLoader}. * @return this. */ public Configuration setResourceConfigurationFilename(String resourceConfigurationFilename) { checkNotStarted(); this.resourceConfigurationFilename = resourceConfigurationFilename; return this; } /** * Build the server ID byte array that will be prepended in generated UIDs. Once built, the value is cached for * the duration of the JVM lifespan. * @return the server ID. */ public byte[] buildServerIdArray() { if (serverIdArray == null) { try { serverIdArray = serverId.substring(0, Math.min(serverId.length(), MAX_SERVER_ID_LENGTH)).getBytes("US-ASCII"); } catch (Exception ex) { log.warn("cannot get this JVM unique ID. Make sure it is configured and you only use ASCII characters. Will use IP address instead (unsafe for production usage!)."); try { serverIdArray = InetAddress.getLocalHost().getHostAddress().getBytes("US-ASCII"); } catch (Exception ex2) { final String unknownServerId = "unknown-server-id"; log.warn("cannot get the local IP address. Will replace it with '" + unknownServerId + "' constant (highly unsafe!)."); serverIdArray = unknownServerId.getBytes(); } } if (serverIdArray.length > MAX_SERVER_ID_LENGTH) { byte[] truncatedServerId = new byte[MAX_SERVER_ID_LENGTH]; System.arraycopy(serverIdArray, 0, truncatedServerId, 0, MAX_SERVER_ID_LENGTH); serverIdArray = truncatedServerId; } String serverIdArrayAsString = new String(serverIdArray); if (serverId == null) serverId = serverIdArrayAsString; log.info("JVM unique ID: <" + serverIdArrayAsString + ">"); } return serverIdArray; } public void shutdown() { serverIdArray = null; } public String toString() { StringBuilder sb = new StringBuilder(512); sb.append("a Configuration with ["); try { sb.append(PropertyUtils.propertiesToString(this)); } catch (PropertyException ex) { sb.append("???"); if (log.isDebugEnabled()) log.debug("error accessing properties of Configuration object", ex); } sb.append("]"); return sb.toString(); } /* * Internal implementation */ private void checkNotStarted() { if (TransactionManagerServices.isTransactionManagerRunning()) throw new IllegalStateException("cannot change the configuration while the transaction manager is running"); } static String getString(Properties properties, String key, String defaultValue) { String value = System.getProperty(key); if (value == null) { value = properties.getProperty(key); if (value == null) return defaultValue; } return evaluate(properties, value); } static boolean getBoolean(Properties properties, String key, boolean defaultValue) { return Boolean.valueOf(getString(properties, key, "" + defaultValue)); } static int getInt(Properties properties, String key, int defaultValue) { return Integer.parseInt(getString(properties, key, "" + defaultValue)); } private static String evaluate(Properties properties, String value) { String result = value; int startIndex = value.indexOf('$'); if (startIndex > -1 && value.length() > startIndex +1 && value.charAt(startIndex +1) == '{') { int endIndex = value.indexOf('}'); if (startIndex +2 == endIndex) throw new IllegalArgumentException("property ref cannot refer to an empty name: ${}"); if (endIndex == -1) throw new IllegalArgumentException("unclosed property ref: ${" + value.substring(startIndex +2)); String subPropertyKey = value.substring(startIndex +2, endIndex); String subPropertyValue = getString(properties, subPropertyKey, null); result = result.substring(0, startIndex) + subPropertyValue + result.substring(endIndex +1); return evaluate(properties, result); } return result; } } btm-dist-2.1.4/src/bitronix/tm/gui/0000755000175000017500000000000012147207062015637 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/gui/package.html0000644000175000017500000000011712147207062020117 0ustar tonytony

GUI admin console.

btm-dist-2.1.4/src/bitronix/tm/gui/DuplicatedGtridTableModel.java0000644000175000017500000000505312147207062023506 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.journal.TransactionLogRecord; import javax.swing.table.DefaultTableModel; import java.util.Iterator; import java.util.List; import java.util.Map; /** *

* * @author lorban */ public class DuplicatedGtridTableModel extends DefaultTableModel { private Map duplicatedGtrids; public DuplicatedGtridTableModel(Map map) { super(map.size(), 2); this.duplicatedGtrids = map; } public String getColumnName(int column) { switch (column) { case 0: return "Sequence number"; case 1: return "GTRID"; default: return "?"; } } public Object getValueAt(int row, int column) { Iterator it = duplicatedGtrids.entrySet().iterator(); List tlogs = null; int i=0; while (i<=row && it.hasNext()) { i++; Map.Entry entry = (Map.Entry) it.next(); tlogs = (List) entry.getValue(); } if (tlogs == null) return null; switch (column) { case 0: return buildTlogsSequenceNumber(tlogs); case 1: return buildTlogsGtrid(tlogs); default: return "?"; } } private String buildTlogsSequenceNumber(List tlogs) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < tlogs.size(); i++) { TransactionLogRecord tlog = (TransactionLogRecord) tlogs.get(i); sb.append(tlog.getSequenceNumber()); if (i < tlogs.size() -1) sb.append(", "); } return sb.toString(); } private String buildTlogsGtrid(List tlogs) { TransactionLogRecord tlog = (TransactionLogRecord) tlogs.get(0); return tlog.getGtrid().toString(); } } btm-dist-2.1.4/src/bitronix/tm/gui/TransactionTableModel.java0000644000175000017500000000413212147207062022720 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.journal.TransactionLogCursor; import bitronix.tm.journal.TransactionLogRecord; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import javax.swing.table.TableModel; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** *

* * @author lorban */ public abstract class TransactionTableModel implements TableModel { private final static Logger log = LoggerFactory.getLogger(TransactionTableModel.class); protected List tLogs = new ArrayList(); protected void readFullTransactionLog(File filename) throws IOException { TransactionLogCursor tlis = new TransactionLogCursor(filename); int count=0; try { while (true) { TransactionLogRecord tlog = tlis.readLog(true); if (tlog == null) break; if (!acceptLog(tlog)) continue; tLogs.add(tlog); count++; } } finally { tlis.close(); if (log.isDebugEnabled()) log.debug("read " + count + " transaction logs"); } } public abstract boolean acceptLog(TransactionLogRecord tlog); public abstract TransactionLogRecord getRow(int row); } btm-dist-2.1.4/src/bitronix/tm/gui/TransactionLogDialog.java0000644000175000017500000001124412147207062022553 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.utils.Decoder; import bitronix.tm.journal.TransactionLogRecord; import javax.swing.*; import java.awt.*; import java.util.Date; import java.util.Set; import java.util.Iterator; /** *

* * @author lorban */ public class TransactionLogDialog extends JDialog { private JPanel labelPanel = new JPanel(); private JLabel statusLabel = new JLabel("Status"); private JLabel recordLengthLabel = new JLabel("Record length"); private JLabel headerLengthLabel = new JLabel("Header length"); private JLabel timeLabel = new JLabel("Time"); private JLabel sequenceNumberLabel = new JLabel("Sequence number"); private JLabel crc32Label = new JLabel("CRC"); private JLabel gtridLabel = new JLabel("GTRID"); private JLabel uniqueNamesLabel = new JLabel("Resources"); private JPanel fieldPanel = new JPanel(); private JTextField statusField = new JTextField(); private JTextField recordLengthField = new JTextField(); private JTextField headerLengthField = new JTextField(); private JTextField timeField = new JTextField(); private JTextField sequenceNumberField = new JTextField(); private JTextField crc32Field = new JTextField(); private JTextField gtridField = new JTextField(); private JTextField uniqueNamesField = new JTextField(); public TransactionLogDialog(JFrame frame, TransactionLogRecord tlog) { super(frame, "Transaction log details", true); statusField.setText(Decoder.decodeStatus(tlog.getStatus())); recordLengthField.setText(""+tlog.getRecordLength()); headerLengthField.setText(""+tlog.getHeaderLength()); timeField.setText(Console.dateFormatter.format(new Date(tlog.getTime()))); sequenceNumberField.setText(""+tlog.getSequenceNumber()); if (tlog.isCrc32Correct()) { crc32Field.setText(""+tlog.getCrc32()); } else { crc32Field.setText(tlog.getCrc32() + " (should be: " + tlog.calculateCrc32() + ")"); crc32Field.setBackground(Color.RED); } gtridField.setText(tlog.getGtrid().toString()); uniqueNamesField.setText(buildString(tlog.getUniqueNames())); statusField.setEditable(false); recordLengthField.setEditable(false); headerLengthField.setEditable(false); timeField.setEditable(false); sequenceNumberField.setEditable(false); crc32Field.setEditable(false); gtridField.setEditable(false); uniqueNamesField.setEditable(false); labelPanel.add(statusLabel); fieldPanel.add(statusField); labelPanel.add(recordLengthLabel); fieldPanel.add(recordLengthField); labelPanel.add(headerLengthLabel); fieldPanel.add(headerLengthField); labelPanel.add(timeLabel); fieldPanel.add(timeField); labelPanel.add(sequenceNumberLabel); fieldPanel.add(sequenceNumberField); labelPanel.add(crc32Label); fieldPanel.add(crc32Field); labelPanel.add(gtridLabel); fieldPanel.add(gtridField); labelPanel.add(uniqueNamesLabel); fieldPanel.add(uniqueNamesField); labelPanel.setLayout(new GridLayout(8, 1)); fieldPanel.setLayout(new GridLayout(8, 1)); getContentPane().add(labelPanel); getContentPane().add(fieldPanel); getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS)); pack(); int xPos = (frame.getBounds().width - 600) / 2; int yPos = (frame.getBounds().height - getSize().height) / 2; setBounds(xPos, yPos, 600, getSize().height); } private String buildString(Set uniqueNames) { StringBuffer sb = new StringBuffer(); Iterator it = uniqueNames.iterator(); while (it.hasNext()) { Object o = it.next(); sb.append(o); if (it.hasNext()) sb.append(", "); } return sb.toString(); } } btm-dist-2.1.4/src/bitronix/tm/gui/RawTransactionTableModel.java0000644000175000017500000001052312147207062023373 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.utils.Decoder; import bitronix.tm.journal.TransactionLogRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.event.TableModelListener; import java.io.File; import java.util.Date; import java.util.List; import java.util.ArrayList; /** *

* * @author lorban */ public class RawTransactionTableModel extends TransactionTableModel { private List displayedRows; private final static Logger log = LoggerFactory.getLogger(RawTransactionTableModel.class); public static final int GTRID_COL = 7; public RawTransactionTableModel(File filename) { try { readFullTransactionLog(filename); } catch (Exception ex) { log.error("corrupted log file", ex); } displayedRows = new ArrayList(tLogs); } public int getColumnCount() { return 8; } public int getRowCount() { return displayedRows.size(); } public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } public Class getColumnClass(int columnIndex) { return String.class; } public Object getValueAt(int rowIndex, int columnIndex) { TransactionLogRecord tlog = (TransactionLogRecord) displayedRows.get(rowIndex); switch (columnIndex) { case 0: return Decoder.decodeStatus(tlog.getStatus()); case 1: return "" + tlog.getRecordLength(); case 2: return "" + tlog.getHeaderLength(); case 3: return Console.dateFormatter.format(new Date(tlog.getTime())); case 4: return "" + tlog.getSequenceNumber(); case 5: return "" + tlog.getCrc32(); case 6: return "" + tlog.getUniqueNames().size(); case 7: return tlog.getGtrid().toString(); default: return null; } } public void setValueAt(Object aValue, int rowIndex, int columnIndex) { } public String getColumnName(int columnIndex) { switch (columnIndex) { case 0: return "Record Status"; case 1: return "Record length"; case 2: return "Header length"; case 3: return "Record time"; case 4: return "Record sequence number"; case 5: return "CRC"; case 6: return "Resources"; case 7: return "GTRID"; default: return null; } } public void addTableModelListener(TableModelListener l) { } public void removeTableModelListener(TableModelListener l) { } public boolean acceptLog(TransactionLogRecord tlog) { return true; } public TransactionLogRecord getRow(int row) { return (TransactionLogRecord) displayedRows.get(row); } public void filterByGtrid(String gtrid) { if (gtrid == null) { displayedRows = new ArrayList(tLogs); } else { List newDis = new ArrayList(); for (int i = 0; i < displayedRows.size(); i++) { TransactionLogRecord transactionLogRecord = (TransactionLogRecord) displayedRows.get(i); if (transactionLogRecord.getGtrid().toString().equals(gtrid)) newDis.add(transactionLogRecord); } displayedRows = newDis; } } } btm-dist-2.1.4/src/bitronix/tm/gui/Console.java0000644000175000017500000004572412147207062020120 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.BitronixXid; import bitronix.tm.Configuration; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.Uid; import bitronix.tm.journal.TransactionLogRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import javax.swing.border.EtchedBorder; import javax.transaction.Status; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; /** *

* * @author lorban */ public class Console extends JFrame { private final static Logger log = LoggerFactory.getLogger(Console.class); protected static final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS"); private JTabbedPane tabbedPane = new JTabbedPane(); private JTable rawViewTransactionsTable = new JTable(); private JTable pendingViewTransactionsTable = new JTable(); private JScrollPane rawTransactionsTableScrollpane = new JScrollPane(rawViewTransactionsTable); private JScrollPane pendingTransactionsTableScrollpane = new JScrollPane(pendingViewTransactionsTable); private ResourcesPanel resourcesPanel = new ResourcesPanel(); private JPanel statusBarPanel = new JPanel(); private JLabel statusLabel = new JLabel(); private TransactionLogHeaderPanel transactionLogHeaderPanel1 = new TransactionLogHeaderPanel(); private TransactionLogHeaderPanel transactionLogHeaderPanel2 = new TransactionLogHeaderPanel(); private JMenuBar menuBar = new JMenuBar(); public Console() throws IOException { final Configuration configuration = TransactionManagerServices.getConfiguration(); JMenu findMenu = new JMenu("Find"); menuBar.add(findMenu); JMenuItem bySequenceItem = new JMenuItem("First by sequence"); JMenuItem byGtridItem = new JMenuItem("First by GTRID"); findMenu.add(bySequenceItem); findMenu.add(byGtridItem); JMenu analysisMenu = new JMenu("Analysis"); menuBar.add(analysisMenu); JMenuItem switchLogFilesItem = new JMenuItem("Switch log files"); analysisMenu.add(switchLogFilesItem); JMenuItem countDuplicatedGtridsItem = new JMenuItem("Count duplicated GTRID"); analysisMenu.add(countDuplicatedGtridsItem); JMenuItem countByStatus = new JMenuItem("Count by status"); analysisMenu.add(countByStatus); transactionLogHeaderPanel1.read(getActiveLogFile(configuration), true); transactionLogHeaderPanel2.read(getPassiveLogFile(configuration), false); pendingViewTransactionsTable.setModel(new PendingTransactionTableModel(getActiveLogFile(configuration))); pendingViewTransactionsTable.addMouseListener(new TransactionTableMouseListener(this, pendingViewTransactionsTable)); rawViewTransactionsTable.setDefaultRenderer(String.class, new TransactionTableCellRenderer()); rawViewTransactionsTable.setModel(new RawTransactionTableModel(getActiveLogFile(configuration))); rawViewTransactionsTable.addMouseListener(new TransactionTableMouseListener(this, rawViewTransactionsTable)); final JPopupMenu rawViewTransactionsTablePopupMenu = new JPopupMenu(); final JCheckBoxMenuItem filterByGtridItem = new JCheckBoxMenuItem("Filter by GTRID"); filterByGtridItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { filterByGtrid(filterByGtridItem.isSelected()); } }); rawViewTransactionsTablePopupMenu.add(filterByGtridItem); rawViewTransactionsTable.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { rawViewTransactionsTablePopupMenu.show(e.getComponent(), e.getX(), e.getY()); int row = rawViewTransactionsTable.rowAtPoint(new Point(e.getX(), e.getY())); selectTableRow(rawViewTransactionsTable, row); } } public void mouseReleased(MouseEvent e) { mousePressed(e); } }); tabbedPane.add("Pending logs", pendingTransactionsTableScrollpane); tabbedPane.add("Raw logs", rawTransactionsTableScrollpane); tabbedPane.add("Resources", resourcesPanel); refreshStatus(); statusBarPanel.setLayout(new GridLayout(3, 1, 1, 1)); statusBarPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); statusBarPanel.add(transactionLogHeaderPanel1); statusBarPanel.add(transactionLogHeaderPanel2); statusBarPanel.add(statusLabel); switchLogFilesItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { switchLogFiles(configuration); } }); countDuplicatedGtridsItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { countDuplicatedGtrids(); } }); countByStatus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { countByStatus(); } }); bySequenceItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { findBySequence(); } }); byGtridItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { findByGtrid(); } }); setTitle("Bitronix Transaction Manager Console"); setJMenuBar(menuBar); getContentPane().setLayout(new BorderLayout(0, 2)); getContentPane().add(tabbedPane, BorderLayout.CENTER); getContentPane().add(statusBarPanel, BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(800, 600); setVisible(true); } private File activeLogFile; private File passiveLogFile; private File realActiveLogFile; private File getActiveLogFile(Configuration configuration) throws IOException { if (activeLogFile == null) { activeLogFile = pickCurrentLogFile(new File(configuration.getLogPart1Filename()), new File(configuration.getLogPart2Filename())); realActiveLogFile = activeLogFile; if (log.isDebugEnabled()) log.debug("active file is " + activeLogFile.getName()); } return activeLogFile; } public static File pickCurrentLogFile(File file1, File file2) throws IOException { RandomAccessFile activeRandomAccessFile; activeRandomAccessFile = new RandomAccessFile(file1, "r"); int formatId1 = activeRandomAccessFile.readInt(); if (formatId1 != BitronixXid.FORMAT_ID) throw new IOException("log file 1 " + file1.getName() + " is not a Bitronix Log file (incorrect header)"); long timestamp1 = activeRandomAccessFile.readLong(); activeRandomAccessFile.close(); activeRandomAccessFile = new RandomAccessFile(file2, "r"); int formatId2 = activeRandomAccessFile.readInt(); if (formatId2 != BitronixXid.FORMAT_ID) throw new IOException("log file 2 " + file2.getName() + " is not a Bitronix Log file (incorrect header)"); long timestamp2 = activeRandomAccessFile.readLong(); activeRandomAccessFile.close(); if (timestamp1 > timestamp2) { return file1; } else { return file2; } } private File getPassiveLogFile(Configuration configuration) throws IOException { if (passiveLogFile == null) { if (getActiveLogFile(configuration).getName().equals(configuration.getLogPart1Filename())) passiveLogFile = new File(configuration.getLogPart2Filename()); else passiveLogFile = new File(configuration.getLogPart1Filename()); } return passiveLogFile; } private void refreshStatus() { statusLabel.setText("active log file is " + realActiveLogFile.getName() + " - displayed log file contains " + pendingViewTransactionsTable.getModel().getRowCount() + " dangling transaction log(s) over " + rawViewTransactionsTable.getModel().getRowCount() + " total transaction log(s)"); } private void switchLogFiles(Configuration configuration) { File temp = activeLogFile; activeLogFile = passiveLogFile; passiveLogFile = temp; File realPassive = activeLogFile == realActiveLogFile ? passiveLogFile : activeLogFile; try { transactionLogHeaderPanel1.read(realActiveLogFile, configuration.getLogPart1Filename().equals(activeLogFile.getName())); transactionLogHeaderPanel2.read(realPassive, configuration.getLogPart2Filename().equals(activeLogFile.getName())); pendingViewTransactionsTable.setModel(new PendingTransactionTableModel(getActiveLogFile(configuration))); rawViewTransactionsTable.setModel(new RawTransactionTableModel(getActiveLogFile(configuration))); refreshStatus(); } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Reloading model of switched logs failed. Try again.", "Error", JOptionPane.ERROR_MESSAGE); } } private void countDuplicatedGtrids() { TransactionTableModel transactionTableModel = (TransactionTableModel) rawViewTransactionsTable.getModel(); HashMap gtrids = new HashMap(); HashMap redundantGtrids = new HashMap(); for (int i = 0; i < transactionTableModel.getRowCount(); i++) { TransactionLogRecord tlog = transactionTableModel.getRow(i); if (tlog.getStatus() == Status.STATUS_COMMITTING) { Uid gtrid = tlog.getGtrid(); if (gtrids.containsKey(gtrid)) { java.util.List tlogs = (java.util.List) gtrids.get(gtrid); tlogs.add(tlog); redundantGtrids.put(gtrid, tlogs); } else { java.util.List tlogs = new ArrayList(); tlogs.add(tlog); gtrids.put(gtrid, tlogs); } } } JTable table = new JTable(new DuplicatedGtridTableModel(redundantGtrids)); JScrollPane scrollPane = new JScrollPane(table); JDialog dialog = new JDialog(this, redundantGtrids.size() + " duplicated GTRIDs found"); dialog.getContentPane().add(scrollPane); dialog.pack(); dialog.setModal(false); dialog.setVisible(true); // JOptionPane.showMessageDialog(this, redundantGtrids.size() + " duplicated GTRID", "Duplicated GTRID count", JOptionPane.INFORMATION_MESSAGE); } private void countByStatus() { TransactionTableModel transactionTableModel = (TransactionTableModel) rawViewTransactionsTable.getModel(); int preparing = 0; int prepared = 0; int rollingback = 0; int rolledback = 0; int committing = 0; int committed = 0; int active = 0; int unknown = 0; for (int i = 0; i < transactionTableModel.getRowCount(); i++) { TransactionLogRecord tlog = transactionTableModel.getRow(i); switch (tlog.getStatus()) { case Status.STATUS_ACTIVE: active++; break; case Status.STATUS_PREPARING: preparing++; break; case Status.STATUS_PREPARED: prepared++; break; case Status.STATUS_COMMITTING: committing++; break; case Status.STATUS_COMMITTED: committed++; break; case Status.STATUS_ROLLING_BACK: rollingback++; break; case Status.STATUS_ROLLEDBACK: rolledback++; break; default: unknown++; } } String message = "Active: " + active + "\n" + "Preparing: " + preparing + "\n" + "Prepared: " + prepared + "\n" + "Committing: " + committing + "\n" + "Committed: " + committed + "\n" + "Rolling back: " + rollingback + "\n" + "Rolled back: " + rolledback; if (unknown > 0) message += "\nUnknown: " + unknown; JOptionPane.showMessageDialog(this, message, "Count by status", JOptionPane.INFORMATION_MESSAGE); } private void findBySequence() { String sequence = JOptionPane.showInputDialog(this, "Enter sequence to search for"); int searchedSequence; try { searchedSequence = new Integer(sequence).intValue(); } catch (NumberFormatException ex) { JOptionPane.showMessageDialog(this, "Please input a number", "Find by sequence", JOptionPane.ERROR_MESSAGE); return; } if (tabbedPane.getSelectedComponent() == pendingTransactionsTableScrollpane) { TransactionTableModel transactionTableModel = (TransactionTableModel) pendingViewTransactionsTable.getModel(); selectTLogMatchingSequence(transactionTableModel, searchedSequence, pendingViewTransactionsTable); } else { TransactionTableModel transactionTableModel = (TransactionTableModel) rawViewTransactionsTable.getModel(); selectTLogMatchingSequence(transactionTableModel, searchedSequence, rawViewTransactionsTable); } } private void findByGtrid() { String gtrid = JOptionPane.showInputDialog(this, "Enter GTRID to search for"); if (tabbedPane.getSelectedComponent() == pendingTransactionsTableScrollpane) { TransactionTableModel transactionTableModel = (TransactionTableModel) pendingViewTransactionsTable.getModel(); selectTLogMatchingGtrid(transactionTableModel, gtrid, pendingViewTransactionsTable); } else { TransactionTableModel transactionTableModel = (TransactionTableModel) rawViewTransactionsTable.getModel(); selectTLogMatchingGtrid(transactionTableModel, gtrid, rawViewTransactionsTable); } } private void filterByGtrid(boolean filter) { RawTransactionTableModel model = (RawTransactionTableModel) rawViewTransactionsTable.getModel(); if (filter) { int selectedRow = rawViewTransactionsTable.getSelectedRow(); String gtrid = (String) model.getValueAt(selectedRow, RawTransactionTableModel.GTRID_COL); model.filterByGtrid(gtrid); } else { model.filterByGtrid(null); } rawViewTransactionsTable.repaint(); } private void selectTLogMatchingSequence(TransactionTableModel transactionTableModel, int sequenceNumber, JTable table) { int startIndex = table.getSelectedRow() + 1; for (int i = startIndex; i < transactionTableModel.getRowCount(); i++) { TransactionLogRecord tlog = transactionTableModel.getRow(i); if (tlog.getSequenceNumber() == sequenceNumber) { selectTableRow(table, i); return; } } // if it is not found, search starting back at the beginning of the list up to where we previously started if (startIndex > 0) { for (int i = 0; i < startIndex; i++) { TransactionLogRecord tlog = transactionTableModel.getRow(i); if (tlog.getSequenceNumber() == sequenceNumber) { selectTableRow(table, i); return; } } } JOptionPane.showMessageDialog(this, "Not found", "Find by sequence", JOptionPane.INFORMATION_MESSAGE); } private void selectTLogMatchingGtrid(TransactionTableModel transactionTableModel, String gtrid, JTable table) { int startIndex = table.getSelectedRow() + 1; for (int i = startIndex; i < transactionTableModel.getRowCount(); i++) { TransactionLogRecord tlog = transactionTableModel.getRow(i); if (tlog.getGtrid().toString().equals(gtrid)) { selectTableRow(table, i); return; } } // if it is not found, search starting back at the beginning of the list up to where we previously started if (startIndex > 0) { for (int i = 0; i < startIndex; i++) { TransactionLogRecord tlog = transactionTableModel.getRow(i); if (tlog.getGtrid().toString().equals(gtrid)) { selectTableRow(table, i); return; } } } JOptionPane.showMessageDialog(this, "Not found", "Find by GTRID", JOptionPane.INFORMATION_MESSAGE); } private void selectTableRow(JTable table, int rowNum) { if (rowNum == -1) return; // select the row table.setRowSelectionInterval(rowNum, rowNum); // now scroll to the selected row JViewport viewport = (JViewport) table.getParent(); Rectangle rect = table.getCellRect(rowNum, 0, true); // The location of the view relative to the table Rectangle viewRect = viewport.getViewRect(); // Translate the cell location so that it is relative // to the view, assuming the northwest corner of the // view is (0,0). rect.setLocation(rect.x - viewRect.x, rect.y - viewRect.y); viewport.scrollRectToVisible(rect); } public static void main(String[] args) throws Exception { try { new Console(); } catch (IOException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); ex.printStackTrace(); } } } btm-dist-2.1.4/src/bitronix/tm/gui/TransactionTableMouseListener.java0000644000175000017500000000311712147207062024460 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.journal.TransactionLogRecord; import javax.swing.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; /** *

* * @author lorban */ public class TransactionTableMouseListener extends MouseAdapter { private JFrame frame; private JTable table; public TransactionTableMouseListener(JFrame frame, JTable table) { this.frame = frame; this.table = table; } public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { showDetails(); } } private void showDetails() { TransactionLogRecord tlog = ((TransactionTableModel)table.getModel()).getRow(table.getSelectedRow()); new TransactionLogDialog(frame, tlog).setVisible(true); } } btm-dist-2.1.4/src/bitronix/tm/gui/TransactionTableCellRenderer.java0000644000175000017500000000363312147207062024233 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.journal.TransactionLogRecord; import javax.swing.*; import javax.swing.table.DefaultTableCellRenderer; import java.awt.*; /** *

* * @author lorban */ public class TransactionTableCellRenderer extends DefaultTableCellRenderer { public TransactionTableCellRenderer() { } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); TransactionLogRecord tlog = (TransactionLogRecord) ((RawTransactionTableModel)table.getModel()).getRow(row); if (!tlog.isCrc32Correct()) { if (isSelected) setBackground(table.getSelectionBackground()); else component.setBackground(Color.RED); } else { if (isSelected) setBackground(table.getSelectionBackground()); else component.setBackground(Color.WHITE); } return component; } } btm-dist-2.1.4/src/bitronix/tm/gui/ResourcesTreeModel.java0000644000175000017500000000515612147207062022264 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.TransactionManagerServices; import bitronix.tm.resource.ResourceLoader; import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import java.util.Iterator; /** * * @author lorban */ public class ResourcesTreeModel implements TreeModel { private static final String ROOT = "Resource loader"; private ResourceLoader resourceLoader; public ResourcesTreeModel() { resourceLoader = TransactionManagerServices.getResourceLoader(); } public Object getRoot() { return ROOT; } public int getChildCount(Object parent) { if (parent.equals(ROOT)) return resourceLoader.getResources().size(); return 0; } public boolean isLeaf(Object node) { if (node.equals(ROOT)) return false; return true; } public void addTreeModelListener(TreeModelListener l) { //To change body of implemented methods use File | Settings | File Templates. } public void removeTreeModelListener(TreeModelListener l) { //To change body of implemented methods use File | Settings | File Templates. } public Object getChild(Object parent, int index) { if (index < 0) return ROOT; Iterator it = resourceLoader.getResources().entrySet().iterator(); Object result = null; for(int i= -1; i

* * @author lorban */ public class PendingTransactionTableModel extends TransactionTableModel { private final static Logger log = LoggerFactory.getLogger(PendingTransactionTableModel.class); public PendingTransactionTableModel(File filename) { try { readFullTransactionLog(filename); } catch (Exception ex) { log.error("corrupted log file", ex); } } public int getColumnCount() { return 8; } public int getRowCount() { return tLogs.size(); } public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } public Class getColumnClass(int columnIndex) { return String.class; } public Object getValueAt(int rowIndex, int columnIndex) { TransactionLogRecord tlog = (TransactionLogRecord) tLogs.get(rowIndex); switch (columnIndex) { case 0: return Decoder.decodeStatus(tlog.getStatus()); case 1: return "" + tlog.getRecordLength(); case 2: return "" + tlog.getHeaderLength(); case 3: return "" + tlog.getTime(); case 4: return "" + tlog.getSequenceNumber(); case 5: return "" + tlog.getCrc32(); case 6: return "" + tlog.getUniqueNames().size(); case 7: return tlog.getGtrid().toString(); default: return null; } } public void setValueAt(Object aValue, int rowIndex, int columnIndex) { } public String getColumnName(int columnIndex) { switch (columnIndex) { case 0: return "Record Status"; case 1: return "Record length"; case 2: return "Header length"; case 3: return "Record time"; case 4: return "Record sequence number"; case 5: return "CRC"; case 6: return "Resources"; case 7: return "GTRID"; default: return null; } } public void addTableModelListener(TableModelListener l) { } public void removeTableModelListener(TableModelListener l) { } private Map pendingTLogs = new HashMap(); protected void readFullTransactionLog(File filename) throws IOException { super.readFullTransactionLog(filename); pendingTLogs.clear(); } public boolean acceptLog(TransactionLogRecord tlog) { if (tlog.getStatus() == Status.STATUS_COMMITTING) { pendingTLogs.put(tlog.getGtrid(), tlog); return true; } if (tlog.getStatus() == Status.STATUS_COMMITTED || tlog.getStatus() == Status.STATUS_ROLLEDBACK && pendingTLogs.containsKey(tlog.getGtrid().toString())) { tLogs.remove(pendingTLogs.get(tlog.getGtrid())); } return false; } public TransactionLogRecord getRow(int row) { return (TransactionLogRecord) tLogs.get(row); } } btm-dist-2.1.4/src/bitronix/tm/gui/ResourcesPanel.java0000644000175000017500000000722712147207062021444 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.gui; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.PropertyUtils; import bitronix.tm.resource.ResourceLoader; import bitronix.tm.resource.common.ResourceBean; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Iterator; import java.util.Map; /** * * @author lorban */ public class ResourcesPanel extends JPanel { private JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); private JTree resourcesTree = new JTree(); private JScrollPane resourcesTreeScrollpane = new JScrollPane(resourcesTree); private JTextArea activeResource = new JTextArea(); public ResourcesPanel() { setLayout(new GridLayout(1, 1)); resourcesTree.setModel(new ResourcesTreeModel()); resourcesTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JTree tree = (JTree) evt.getSource(); int selectedRow = tree.getSelectionRows()[0] -1; ResourceLoader resourceLoader = TransactionManagerServices.getResourceLoader(); Iterator it = resourceLoader.getResources().entrySet().iterator(); ResourceBean resource = null; for (int i=0; i

* * @author lorban */ public class TransactionLogHeaderPanel extends JPanel { private final static Logger log = LoggerFactory.getLogger(TransactionLogHeaderPanel.class); private JTextField logFileField = new JTextField(); private JTextField timestampField = new JTextField(); private JTextField stateField = new JTextField(); private JTextField positionField = new JTextField(); public TransactionLogHeaderPanel() { logFileField.setEditable(false); timestampField.setEditable(false); stateField.setEditable(false); positionField.setEditable(false); logFileField.setBorder(null); timestampField.setBorder(null); stateField.setBorder(null); positionField.setBorder(null); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(logFileField); add(timestampField); add(stateField); add(positionField); } public void setLogFile(File logFile) { logFileField.setText(logFile.getName()); } public void setTimestamp(long timestamp) { timestampField.setText(Console.dateFormatter.format(new Date(timestamp))); } public void setState(byte state) { stateField.setText(Decoder.decodeHeaderState(state)); } public void setPosition(long position) { positionField.setText("" + position); } public void read(File logFile, boolean active) throws IOException { RandomAccessFile raf = new RandomAccessFile(logFile, "r"); TransactionLogHeader header = new TransactionLogHeader(raf.getChannel(), 0L); raf.close(); if (log.isDebugEnabled()) log.debug("read header: " + header); setLogFile(logFile); setTimestamp(header.getTimestamp()); setState(header.getState()); setPosition(header.getPosition()); Font font; if (active) { font = logFileField.getFont().deriveFont(Font.BOLD); } else { font = logFileField.getFont().deriveFont(Font.PLAIN); } logFileField.setFont(font); timestampField.setFont(font); stateField.setFont(font); positionField.setFont(font); } } btm-dist-2.1.4/src/bitronix/tm/BitronixUserTransactionObjectFactory.java0000644000175000017500000000216612147207062025245 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; /** * {@link BitronixTransactionManager} object factory for JNDI references. This class does no more than * {@link BitronixTransactionManagerObjectFactory}, it only exists for clarity. * * @author lorban */ public class BitronixUserTransactionObjectFactory extends BitronixTransactionManagerObjectFactory { } btm-dist-2.1.4/src/bitronix/tm/resource/0000755000175000017500000000000012147207062016702 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/resource/package.html0000644000175000017500000000016012147207062021160 0ustar tonytony

Transaction Manager's resource management services.

btm-dist-2.1.4/src/bitronix/tm/resource/ResourceLoader.java0000644000175000017500000003202212147207062022462 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource; import bitronix.tm.TransactionManagerServices; import bitronix.tm.resource.common.XAResourceProducer; import bitronix.tm.utils.ClassLoaderUtils; import bitronix.tm.utils.InitializationException; import bitronix.tm.utils.PropertyUtils; import bitronix.tm.utils.Service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jms.XAConnectionFactory; import javax.sql.XADataSource; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; /** * XA resources pools configurator & loader. *

{@link ResourceLoader} relies on the optional bitronix.tm.resource.configuration propery to load the * JDBC datasources ({@link bitronix.tm.resource.jdbc.PoolingDataSource}) and JMS connection factories * ({@link bitronix.tm.resource.jms.PoolingConnectionFactory}) configuration file and create the resources.

*

When bitronix.tm.resource.configuration is not specified, ResourceLoader is disabled and resources * should be manually created.

* * @author lorban */ public class ResourceLoader implements Service { private final static Logger log = LoggerFactory.getLogger(ResourceLoader.class); private final static String JDBC_RESOURCE_CLASSNAME = "bitronix.tm.resource.jdbc.PoolingDataSource"; private final static String JMS_RESOURCE_CLASSNAME = "bitronix.tm.resource.jms.PoolingConnectionFactory"; private final Map resourcesByUniqueName = new HashMap(); public ResourceLoader() { } /** * Get a Map with the configured uniqueName as key and {@link XAResourceProducer} as value. * @return a Map using the uniqueName as key and {@link XAResourceProducer} as value. */ public Map getResources() { return resourcesByUniqueName; } /** * Initialize the ResourceLoader and load the resources configuration file specified in * bitronix.tm.resource.configuration property. * @return the number of resources which failed to initialize. */ public int init() { String filename = TransactionManagerServices.getConfiguration().getResourceConfigurationFilename(); if (filename != null) { if (!new File(filename).exists()) throw new ResourceConfigurationException("cannot find resources configuration file '" + filename +"', missing or invalid value of property 'bitronix.tm.resource.configuration'"); log.info("reading resources configuration from " + filename); return init(filename); } else { if (log.isDebugEnabled()) log.debug("no resource configuration file specified"); return 0; } } public synchronized void shutdown() { if (log.isDebugEnabled()) log.debug("resource loader has registered " + resourcesByUniqueName.entrySet().size() + " resource(s), unregistering them now"); for (Map.Entry entry : resourcesByUniqueName.entrySet()) { XAResourceProducer producer = entry.getValue(); if (log.isDebugEnabled()) log.debug("closing " + producer); try { producer.close(); } catch (Exception ex) { log.warn("error closing resource " + producer, ex); } } resourcesByUniqueName.clear(); } /* * Internal impl. */ /** * Create an unitialized {@link XAResourceProducer} implementation which depends on the XA resource class name. * @param xaResourceClassName an XA resource class name. * @return a {@link XAResourceProducer} implementation. * @throws ClassNotFoundException if the {@link XAResourceProducer} cannot be instantiated. * @throws IllegalAccessException if the {@link XAResourceProducer} cannot be instantiated. * @throws InstantiationException if the {@link XAResourceProducer} cannot be instantiated. */ private static XAResourceProducer instantiate(String xaResourceClassName) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Class clazz = ClassLoaderUtils.loadClass(xaResourceClassName); // resource classes are instantiated via reflection so that there is no hard class binding between this internal // transaction manager service and 3rd party libraries like the JMS ones. // This allows using the TM with a 100% JDBC application without requiring JMS libraries. if (XADataSource.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JDBC_RESOURCE_CLASSNAME).newInstance(); } else if (XAConnectionFactory.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JMS_RESOURCE_CLASSNAME).newInstance(); } else return null; } /** * Read the resources properties file and create {@link XAResourceProducer} accordingly. * @param propertiesFilename the name of the properties file to load. * @return the number of resources which failed to initialize. */ private int init(String propertiesFilename) { try { FileInputStream fis = null; Properties properties; try { fis = new FileInputStream(propertiesFilename); properties = new Properties(); properties.load(fis); } finally { if (fis != null) fis.close(); } return initXAResourceProducers(properties); } catch (IOException ex) { throw new InitializationException("cannot create resource loader", ex); } } /** * Initialize {@link XAResourceProducer}s given a set of properties. * @param properties the properties to use for initialization. * @return the number of resources which failed to initialize. */ int initXAResourceProducers(Properties properties) { Map> entries = buildConfigurationEntriesMap(properties); int errorCount = 0; for (Map.Entry> entry : entries.entrySet()) { String uniqueName = entry.getKey(); List propertyPairs = entry.getValue(); XAResourceProducer producer = buildXAResourceProducer(uniqueName, propertyPairs); if (ResourceRegistrar.get(producer.getUniqueName()) != null) { if (log.isDebugEnabled()) log.debug("resource already registered, skipping it:" + producer.getUniqueName()); continue; } if (log.isDebugEnabled()) log.debug("creating resource " + producer); try { producer.init(); } catch (ResourceConfigurationException ex) { log.warn("unable to create resource with unique name " + producer.getUniqueName(), ex); producer.close(); errorCount++; } resourcesByUniqueName.put(producer.getUniqueName(), producer); } return errorCount; } /** * Create a map using the configured resource name as the key and a List of PropertyPair objects as the value. * @param properties object to analyze. * @return the built map. */ private Map> buildConfigurationEntriesMap(Properties properties) { Map> entries = new HashMap>(); for (Map.Entry entry : properties.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); if (key.startsWith("resource.")) { String[] keyParts = key.split("\\."); if (keyParts.length < 3) { log.warn("ignoring invalid entry in configuration file: " + key); continue; } String configuredName = keyParts[1]; String propertyName = keyParts[2]; if (keyParts.length > 3) { for (int i = 3; i < keyParts.length; i++) { propertyName += "." + keyParts[i]; } } List pairs = entries.get(configuredName); if (pairs == null) { pairs = new ArrayList(); entries.put(configuredName, pairs); } pairs.add(new PropertyPair(propertyName, value)); } } return entries; } /** * Build a populated {@link XAResourceProducer} out of a list of property pairs and the config name. * @param configuredName index name of the config file. * @param propertyPairs the properties attached to this index. * @return a populated {@link XAResourceProducer}. * @throws ResourceConfigurationException if the {@link XAResourceProducer} cannot be built. */ private XAResourceProducer buildXAResourceProducer(String configuredName, List propertyPairs) throws ResourceConfigurationException { String lastPropertyName = "className"; try { XAResourceProducer producer = createBean(configuredName, propertyPairs); for (PropertyPair propertyPair : propertyPairs) { lastPropertyName = propertyPair.getName(); String propertyValue = propertyPair.getValue(); PropertyUtils.setProperty(producer, lastPropertyName, propertyValue); } if (producer.getUniqueName() == null) throw new ResourceConfigurationException("missing mandatory property [uniqueName] of resource [" + configuredName + "] in resources configuration file"); return producer; } catch (ResourceConfigurationException ex) { throw ex; } catch (Exception ex) { throw new ResourceConfigurationException("cannot configure resource for configuration entries with name [" + configuredName + "]" + " - failing property is [" + lastPropertyName + "]", ex); } } /** * Create an unpopulated, uninitialized {@link XAResourceProducer} instance depending on the className value. * @param configuredName the properties configured name. * @param propertyPairs a list of {@link PropertyPair}s. * @return a {@link XAResourceProducer}. * @throws ClassNotFoundException if the {@link XAResourceProducer} cannot be instantiated. * @throws IllegalAccessException if the {@link XAResourceProducer} cannot be instantiated. * @throws InstantiationException if the {@link XAResourceProducer} cannot be instantiated. */ private XAResourceProducer createBean(String configuredName, List propertyPairs) throws ClassNotFoundException, IllegalAccessException, InstantiationException { for (PropertyPair propertyPair : propertyPairs) { if (propertyPair.getName().equals("className")) { String className = propertyPair.getValue(); XAResourceProducer producer = instantiate(className); if (producer == null) throw new ResourceConfigurationException("property [className] " + "of resource [" + configuredName + "] in resources configuration file " + "must be the name of a class implementing either javax.sql.XADataSource or javax.jms.XAConnectionFactory"); return producer; } } throw new ResourceConfigurationException("missing mandatory property [className] for resource [" + configuredName + "] in resources configuration file"); } private final class PropertyPair { private final String name; private final String value; public PropertyPair(String key, String value) { this.name = key; this.value = value; } public String getName() { return name; } public String getValue() { return value; } public String toString() { return name + "/" + value; } } } btm-dist-2.1.4/src/bitronix/tm/resource/ResourceObjectFactory.java0000644000175000017500000000454512147207062024023 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.naming.spi.ObjectFactory; import javax.naming.*; import java.util.Hashtable; /** * {@link bitronix.tm.resource.common.XAResourceProducer} object factory for JNDI references. * * @see bitronix.tm.resource.common.ResourceBean * @author lorban */ public class ResourceObjectFactory implements ObjectFactory { private final static Logger log = LoggerFactory.getLogger(ResourceObjectFactory.class); public Object getObjectInstance(Object obj, Name jndiNameObject, Context nameCtx, Hashtable environment) throws Exception { Reference ref = (Reference) obj; if (log.isDebugEnabled()) log.debug("referencing resource with reference of type " + ref.getClass()); RefAddr refAddr = ref.get("uniqueName"); if (refAddr == null) throw new NamingException("no 'uniqueName' RefAddr found"); Object content = refAddr.getContent(); if (!(content instanceof String)) throw new NamingException("'uniqueName' RefAddr content is not of type java.lang.String"); String uniqueName = (String) content; if (log.isDebugEnabled()) log.debug("getting registered resource with uniqueName '" + uniqueName + "'"); Referenceable resource = ResourceRegistrar.get(uniqueName); if (resource == null) throw new NamingException("no resource registered with uniqueName '" + uniqueName + "', available resources: " + ResourceRegistrar.getResourcesUniqueNames()); return resource; } } btm-dist-2.1.4/src/bitronix/tm/resource/ehcache/0000755000175000017500000000000012147207062020262 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/resource/ehcache/package.html0000644000175000017500000000014112136323160022533 0ustar tonytony

Ehcache specific resource management code.

btm-dist-2.1.4/src/bitronix/tm/resource/ehcache/EhCacheXAResourceProducer.java0000644000175000017500000001723012147207062026055 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.ehcache; import bitronix.tm.internal.BitronixRuntimeException; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.recovery.RecoveryException; import bitronix.tm.resource.ResourceObjectFactory; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.common.RecoveryXAResourceHolder; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.resource.common.XAResourceProducer; import bitronix.tm.resource.common.XAStatefulHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.naming.NamingException; import javax.naming.Reference; import javax.naming.StringRefAddr; import javax.transaction.xa.XAResource; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; /** * EHCache implementation of BTM's XAResourceProducer. *

* Copyright 2003-2010 Terracotta, Inc. *

* @author lorban */ public final class EhCacheXAResourceProducer extends ResourceBean implements XAResourceProducer { private static final Logger log = LoggerFactory.getLogger(EhCacheXAResourceProducer.class.getName()); private static final ConcurrentMap producers = new ConcurrentHashMap(); private final ConcurrentMap xaResourceHolders = new ConcurrentHashMap(); private final AtomicInteger xaResourceHolderCounter = new AtomicInteger(); private volatile RecoveryXAResourceHolder recoveryXAResourceHolder; private EhCacheXAResourceProducer() { setApplyTransactionTimeout(true); } /** * Register an XAResource of a cache with BTM. The first time a XAResource is registered a new * EhCacheXAResourceProducer is created to hold it. * @param uniqueName the uniqueName of this XAResourceProducer, usually the cache's name * @param xaResource the XAResource to be registered */ public static void registerXAResource(String uniqueName, XAResource xaResource) { EhCacheXAResourceProducer xaResourceProducer = producers.get(uniqueName); if (xaResourceProducer == null) { xaResourceProducer = new EhCacheXAResourceProducer(); xaResourceProducer.setUniqueName(uniqueName); // the initial xaResource must be added before init() can be called xaResourceProducer.addXAResource(xaResource); EhCacheXAResourceProducer previous = producers.putIfAbsent(uniqueName, xaResourceProducer); if (previous == null) { xaResourceProducer.init(); } else { previous.addXAResource(xaResource); } } else { xaResourceProducer.addXAResource(xaResource); } } /** * Unregister an XAResource of a cache from BTM. * @param uniqueName the uniqueName of this XAResourceProducer, usually the cache's name * @param xaResource the XAResource to be registered */ public static void unregisterXAResource(String uniqueName, XAResource xaResource) { EhCacheXAResourceProducer xaResourceProducer = producers.get(uniqueName); if (xaResourceProducer != null) { boolean found = xaResourceProducer.removeXAResource(xaResource); if (!found) { log.error("no XAResource " + xaResource + " found in XAResourceProducer with name " + uniqueName); } if (xaResourceProducer.xaResourceHolders.isEmpty()) { xaResourceProducer.close(); producers.remove(uniqueName); } } else { log.error("no XAResourceProducer registered with name " + uniqueName); } } private void addXAResource(XAResource xaResource) { EhCacheXAResourceHolder xaResourceHolder = new EhCacheXAResourceHolder(xaResource, this); int key = xaResourceHolderCounter.incrementAndGet(); xaResourceHolders.put(key, xaResourceHolder); } private boolean removeXAResource(XAResource xaResource) { for (Map.Entry entry : xaResourceHolders.entrySet()) { Integer key = entry.getKey(); EhCacheXAResourceHolder xaResourceHolder = entry.getValue(); if (xaResourceHolder.getXAResource() == xaResource) { xaResourceHolders.remove(key); return true; } } return false; } /** * {@inheritDoc} */ public XAResourceHolderState startRecovery() throws RecoveryException { if (recoveryXAResourceHolder != null) { throw new RecoveryException("recovery already in progress on " + this); } if (xaResourceHolders.isEmpty()) { throw new RecoveryException("no XAResource registered, recovery cannot be done on " + this); } recoveryXAResourceHolder = new RecoveryXAResourceHolder(xaResourceHolders.values().iterator().next()); return new XAResourceHolderState(recoveryXAResourceHolder, this); } /** * {@inheritDoc} */ public void endRecovery() throws RecoveryException { recoveryXAResourceHolder = null; } /** * {@inheritDoc} */ public void setFailed(boolean failed) { // cache cannot fail as it's not connection oriented } /** * {@inheritDoc} */ public XAResourceHolder findXAResourceHolder(XAResource xaResource) { for (EhCacheXAResourceHolder xaResourceHolder : xaResourceHolders.values()) { if (xaResource == xaResourceHolder.getXAResource()) { return xaResourceHolder; } } return null; } /** * {@inheritDoc} */ public void init() { try { ResourceRegistrar.register(this); } catch (RecoveryException ex) { throw new BitronixRuntimeException("error recovering " + this, ex); } } /** * {@inheritDoc} */ public void close() { xaResourceHolders.clear(); xaResourceHolderCounter.set(0); ResourceRegistrar.unregister(this); } /** * {@inheritDoc} */ public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception { throw new UnsupportedOperationException("Ehcache is not connection-oriented"); } /** * {@inheritDoc} */ public Reference getReference() throws NamingException { return new Reference(EhCacheXAResourceProducer.class.getName(), new StringRefAddr("uniqueName", getUniqueName()), ResourceObjectFactory.class.getName(), null); } public String toString() { return "a EhCacheXAResourceProducer with uniqueName " + getUniqueName(); } } btm-dist-2.1.4/src/bitronix/tm/resource/ehcache/EhCacheXAResourceHolder.java0000644000175000017500000000525012147207062025506 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.ehcache; import bitronix.tm.resource.common.AbstractXAResourceHolder; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.resource.common.XAResourceHolder; import javax.transaction.xa.XAResource; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; /** * Ehcache implementation of BTM's XAResourceHolder. *

* Copyright 2003-2010 Terracotta, Inc. *

* @author lorban */ public class EhCacheXAResourceHolder extends AbstractXAResourceHolder { private final XAResource resource; private final ResourceBean bean; /** * Create a new EhCacheXAResourceHolder for a particular XAResource * @param resource the required XAResource * @param bean the required ResourceBean */ public EhCacheXAResourceHolder(XAResource resource, ResourceBean bean) { this.resource = resource; this.bean = bean; } /** * {@inheritDoc} */ public XAResource getXAResource() { return resource; } /** * {@inheritDoc} */ public ResourceBean getResourceBean() { return bean; } /** * {@inheritDoc} */ public void close() throws Exception { throw new UnsupportedOperationException("EhCacheXAResourceHolder cannot be used with an XAPool"); } /** * {@inheritDoc} */ public Object getConnectionHandle() throws Exception { throw new UnsupportedOperationException("EhCacheXAResourceHolder cannot be used with an XAPool"); } /** * {@inheritDoc} */ public Date getLastReleaseDate() { throw new UnsupportedOperationException("EhCacheXAResourceHolder cannot be used with an XAPool"); } /** * {@inheritDoc} */ public List getXAResourceHolders() { return Arrays.asList((XAResourceHolder) this); } } btm-dist-2.1.4/src/bitronix/tm/resource/common/0000755000175000017500000000000012147207062020172 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/resource/common/package.html0000644000175000017500000000016712147207062022457 0ustar tonytony

Resource management code common across all resource types.

btm-dist-2.1.4/src/bitronix/tm/resource/common/AbstractXAResourceHolder.java0000644000175000017500000001562212147207062025705 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import bitronix.tm.BitronixTransaction; import bitronix.tm.BitronixXid; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.utils.Uid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; /** * Implementation of all services required by a {@link XAResourceHolder}. This class keeps a list of all * {@link XAResourceHolderState}s of the {@link XAResourceHolder} plus the currently active one. There is * one per transaction in which this {@link XAResourceHolder} is enlisted plus all the suspended transactions in which * it is enlisted as well. * * @author lorban */ public abstract class AbstractXAResourceHolder extends AbstractXAStatefulHolder implements XAResourceHolder { private final static Logger log = LoggerFactory.getLogger(AbstractXAResourceHolder.class); private final Map> xaResourceHolderStates = Collections.synchronizedMap(new HashMap>()); public Map getXAResourceHolderStatesForGtrid(Uid gtrid) { synchronized (xaResourceHolderStates) { return xaResourceHolderStates.get(gtrid); } } public void putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState) { synchronized (xaResourceHolderStates) { if (log.isDebugEnabled()) log.debug("putting XAResourceHolderState [" + xaResourceHolderState + "] on " + this); Uid gtrid = xid.getGlobalTransactionIdUid(); Uid bqual = xid.getBranchQualifierUid(); if (!xaResourceHolderStates.containsKey(gtrid)) { if (log.isDebugEnabled()) log.debug("GTRID [" + gtrid + "] previously unknown to " + this + ", adding it to the resource's transactions list"); // use a LinkedHashMap as iteration order must be guaranteed Map statesForGtrid = new LinkedHashMap(4); statesForGtrid.put(bqual, xaResourceHolderState); xaResourceHolderStates.put(gtrid, statesForGtrid); } else { if (log.isDebugEnabled()) log.debug("GTRID [" + gtrid + "] previously known to " + this + ", adding it to the resource's transactions list"); Map statesForGtrid = xaResourceHolderStates.get(gtrid); statesForGtrid.put(bqual, xaResourceHolderState); } } } public void removeXAResourceHolderState(BitronixXid xid) { synchronized (xaResourceHolderStates) { if (log.isDebugEnabled()) log.debug("removing XAResourceHolderState of xid " + xid + " from " + this); Uid gtrid = xid.getGlobalTransactionIdUid(); Uid bqual = xid.getBranchQualifierUid(); Map statesForGtrid = xaResourceHolderStates.get(gtrid); if (statesForGtrid == null) { log.warn("tried to remove unknown GTRID [" + gtrid + "] from " + this + " - Bug?"); return; } XAResourceHolderState removed = statesForGtrid.remove(bqual); if (removed == null) { log.warn("tried to remove unknown BQUAL [" + bqual + "] from " + this + " - Bug?"); return; } if (statesForGtrid.isEmpty()) { xaResourceHolderStates.remove(gtrid); } } } public boolean hasStateForXAResource(XAResourceHolder xaResourceHolder) { synchronized (xaResourceHolderStates) { for (Map statesForGtrid : xaResourceHolderStates.values()) { for (XAResourceHolderState otherXaResourceHolderState : statesForGtrid.values()) { if (otherXaResourceHolderState.getXAResource() == xaResourceHolder.getXAResource()) { if (log.isDebugEnabled()) log.debug("resource " + xaResourceHolder + " is enlisted in another transaction with " + otherXaResourceHolderState.getXid().toString()); return true; } } } if (log.isDebugEnabled()) log.debug("resource not enlisted in any transaction: " + xaResourceHolder); return false; } } /** * If this method returns false, then local transaction calls like Connection.commit() can be made. * @return true if start() has been successfully called but not end() yet and the transaction is not suspended. */ public boolean isParticipatingInActiveGlobalTransaction() { synchronized (xaResourceHolderStates) { BitronixTransaction currentTransaction = TransactionContextHelper.currentTransaction(); Uid gtrid = currentTransaction == null ? null : currentTransaction.getResourceManager().getGtrid(); if (gtrid == null) return false; Map statesForGtrid = xaResourceHolderStates.get(gtrid); if (statesForGtrid == null) return false; for (XAResourceHolderState xaResourceHolderState : statesForGtrid.values()) { if (xaResourceHolderState != null && xaResourceHolderState.isStarted() && !xaResourceHolderState.isSuspended() && !xaResourceHolderState.isEnded()) return true; } return false; } } /** * Simple helper method which returns a set of GTRIDs of transactions in which * this resource is enlisted. Useful for monitoring. * @return a set of String-encoded GTRIDs of transactions in which this resource is enlisted. */ public Set getXAResourceHolderStateGtrids() { synchronized (xaResourceHolderStates) { HashSet gtridsAsStrings = new HashSet(); for (Uid uid : xaResourceHolderStates.keySet()) { gtridsAsStrings.add(uid.toString()); } return gtridsAsStrings; } } } btm-dist-2.1.4/src/bitronix/tm/resource/common/XAResourceProducer.java0000644000175000017500000000705312147207062024566 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.recovery.RecoveryException; import javax.naming.Referenceable; import javax.transaction.xa.XAResource; import java.io.Serializable; /** * A {@link XAResourceProducer} is a {@link XAStatefulHolder} factory. It must be implemented by any class that is * able to produce pooled XA connections. * * @author lorban */ public interface XAResourceProducer extends Referenceable, Serializable { /** * Get the resource name as registered in the transactions journal. * @return the unique name of the resource. */ public String getUniqueName(); /** * Prepare the recoverable {@link XAResource} producer for recovery. * @return a {@link XAResourceHolderState} object that can be used to call recover(). * @throws bitronix.tm.recovery.RecoveryException thrown when a {@link XAResourceHolderState} cannot be acquired. */ public XAResourceHolderState startRecovery() throws RecoveryException; /** * Release internal resources held after call to startRecovery(). * @throws bitronix.tm.recovery.RecoveryException thrown when an error occured while releasing reserved resources. */ public void endRecovery() throws RecoveryException; /** * Mark this resource producer as failed or not. A resource is considered failed if recovery fails to run on it. * @param failed true is the resource must be considered failed, false it it must be considered sane. */ public void setFailed(boolean failed); /** * Find in the {@link XAResourceHolder}s created by this {@link XAResourceProducer} the one which this * {@link XAResource} belongs to. * @param xaResource the {@link XAResource} to look for. * @return the associated {@link XAResourceHolder} or null if the {@link XAResource} does not belong to this * {@link XAResourceProducer}. */ public XAResourceHolder findXAResourceHolder(XAResource xaResource); /** * Initialize this {@link XAResourceProducer}'s internal resources. */ public void init(); /** * Release this {@link XAResourceProducer}'s internal resources. */ public void close(); /** * Create a {@link XAStatefulHolder} that will be placed in an {@link XAPool}. * @param xaFactory the vendor's resource-specific XA factory. * @param bean the resource-specific bean describing the resource parameters. * @return a {@link XAStatefulHolder} that will be placed in an {@link XAPool}. * @throws Exception thrown when the {@link XAStatefulHolder} cannot be created. */ public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception; } btm-dist-2.1.4/src/bitronix/tm/resource/common/StateChangeListener.java0000644000175000017500000000335412147207062024736 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; /** * {@link XAStatefulHolder} state change listener interface. * * @author lorban */ public interface StateChangeListener { /** * Fired when the internal state of a {@link XAStatefulHolder} has changed. * @param source the {@link XAStatefulHolder} changing state. * @param oldState the old state of the {@link XAStatefulHolder}. * @param newState the new state of the {@link XAStatefulHolder}. */ public void stateChanged(XAStatefulHolder source, int oldState, int newState); /** * Fired before the internal state of a {@link XAStatefulHolder} has changed. * @param source the {@link XAStatefulHolder} changing state. * @param currentState the current state of the {@link XAStatefulHolder}. * @param futureState the future state of the {@link XAStatefulHolder}. */ public void stateChanging(XAStatefulHolder source, int currentState, int futureState); } btm-dist-2.1.4/src/bitronix/tm/resource/common/TransactionContextHelper.java0000644000175000017500000003506012147207062026033 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import bitronix.tm.BitronixTransaction; import bitronix.tm.BitronixXid; import bitronix.tm.TransactionManagerServices; import bitronix.tm.internal.BitronixSystemException; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.utils.Scheduler; import bitronix.tm.utils.Uid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.RollbackException; import javax.transaction.Synchronization; import javax.transaction.SystemException; import javax.transaction.xa.XAResource; import java.util.List; import java.util.Map; /** * Helper class that contains static logic common accross all resource types. * * @author lorban */ public class TransactionContextHelper { private final static Logger log = LoggerFactory.getLogger(TransactionContextHelper.class); /** * Enlist the {@link XAResourceHolder} in the current transaction or do nothing if there is no global transaction * context for this thread. * @param xaResourceHolder the {@link XAResourceHolder} to enlist. * @throws SystemException if an internal error happens. * @throws RollbackException if the current transaction has been marked as rollback only. */ public static void enlistInCurrentTransaction(XAResourceHolder xaResourceHolder) throws SystemException, RollbackException { BitronixTransaction currentTransaction = currentTransaction(); ResourceBean bean = xaResourceHolder.getResourceBean(); if (log.isDebugEnabled()) log.debug("enlisting " + xaResourceHolder + " into " + currentTransaction); if (currentTransaction != null) { if (currentTransaction.timedOut()) throw new BitronixSystemException("transaction timed out"); // in case multiple unjoined branches of the current transaction have run on the resource, // only the last one counts as all the first ones are ended already XAResourceHolderState alreadyEnlistedXAResourceHolderState = TransactionContextHelper.getLatestAlreadyEnlistedXAResourceHolderState(xaResourceHolder, currentTransaction); if (alreadyEnlistedXAResourceHolderState == null || alreadyEnlistedXAResourceHolderState.isEnded()) { currentTransaction.enlistResource(xaResourceHolder.getXAResource()); } else if (log.isDebugEnabled()) log.debug("avoiding re-enlistment of already enlisted but not ended resource " + alreadyEnlistedXAResourceHolderState); } else { if (bean.getAllowLocalTransactions()) { if (log.isDebugEnabled()) log.debug("in local transaction context, skipping enlistment"); } else throw new BitronixSystemException("resource '" + bean.getUniqueName() + "' cannot be used outside XA " + "transaction scope. Set allowLocalTransactions to true if you want to allow this and you know " + "your resource supports this."); } } /** * Delist the {@link XAResourceHolder} from the current transaction or do nothing if there is no global transaction * context for this thread. * @param xaResourceHolder the {@link XAResourceHolder} to delist. * @throws SystemException if an internal error happens. */ public static void delistFromCurrentTransaction(XAResourceHolder xaResourceHolder) throws SystemException { BitronixTransaction currentTransaction = currentTransaction(); ResourceBean bean = xaResourceHolder.getResourceBean(); if (log.isDebugEnabled()) log.debug("delisting " + xaResourceHolder + " from " + currentTransaction); // End resource as eagerly as possible. This allows to release connections to the pool much earlier // with resources fully supporting transaction interleaving. if (isInEnlistingGlobalTransactionContext(xaResourceHolder, currentTransaction) && !bean.getDeferConnectionRelease()) { Map statesForGtrid = xaResourceHolder.getXAResourceHolderStatesForGtrid(currentTransaction.getResourceManager().getGtrid()); for (XAResourceHolderState xaResourceHolderState : statesForGtrid.values()) { if (!xaResourceHolderState.isEnded()) { if (log.isDebugEnabled()) log.debug("delisting resource " + xaResourceHolderState + " from " + currentTransaction); // Watch out: the delistResource() call might throw a BitronixRollbackSystemException to indicate a unilateral rollback. currentTransaction.delistResource(xaResourceHolderState.getXAResource(), XAResource.TMSUCCESS); } else if (log.isDebugEnabled()) log.debug("avoiding delistment of not enlisted resource " + xaResourceHolderState); } } // isInEnlistingGlobalTransactionContext } /** * Get the transaction running on the current thead context. * @return null if there is no transaction on the current context or if the transaction manager is not running. */ public static BitronixTransaction currentTransaction() { if (!TransactionManagerServices.isTransactionManagerRunning()) return null; return TransactionManagerServices.getTransactionManager().getCurrentTransaction(); } /** * Switch the {@link XAStatefulHolder}'s state appropriately after the acquired resource handle has been closed. * The pooled resource will either be marked as closed or not accessible, depending on the value of the bean's * deferConnectionRelease property and will be marked for release after 2PC execution in the latter case. * @param xaStatefulHolder the {@link XAStatefulHolder} to requeue. * @param bean the {@link ResourceBean} of the {@link XAResourceHolder}. * @throws BitronixSystemException if an internal error happens. */ public static void requeue(XAStatefulHolder xaStatefulHolder, ResourceBean bean) throws BitronixSystemException { BitronixTransaction currentTransaction = currentTransaction(); if (log.isDebugEnabled()) log.debug("requeuing " + xaStatefulHolder + " from " + currentTransaction); if (!TransactionContextHelper.isInEnlistingGlobalTransactionContext(xaStatefulHolder, currentTransaction)) { if (!TransactionContextHelper.isEnlistedInSomeTransaction(xaStatefulHolder)) { // local mode, always requeue connection immediately if (log.isDebugEnabled()) log.debug("resource not in enlisting global transaction context, immediately releasing to pool " + xaStatefulHolder); xaStatefulHolder.setState(XAResourceHolder.STATE_IN_POOL); } else { throw new BitronixSystemException("cannot close a resource when its XAResource is taking part in an unfinished global transaction"); } } else if (bean.getDeferConnectionRelease()) { // global mode, defer connection requeuing if (log.isDebugEnabled()) log.debug("deferring release to pool of " + xaStatefulHolder); if (!TransactionContextHelper.isAlreadyRegisteredForDeferredRelease(xaStatefulHolder, currentTransaction)) { if (log.isDebugEnabled()) log.debug("registering DeferredReleaseSynchronization for " + xaStatefulHolder); DeferredReleaseSynchronization synchronization = new DeferredReleaseSynchronization(xaStatefulHolder); currentTransaction.getSynchronizationScheduler().add(synchronization, Scheduler.ALWAYS_LAST_POSITION); } else if (log.isDebugEnabled()) log.debug("already registered DeferredReleaseSynchronization for " + xaStatefulHolder); xaStatefulHolder.setState(XAResourceHolder.STATE_NOT_ACCESSIBLE); } else { // global mode, immediate connection requeuing if (log.isDebugEnabled()) log.debug("immediately releasing to pool " + xaStatefulHolder); xaStatefulHolder.setState(XAResourceHolder.STATE_IN_POOL); } } /** * Ensure the {@link XAStatefulHolder}'s release won't be deferred anymore (when appropriate) as it has been recycled. * @param xaStatefulHolder the recycled {@link XAStatefulHolder}. */ public static void recycle(XAStatefulHolder xaStatefulHolder) { BitronixTransaction currentTransaction = currentTransaction(); if (log.isDebugEnabled()) log.debug("marking " + xaStatefulHolder + " as recycled in " + currentTransaction); Scheduler synchronizationScheduler = currentTransaction.getSynchronizationScheduler(); DeferredReleaseSynchronization deferredReleaseSynchronization = findDeferredRelease(xaStatefulHolder, currentTransaction); if (deferredReleaseSynchronization != null) { if (log.isDebugEnabled()) log.debug(xaStatefulHolder + " has been recycled, unregistering deferred release from " + currentTransaction); synchronizationScheduler.remove(deferredReleaseSynchronization); } } /* private methods must not call TransactionManagerServices.getTransactionManager().getCurrentTransaction() */ private static boolean isAlreadyRegisteredForDeferredRelease(XAStatefulHolder xaStatefulHolder, BitronixTransaction currentTransaction) { boolean alreadyDeferred = findDeferredRelease(xaStatefulHolder, currentTransaction) != null; if (log.isDebugEnabled()) log.debug(xaStatefulHolder + " is " + (alreadyDeferred ? "" : "not ") + "already registered for deferred release in " + currentTransaction); return alreadyDeferred; } private static DeferredReleaseSynchronization findDeferredRelease(XAStatefulHolder xaStatefulHolder, BitronixTransaction currentTransaction) { Scheduler synchronizationScheduler = currentTransaction.getSynchronizationScheduler(); for (Synchronization synchronization : synchronizationScheduler) { if (synchronization instanceof DeferredReleaseSynchronization) { DeferredReleaseSynchronization deferredReleaseSynchronization = (DeferredReleaseSynchronization) synchronization; if (deferredReleaseSynchronization.getXAStatefulHolder() == xaStatefulHolder) { return deferredReleaseSynchronization; } } // if synchronization instanceof DeferredReleaseSynchronization } // for return null; } private static boolean isEnlistedInSomeTransaction(XAResourceHolder xaResourceHolder) throws BitronixSystemException { if (log.isDebugEnabled()) log.debug("looking in in-flight transactions for XAResourceHolderState of " + xaResourceHolder); if (!TransactionManagerServices.isTransactionManagerRunning()) { if (log.isDebugEnabled()) log.debug("transaction manager not running, there is no in-flight transaction"); return false; } return xaResourceHolder.hasStateForXAResource(xaResourceHolder); } private static boolean isEnlistedInSomeTransaction(XAStatefulHolder xaStatefulHolder) throws BitronixSystemException { List xaResourceHolders = xaStatefulHolder.getXAResourceHolders(); if (xaResourceHolders == null) return false; for (XAResourceHolder xaResourceHolder : xaResourceHolders) { boolean enlisted = isEnlistedInSomeTransaction(xaResourceHolder); if (enlisted) return true; } return false; } private static boolean isInEnlistingGlobalTransactionContext(XAResourceHolder xaResourceHolder, BitronixTransaction currentTransaction) { boolean globalTransactionMode = false; if (currentTransaction != null && xaResourceHolder.getXAResourceHolderStatesForGtrid(currentTransaction.getResourceManager().getGtrid()) != null) { globalTransactionMode = true; } if (log.isDebugEnabled()) log.debug("resource is " + (globalTransactionMode ? "" : "not ") + "in enlisting global transaction context: " + xaResourceHolder); return globalTransactionMode; } private static boolean isInEnlistingGlobalTransactionContext(XAStatefulHolder xaStatefulHolder, BitronixTransaction currentTransaction) { List xaResourceHolders = xaStatefulHolder.getXAResourceHolders(); if (xaResourceHolders == null) return false; for (XAResourceHolder xaResourceHolder : xaResourceHolders) { boolean enlisted = isInEnlistingGlobalTransactionContext(xaResourceHolder, currentTransaction); if (enlisted) return true; } return false; } private static XAResourceHolderState getLatestAlreadyEnlistedXAResourceHolderState(XAResourceHolder xaResourceHolder, BitronixTransaction currentTransaction) { if (currentTransaction == null) return null; Map statesForGtrid = xaResourceHolder.getXAResourceHolderStatesForGtrid(currentTransaction.getResourceManager().getGtrid()); if (statesForGtrid == null) return null; XAResourceHolderState result = null; // iteration order is guraranteed so just take the latest matching one in the iterator for (XAResourceHolderState xaResourceHolderState : statesForGtrid.values()) { if (xaResourceHolderState != null && xaResourceHolderState.getXid() != null) { BitronixXid bitronixXid = xaResourceHolderState.getXid(); Uid resourceGtrid = bitronixXid.getGlobalTransactionIdUid(); Uid currentTransactionGtrid = currentTransaction.getResourceManager().getGtrid(); if (currentTransactionGtrid.equals(resourceGtrid)) { result = xaResourceHolderState; } } } return result; } } btm-dist-2.1.4/src/bitronix/tm/resource/common/XAPool.java0000644000175000017500000005705512147207062022213 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import java.util.*; import javax.transaction.Synchronization; import javax.transaction.xa.XAResource; import org.slf4j.*; import bitronix.tm.*; import bitronix.tm.internal.*; import bitronix.tm.recovery.*; import bitronix.tm.utils.*; import bitronix.tm.utils.CryptoEngine; /** * Generic XA pool. {@link XAStatefulHolder} instances are created by the {@link XAPool} out of a * {@link XAResourceProducer}. Those objects are then pooled and can be retrieved and/or recycled by the pool * depending on the running XA transaction's and the {@link XAStatefulHolder}'s states. * * @author lorban */ public class XAPool implements StateChangeListener { private final static Logger log = LoggerFactory.getLogger(XAPool.class); private final static String PASSWORD_PROPERTY_NAME = "password"; private final Map> statefulHolderTransactionMap = new HashMap>(); private final List objects = new ArrayList(); private final ResourceBean bean; private final XAResourceProducer xaResourceProducer; private final Object xaFactory; private boolean failed = false; public XAPool(XAResourceProducer xaResourceProducer, ResourceBean bean) throws Exception { this.xaResourceProducer = xaResourceProducer; this.bean = bean; if (bean.getMaxPoolSize() < 1 || bean.getMinPoolSize() > bean.getMaxPoolSize()) throw new IllegalArgumentException("cannot create a pool with min " + bean.getMinPoolSize() + " connection(s) and max " + bean.getMaxPoolSize() + " connection(s)"); if (bean.getAcquireIncrement() < 1) throw new IllegalArgumentException("cannot create a pool with a connection acquisition increment less than 1, configured value is " + bean.getAcquireIncrement()); xaFactory = createXAFactory(bean); init(); if (bean.getIgnoreRecoveryFailures()) log.warn("resource '" + bean.getUniqueName() + "' is configured to ignore recovery failures, make sure this setting is not enabled on a production system!"); } private synchronized void init() throws Exception { growUntilMinPoolSize(); if (bean.getMaxIdleTime() > 0) { TransactionManagerServices.getTaskScheduler().schedulePoolShrinking(this); } } public Object getXAFactory() { return xaFactory; } public synchronized void setFailed(boolean failed) { this.failed = failed; } public synchronized boolean isFailed() { return failed; } public synchronized Object getConnectionHandle() throws Exception { return getConnectionHandle(true); } public synchronized Object getConnectionHandle(boolean recycle) throws Exception { if (failed) { try { if (log.isDebugEnabled()) log.debug("resource '" + bean.getUniqueName() + "' is marked as failed, resetting and recovering it before trying connection acquisition"); close(); init(); IncrementalRecoverer.recover(xaResourceProducer); } catch (RecoveryException ex) { throw new BitronixRuntimeException("incremental recovery failed when trying to acquire a connection from failed resource '" + bean.getUniqueName() + "'", ex); } catch (Exception ex) { throw new BitronixRuntimeException("pool reset failed when trying to acquire a connection from failed resource '" + bean.getUniqueName() + "'", ex); } } long remainingTime = bean.getAcquisitionTimeout() * 1000L; while (true) { long before = MonotonicClock.currentTimeMillis(); XAStatefulHolder xaStatefulHolder = null; if (recycle) { if (bean.getShareTransactionConnections()) { xaStatefulHolder = getSharedXAStatefulHolder(); } else { xaStatefulHolder = getNotAccessible(); } } if (xaStatefulHolder == null) { xaStatefulHolder = getInPool(); } if (log.isDebugEnabled()) log.debug("found " + Decoder.decodeXAStatefulHolderState(xaStatefulHolder.getState()) + " connection " + xaStatefulHolder + " from " + this); try { // getConnection() here could throw an exception, if it doesn't the connection is // still alive and we can share it (if sharing is enabled) Object connectionHandle = xaStatefulHolder.getConnectionHandle(); if (bean.getShareTransactionConnections()) { putSharedXAStatefulHolder(xaStatefulHolder); } growUntilMinPoolSize(); return connectionHandle; } catch (Exception ex) { if (log.isDebugEnabled()) log.debug("connection is invalid, trying to close it", ex); try { xaStatefulHolder.close(); } catch (Exception ex2) { if (log.isDebugEnabled()) log.debug("exception while trying to close invalid connection, ignoring it", ex2); } objects.remove(xaStatefulHolder); if (log.isDebugEnabled()) log.debug("removed invalid connection " + xaStatefulHolder + " from " + this); if (log.isDebugEnabled()) log.debug("waiting " + bean.getAcquisitionInterval() + "s before trying to acquire a connection again from " + this); long waitTime = bean.getAcquisitionInterval() * 1000L; if (waitTime > 0) { try { wait(waitTime); } catch (InterruptedException ex2) { // ignore } } // check for timeout long now = MonotonicClock.currentTimeMillis(); remainingTime -= (now - before); if (remainingTime <= 0) { throw new BitronixRuntimeException("cannot get valid connection from " + this + " after trying for " + bean.getAcquisitionTimeout() + "s", ex); } } } // while true } public synchronized void close() { if (log.isDebugEnabled()) log.debug("closing all connections of " + this); for (XAStatefulHolder xaStatefulHolder : objects) { try { // This change is unrelated to BTM-35, but suppresses noise in the unit test output. // Connections that are already in STATE_CLOSED should not be closed again. if (xaStatefulHolder.getState() != XAStatefulHolder.STATE_CLOSED) { xaStatefulHolder.close(); } } catch (Exception ex) { if (log.isDebugEnabled()) log.debug("ignoring exception while closing connection " + xaStatefulHolder, ex); } } if (TransactionManagerServices.isTaskSchedulerRunning()) TransactionManagerServices.getTaskScheduler().cancelPoolShrinking(this); objects.clear(); failed = false; } public synchronized long totalPoolSize() { return objects.size(); } public synchronized long inPoolSize() { int count = 0; for (XAStatefulHolder xaStatefulHolder : objects) { if (xaStatefulHolder.getState() == XAStatefulHolder.STATE_IN_POOL) count++; } return count; } public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == XAStatefulHolder.STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("a connection's state changed to IN_POOL, notifying a thread eventually waiting for a connection"); synchronized (this) { notify(); } } } public void stateChanging(XAStatefulHolder source, int currentState, int futureState) { } public synchronized XAResourceHolder findXAResourceHolder(XAResource xaResource) { for (XAStatefulHolder xaStatefulHolder : objects) { List xaResourceHolders = xaStatefulHolder.getXAResourceHolders(); for (XAResourceHolder holder : xaResourceHolders) { if (holder.getXAResource() == xaResource) return holder; } } return null; } // used for testing List getXAResourceHolders() { return Collections.unmodifiableList(objects); } public Date getNextShrinkDate() { return new Date(MonotonicClock.currentTimeMillis() + bean.getMaxIdleTime() * 1000); } public synchronized void shrink() throws Exception { if (log.isDebugEnabled()) log.debug("shrinking " + this); List toRemoveXaStatefulHolders = new ArrayList(); long now = MonotonicClock.currentTimeMillis(); for (XAStatefulHolder xaStatefulHolder : objects) { if (xaStatefulHolder.getState() != XAStatefulHolder.STATE_IN_POOL) continue; long expirationTime = (xaStatefulHolder.getLastReleaseDate().getTime() + (bean.getMaxIdleTime() * 1000)); if (log.isDebugEnabled()) log.debug("checking if connection can be closed: " + xaStatefulHolder + " - closing time: " + expirationTime + ", now time: " + now); if (expirationTime <= now) { try { xaStatefulHolder.close(); } catch (Exception ex) { log.warn("error closing " + xaStatefulHolder, ex); } toRemoveXaStatefulHolders.add(xaStatefulHolder); } } // for if (log.isDebugEnabled()) log.debug("closed " + toRemoveXaStatefulHolders.size() + " idle connection(s)"); objects.removeAll(toRemoveXaStatefulHolders); growUntilMinPoolSize(); if (log.isDebugEnabled()) log.debug("shrunk " + this); } public synchronized void reset() throws Exception { if (log.isDebugEnabled()) log.debug("resetting " + this); List toRemoveXaStatefulHolders = new ArrayList(); for (XAStatefulHolder xaStatefulHolder : objects) { if (xaStatefulHolder.getState() != XAStatefulHolder.STATE_IN_POOL) continue; try { xaStatefulHolder.close(); } catch (Exception ex) { log.warn("error closing " + xaStatefulHolder, ex); } toRemoveXaStatefulHolders.add(xaStatefulHolder); } if (log.isDebugEnabled()) log.debug("closed " + toRemoveXaStatefulHolders.size() + " connection(s)"); objects.removeAll(toRemoveXaStatefulHolders); growUntilMinPoolSize(); if (log.isDebugEnabled()) log.debug("reset " + this); } public String toString() { return "an XAPool of resource " + bean.getUniqueName() + " with " + totalPoolSize() + " connection(s) (" + inPoolSize() + " still available)" + (failed ? " -failed-" : ""); } private synchronized void createPooledObject(Object xaFactory) throws Exception { XAStatefulHolder xaStatefulHolder = xaResourceProducer.createPooledConnection(xaFactory, bean); xaStatefulHolder.addStateChangeEventListener(this); objects.add(xaStatefulHolder); } private static Object createXAFactory(ResourceBean bean) throws Exception { String className = bean.getClassName(); if (className == null) throw new IllegalArgumentException("className cannot be null"); Class xaFactoryClass = ClassLoaderUtils.loadClass(className); Object xaFactory = xaFactoryClass.newInstance(); for (Map.Entry entry : bean.getDriverProperties().entrySet()) { String name = (String) entry.getKey(); Object value = entry.getValue(); if (name.endsWith(PASSWORD_PROPERTY_NAME)) { value = decrypt((String) value); } if (log.isDebugEnabled()) log.debug("setting vendor property '" + name + "' to '" + value + "'"); PropertyUtils.setProperty(xaFactory, name, value); } return xaFactory; } private static String decrypt(String resourcePassword) throws Exception { int startIdx = resourcePassword.indexOf("{"); int endIdx = resourcePassword.indexOf("}"); if (startIdx != 0 || endIdx == -1) return resourcePassword; String cipher = resourcePassword.substring(1, endIdx); if (log.isDebugEnabled()) log.debug("resource password is encrypted, decrypting " + resourcePassword); return CryptoEngine.decrypt(cipher, resourcePassword.substring(endIdx + 1)); } private synchronized XAStatefulHolder getNotAccessible() { if (log.isDebugEnabled()) log.debug("trying to recycle a NOT_ACCESSIBLE connection of " + this); BitronixTransaction transaction = TransactionContextHelper.currentTransaction(); if (transaction == null) { if (log.isDebugEnabled()) log.debug("no current transaction, no connection can be in state NOT_ACCESSIBLE when there is no global transaction context"); return null; } Uid currentTxGtrid = transaction.getResourceManager().getGtrid(); if (log.isDebugEnabled()) log.debug("current transaction GTRID is [" + currentTxGtrid + "]"); for (XAStatefulHolder xaStatefulHolder : objects) { if (xaStatefulHolder.getState() == XAStatefulHolder.STATE_NOT_ACCESSIBLE) { if (log.isDebugEnabled()) log.debug("found a connection in NOT_ACCESSIBLE state: " + xaStatefulHolder); if (containsXAResourceHolderMatchingGtrid(xaStatefulHolder, currentTxGtrid)) return xaStatefulHolder; } } // for if (log.isDebugEnabled()) log.debug("no NOT_ACCESSIBLE connection enlisted in this transaction"); return null; } private static boolean containsXAResourceHolderMatchingGtrid(XAStatefulHolder xaStatefulHolder, Uid currentTxGtrid) { List xaResourceHolders = xaStatefulHolder.getXAResourceHolders(); if (log.isDebugEnabled()) log.debug(xaResourceHolders.size() + " xa resource(s) created by connection in NOT_ACCESSIBLE state: " + xaStatefulHolder); for (XAResourceHolder xaResourceHolder : xaResourceHolders) { Map statesForGtrid = xaResourceHolder.getXAResourceHolderStatesForGtrid(currentTxGtrid); if (statesForGtrid == null) return false; for (XAResourceHolderState xaResourceHolderState : statesForGtrid.values()) { // compare GTRIDs BitronixXid bitronixXid = xaResourceHolderState.getXid(); Uid resourceGtrid = bitronixXid.getGlobalTransactionIdUid(); if (log.isDebugEnabled()) log.debug("NOT_ACCESSIBLE xa resource GTRID: " + resourceGtrid); if (currentTxGtrid.equals(resourceGtrid)) { if (log.isDebugEnabled()) log.debug("NOT_ACCESSIBLE xa resource's GTRID matched this transaction's GTRID, recycling it"); return true; } } } return false; } private synchronized XAStatefulHolder getInPool() throws Exception { if (log.isDebugEnabled()) log.debug("getting a IN_POOL connection from " + this); if (inPoolSize() == 0) { if (log.isDebugEnabled()) log.debug("no more free connection in " + this + ", trying to grow it"); grow(); } waitForConnectionInPool(); for (XAStatefulHolder xaStatefulHolder : objects) { if (xaStatefulHolder.getState() == XAStatefulHolder.STATE_IN_POOL) return xaStatefulHolder; } throw new BitronixRuntimeException("pool does not contain IN_POOL connection while it should !"); } private synchronized void grow() throws Exception { if (totalPoolSize() < bean.getMaxPoolSize()) { long increment = bean.getAcquireIncrement(); if (totalPoolSize() + increment > bean.getMaxPoolSize()) { increment = bean.getMaxPoolSize() - totalPoolSize(); } if (log.isDebugEnabled()) log.debug("incrementing " + bean.getUniqueName() + " pool size by " + increment + " unit(s) to reach " + (totalPoolSize() + increment) + " connection(s)"); for (int i=0; i < increment ;i++) { createPooledObject(xaFactory); } } else { if (log.isDebugEnabled()) log.debug("pool " + bean.getUniqueName() + " already at max size of " + totalPoolSize() + " connection(s), not growing it"); } } private synchronized void growUntilMinPoolSize() throws Exception { for (int i = (int)totalPoolSize(); i < bean.getMinPoolSize() ;i++) { createPooledObject(xaFactory); } } private synchronized void waitForConnectionInPool() { long remainingTime = bean.getAcquisitionTimeout() * 1000L; if (log.isDebugEnabled()) log.debug("waiting for IN_POOL connections count to be > 0, currently is " + inPoolSize()); while (inPoolSize() == 0) { long before = MonotonicClock.currentTimeMillis(); try { if (log.isDebugEnabled()) log.debug("waiting " + remainingTime + "ms"); wait(remainingTime); if (log.isDebugEnabled()) log.debug("waiting over, IN_POOL connections count is now " + inPoolSize()); } catch (InterruptedException ex) { // ignore } long now = MonotonicClock.currentTimeMillis(); remainingTime -= (now - before); if (remainingTime <= 0 && inPoolSize() == 0) { if (log.isDebugEnabled()) log.debug("connection pool dequeue timed out"); if (TransactionManagerServices.isTransactionManagerRunning()) TransactionManagerServices.getTransactionManager().dumpTransactionContexts(); throw new BitronixRuntimeException("XA pool of resource " + bean.getUniqueName() + " still empty after " + bean.getAcquisitionTimeout() + "s wait time"); } } // while } /** * Shared Connection Handling */ /** * Try to get a shared XAStatefulHolder. This method will either return * a shared XAStatefulHolder or null. If there is no current * transaction, XAStatefulHolder's are not shared. If there is a transaction * and there is a XAStatefulHolder associated with this thread already, * we return that XAStatefulHolder (provided it is ACCESSIBLE or NOT_ACCESSIBLE). * * @return a shared XAStatefulHolder or null */ private synchronized XAStatefulHolder getSharedXAStatefulHolder() { BitronixTransaction transaction = TransactionContextHelper.currentTransaction(); if (transaction == null) { if (log.isDebugEnabled()) log.debug("no current transaction, shared connection map will not be used"); return null; } Uid currentTxGtrid = transaction.getResourceManager().getGtrid(); ThreadLocal threadLocal = statefulHolderTransactionMap.get(currentTxGtrid); if (threadLocal != null) { XAStatefulHolder xaStatefulHolder = threadLocal.get(); // Additional sanity checks... if (xaStatefulHolder != null && xaStatefulHolder.getState() != XAStatefulHolder.STATE_IN_POOL && xaStatefulHolder.getState() != XAStatefulHolder.STATE_CLOSED) { if (log.isDebugEnabled()) log.debug("sharing connection " + xaStatefulHolder + " in transaction " + currentTxGtrid); return xaStatefulHolder; } } return null; } /** * Try to share a XAStatefulHolder with other callers on this thread. If * there is no current transaction, the XAStatefulHolder is not put into the * ThreadLocal. If there is a transaction, and it is the first time we're * attempting to share a XAStatefulHolder on this thread, then we register * a Synchronization so we can pull the ThreadLocals out of the shared map * when the transaction completes (either commit() or rollback()). Without * the Synchronization we would "leak". * * @param xaStatefulHolder a XAStatefulHolder to share with other callers * on this thread. */ private synchronized void putSharedXAStatefulHolder(XAStatefulHolder xaStatefulHolder) { BitronixTransaction transaction = TransactionContextHelper.currentTransaction(); if (transaction == null) { if (log.isDebugEnabled()) log.debug("no current transaction, not adding " + xaStatefulHolder + " to shared connection map"); return; } final Uid currentTxGtrid = transaction.getResourceManager().getGtrid(); ThreadLocal threadLocal = statefulHolderTransactionMap.get(currentTxGtrid); if (threadLocal == null) { // This is the first time this TxGtrid/ThreadLocal is going into the map, // register interest in synchronization so we can remove it at commit/rollback try { transaction.registerSynchronization(new SharedStatefulHolderCleanupSynchronization(currentTxGtrid)); } catch (Exception e) { // OK, forget it. The transaction is either rollback only or already finished. return; } threadLocal = new ThreadLocal(); statefulHolderTransactionMap.put(currentTxGtrid, threadLocal); if (log.isDebugEnabled()) log.debug("added shared connection mapping for " + currentTxGtrid + " holder " + xaStatefulHolder); } // Set the XAStatefulHolder on the ThreadLocal. Even if we've already set it before, // it's safe -- checking would be more expensive than just setting it again. threadLocal.set(xaStatefulHolder); } private final class SharedStatefulHolderCleanupSynchronization implements Synchronization { private final Uid gtrid; private SharedStatefulHolderCleanupSynchronization(Uid gtrid) { this.gtrid = gtrid; } public void beforeCompletion() { } public void afterCompletion(int status) { synchronized (XAPool.this) { statefulHolderTransactionMap.remove(gtrid); if (log.isDebugEnabled()) log.debug("deleted shared connection mappings for " + gtrid); } } public String toString() { return "a SharedStatefulHolderCleanupSynchronization with GTRID [" + gtrid + "]"; } } } btm-dist-2.1.4/src/bitronix/tm/resource/common/AbstractXAStatefulHolder.java0000644000175000017500000000654512147207062025711 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import java.util.*; import org.slf4j.*; import bitronix.tm.utils.Decoder; /** * Implementation of all services required by a {@link XAStatefulHolder}. * * @author lorban */ public abstract class AbstractXAStatefulHolder implements XAStatefulHolder { private final static Logger log = LoggerFactory.getLogger(AbstractXAStatefulHolder.class); private volatile int state = STATE_IN_POOL; private final List stateChangeEventListeners = new ArrayList(); public int getState() { return state; } public void setState(int state) { int oldState = this.state; fireStateChanging(oldState, state); if (oldState == state) throw new IllegalArgumentException("cannot switch state from " + Decoder.decodeXAStatefulHolderState(oldState) + " to " + Decoder.decodeXAStatefulHolderState(state)); if (log.isDebugEnabled()) log.debug("state changing from " + Decoder.decodeXAStatefulHolderState(oldState) + " to " + Decoder.decodeXAStatefulHolderState(state) + " in " + this); this.state = state; fireStateChanged(oldState, state); } public void addStateChangeEventListener(StateChangeListener listener) { stateChangeEventListeners.add(listener); } public void removeStateChangeEventListener(StateChangeListener listener) { stateChangeEventListeners.remove(listener); } private void fireStateChanging(int currentState, int futureState) { if (log.isDebugEnabled()) log.debug("notifying " + stateChangeEventListeners.size() + " stateChangeEventListener(s) about state changing from " + Decoder.decodeXAStatefulHolderState(currentState) + " to " + Decoder.decodeXAStatefulHolderState(futureState) + " in " + this); for (StateChangeListener stateChangeListener : stateChangeEventListeners) { stateChangeListener.stateChanging(this, currentState, futureState); } } private void fireStateChanged(int oldState, int newState) { if (log.isDebugEnabled()) log.debug("notifying " + stateChangeEventListeners.size() + " stateChangeEventListener(s) about state changed from " + Decoder.decodeXAStatefulHolderState(oldState) + " to " + Decoder.decodeXAStatefulHolderState(newState) + " in " + this); for (StateChangeListener stateChangeListener : stateChangeEventListeners) { stateChangeListener.stateChanged(this, oldState, newState); } } } btm-dist-2.1.4/src/bitronix/tm/resource/common/XAResourceHolder.java0000644000175000017500000000612412147207062024216 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import bitronix.tm.BitronixXid; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.utils.Uid; import javax.transaction.xa.XAResource; import java.util.Map; /** * {@link XAResource} wrappers must implement this interface. It defines a way to get access to the transactional * state of this {@link XAResourceHolder}. * * @see XAResourceHolderState * @author lorban */ public interface XAResourceHolder extends XAStatefulHolder { /** * Get the vendor's {@link XAResource} implementation of the wrapped resource. * @return the vendor's XAResource implementation. */ public XAResource getXAResource(); /** * Get all the {@link XAResourceHolderState}s of this wrapped resource for a specific GTRID. *

The returned Map is guaranteed to return states in order they were added when its values are iterated.

* @param gtrid the GTRID of the transaction state to add. * @return the {@link XAResourceHolderState}. */ public Map getXAResourceHolderStatesForGtrid(Uid gtrid); /** * Add a {@link XAResourceHolderState} of this wrapped resource. * @param xid the Xid of the transaction state to add. * @param xaResourceHolderState the {@link XAResourceHolderState} to set. */ public void putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState); /** * Remove all states related to a specific Xid from this wrapped resource. * @param xid the Xid of the transaction state to remove. */ public void removeXAResourceHolderState(BitronixXid xid); /** * Check if this {@link XAResourceHolder} contains a state for a specific {@link XAResourceHolder}. * In other words: has the {@link XAResourceHolder}'s {@link XAResource} been enlisted in some transaction ? * @param xaResourceHolder the {@link XAResourceHolder} to look for. * @return true if the {@link XAResourceHolder} is enlisted in some transaction, false otherwise. */ public boolean hasStateForXAResource(XAResourceHolder xaResourceHolder); /** * Get the ResourceBean which created this XAResourceHolder. * @return the ResourceBean which created this XAResourceHolder. */ public ResourceBean getResourceBean(); } btm-dist-2.1.4/src/bitronix/tm/resource/common/XAStatefulHolder.java0000644000175000017500000001016512147207062024216 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import java.util.List; import java.util.Date; /** * Any pooled connection class must implement the {@link XAStatefulHolder} interface. It defines all the services * that must be implemented by the connection as well as the pooling lifecycle states. * Instances of this interface have to create and manage {@link XAResourceHolder}s. * * @author lorban */ public interface XAStatefulHolder { /** * The state in which the resource is when it is closed and unusable. */ public final static int STATE_CLOSED = 0; /** * The state in which the resource is when it is available in the pool. */ public final static int STATE_IN_POOL = 1; /** * The state in which the resource is when it out of the pool but accessible by the application. */ public final static int STATE_ACCESSIBLE = 2; /** * The state in which the resource is when it out of the pool but not accessible by the application. */ public final static int STATE_NOT_ACCESSIBLE = 3; /** * Get the current resource state. *

This method is thread-safe.

* @return the current resource state. */ public int getState(); /** * Set the current resource state. *

This method is thread-safe.

* @param state the current resource state. */ public void setState(int state); /** * Register an implementation of {@link StateChangeListener}. * @param listener the {@link StateChangeListener} implementation to register. */ public void addStateChangeEventListener(StateChangeListener listener); /** * Unregister an implementation of {@link StateChangeListener}. * @param listener the {@link StateChangeListener} implementation to unregister. */ public void removeStateChangeEventListener(StateChangeListener listener); /** * Get the list of {@link bitronix.tm.resource.common.XAResourceHolder}s created by this * {@link bitronix.tm.resource.common.XAStatefulHolder} that are still open. *

This method is thread-safe.

* @return the list of {@link XAResourceHolder}s created by this * {@link bitronix.tm.resource.common.XAStatefulHolder} that are still open. */ public List getXAResourceHolders(); /** * Create a disposable handler used to drive a pooled instance of * {@link bitronix.tm.resource.common.XAStatefulHolder}. *

This method is thread-safe.

* @return a resource-specific disaposable connection object. * @throws Exception a resource-specific exception thrown when the disaposable connection cannot be created. */ public Object getConnectionHandle() throws Exception; /** * Close the physical connection that this {@link bitronix.tm.resource.common.XAStatefulHolder} represents. * @throws Exception a resource-specific exception thrown when there is an error closing the physical connection. */ public void close() throws Exception; /** * Get the date at which this object was last released to the pool. This is required to check if it is eligible * for discard when the containing pool needs to shrink. * @return the date at which this object was last released to the pool or null if it never left the pool. */ public Date getLastReleaseDate(); } btm-dist-2.1.4/src/bitronix/tm/resource/common/DeferredReleaseSynchronization.java0000644000175000017500000000404412147207062027202 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.Synchronization; /** * {@link Synchronization} used to release a {@link XAStatefulHolder} object after 2PC has executed. * * @author lorban */ public class DeferredReleaseSynchronization implements Synchronization { private final static Logger log = LoggerFactory.getLogger(DeferredReleaseSynchronization.class); private final XAStatefulHolder xaStatefulHolder; public DeferredReleaseSynchronization(XAStatefulHolder xaStatefulHolder) { this.xaStatefulHolder = xaStatefulHolder; } public XAStatefulHolder getXAStatefulHolder() { return xaStatefulHolder; } public void afterCompletion(int status) { if (log.isDebugEnabled()) log.debug("DeferredReleaseSynchronization requeuing " + xaStatefulHolder); // set this connection's state back to IN_POOL xaStatefulHolder.setState(XAResourceHolder.STATE_IN_POOL); if (log.isDebugEnabled()) log.debug("DeferredReleaseSynchronization requeued " + xaStatefulHolder); } public void beforeCompletion() { } public String toString() { return "a DeferredReleaseSynchronization of " + xaStatefulHolder; } } btm-dist-2.1.4/src/bitronix/tm/resource/common/RecoveryXAResourceHolder.java0000644000175000017500000000372512147207062025741 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import javax.transaction.xa.XAResource; import java.util.Date; import java.util.List; /** * {@link XAResourceHolder} created by an {@link bitronix.tm.resource.common.XAResourceProducer} that is * used to perform recovery. Objects of this class cannot be used outside recovery scope. * * @author lorban */ public class RecoveryXAResourceHolder extends AbstractXAResourceHolder { private final XAResourceHolder xaResourceHolder; public RecoveryXAResourceHolder(XAResourceHolder xaResourceHolder) { this.xaResourceHolder = xaResourceHolder; } public void close() throws Exception { xaResourceHolder.setState(STATE_IN_POOL); } public Date getLastReleaseDate() { return null; } public XAResource getXAResource() { return xaResourceHolder.getXAResource(); } public ResourceBean getResourceBean() { return null; } public List getXAResourceHolders() { return null; } public Object getConnectionHandle() throws Exception { throw new UnsupportedOperationException("illegal connection creation attempt out of " + this); } } btm-dist-2.1.4/src/bitronix/tm/resource/common/ResourceBean.java0000644000175000017500000003063512147207062023421 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import java.io.Serializable; import java.util.Properties; /** * Abstract javabean container for all common properties of a {@link bitronix.tm.resource.common.XAResourceProducer} as configured in the * resources configuration file. * * @author lorban */ public abstract class ResourceBean implements Serializable { private volatile String className; private volatile String uniqueName; private volatile boolean automaticEnlistingEnabled = true; private volatile boolean useTmJoin = true; private volatile Properties driverProperties = new Properties(); private volatile int maxPoolSize = 0; private volatile int minPoolSize = 0; private volatile int maxIdleTime = 60; private volatile int acquireIncrement = 1; private volatile int acquisitionTimeout = 30; private volatile boolean deferConnectionRelease = true; private volatile int acquisitionInterval = 1; private volatile boolean allowLocalTransactions = false; private volatile int twoPcOrderingPosition = 1; private volatile boolean applyTransactionTimeout = false; private volatile boolean shareTransactionConnections = false; private volatile boolean disabled = false; private volatile boolean ignoreRecoveryFailures = false; private volatile transient int createdResourcesCounter; /** * Initialize all properties with their default values. */ protected ResourceBean() { } /** * @return the underlying implementation class name. */ public String getClassName() { return className; } /** * Specify the underlying implementation class name of the XA resource described by this bean. * @param className the underlying implementation class name. */ public void setClassName(String className) { this.className = className; } /** * @return the resource's unique name. */ public String getUniqueName() { return uniqueName; } /** * Specify the resource unique name to be used to identify this resource during recovery. This name will be * registered in the transactions journal so once assigned it must never be changed. * @param uniqueName the resource's unique name. */ public void setUniqueName(String uniqueName) { this.uniqueName = uniqueName; } /** * @return true if the the XA resource wrapper should enlist/delist this resource automatically in global * transactions. */ public boolean getAutomaticEnlistingEnabled() { return automaticEnlistingEnabled; } /** * Specify if the XA resource wrapper should enlist/delist this resource automatically in global transactions. * When set to false, you have to enlist resources yourself with {@link javax.transaction.Transaction#enlistResource(javax.transaction.xa.XAResource)} and delist them * {@link javax.transaction.Transaction#delistResource(javax.transaction.xa.XAResource, int)}. * @param automaticEnlistingEnabled true if the the XA resource wrapper should enlist/delist this resource automatically in global * transactions. */ public void setAutomaticEnlistingEnabled(boolean automaticEnlistingEnabled) { this.automaticEnlistingEnabled = automaticEnlistingEnabled; } /** * @return true if transaction branches joining should be used. */ public boolean getUseTmJoin() { return useTmJoin; } /** * Specify if the transaction manager should try to join resources by calling * {@link javax.transaction.xa.XAResource#start(javax.transaction.xa.Xid, int)} with * {@link javax.transaction.xa.XAResource#TMJOIN}. The transaction manager checks if two branches can be joined by * calling {@link javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)}. * It should only be set to true if the underlying implementation supports resource joining. * @param useTmJoin true if transaction branches joining should be used. */ public void setUseTmJoin(boolean useTmJoin) { this.useTmJoin = useTmJoin; } /** * @return the properties that should be set on the underlying implementation. */ public Properties getDriverProperties() { return driverProperties; } /** * Set the properties that should be set on the underlying implementation. * @param driverProperties the properties that should be set on the underlying implementation. */ public void setDriverProperties(Properties driverProperties) { this.driverProperties = driverProperties; } /** * @return the maximum amount of connections that can be in the pool. */ public int getMaxPoolSize() { return maxPoolSize; } /** * Define the maximum amount of connections that can be in the pool. * @param maxPoolSize the maximum amount of connections that can be in the pool. */ public void setMaxPoolSize(int maxPoolSize) { this.maxPoolSize = maxPoolSize; } /** * @return the minimal amount of connections that can be in the pool. */ public int getMinPoolSize() { return minPoolSize; } /** * Define the minimal amount of connections that can be in the pool. * @param minPoolSize the maximum amount of connections that can be in the pool. */ public void setMinPoolSize(int minPoolSize) { this.minPoolSize = minPoolSize; } /** * @return the amount of seconds and idle connection can stay in the pool before getting closed. */ public int getMaxIdleTime() { return maxIdleTime; } /** * Define the amount of seconds and idle connection can stay in the pool before getting closed. * @param maxIdleTime the amount of seconds and idle connection can stay in the pool before getting closed. */ public void setMaxIdleTime(int maxIdleTime) { this.maxIdleTime = maxIdleTime; } /** * @return the amount of connections to be created at once when the pool needs to grow. */ public int getAcquireIncrement() { return acquireIncrement; } /** * Define the amount of connections to be created at once when the pool needs to grow. * @param acquireIncrement the amount of connections to be created at once when the pool needs to grow. */ public void setAcquireIncrement(int acquireIncrement) { this.acquireIncrement = acquireIncrement; } /** * @return the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty. */ public int getAcquisitionTimeout() { return acquisitionTimeout; } /** * Define the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty. * @param acquisitionTimeout the amount of time in seconds. */ public void setAcquisitionTimeout(int acquisitionTimeout) { this.acquisitionTimeout = acquisitionTimeout; } /** * @return false only if the database can run many transactions on the same connection. */ public boolean getDeferConnectionRelease() { return deferConnectionRelease; } /** * Define the transaction interleaving capability of the database. * Should be true only if the database can run many transactions on the same connection. * @param deferConnectionRelease false only if the database can run many transactions on the same connection. */ public void setDeferConnectionRelease(boolean deferConnectionRelease) { this.deferConnectionRelease = deferConnectionRelease; } /** * @return the amount of time between failed connection acquirements. */ public int getAcquisitionInterval() { return acquisitionInterval; } /** * Set the amount of time in seconds the pool will wait before trying to acquire a connection again after an * invalid connection has been attempted to be acquired. * @param acquisitionInterval amount of time in seconds. */ public void setAcquisitionInterval(int acquisitionInterval) { this.acquisitionInterval = acquisitionInterval; } /** * @return true if the transaction manager should allow mixing XA and non-XA transactions. */ public boolean getAllowLocalTransactions() { return allowLocalTransactions; } /** * Set if the transaction manager should allow mixing XA and non-XA transactions. If you know all your transactions * should be executed within global (ie: XA) scope it is a good idea to set this property to false. * @param allowLocalTransactions if the transaction manager should allow mixing XA and non-XA transactions. */ public void setAllowLocalTransactions(boolean allowLocalTransactions) { this.allowLocalTransactions = allowLocalTransactions; } /** * @return the position at which this resource should stand during 2PC commit. */ public int getTwoPcOrderingPosition() { return twoPcOrderingPosition; } /** * Set the position at which this resource should stand during 2PC commit. * @param twoPcOrderingPosition the position at which this resource should stand during 2PC commit. */ public void setTwoPcOrderingPosition(int twoPcOrderingPosition) { this.twoPcOrderingPosition = twoPcOrderingPosition; } /** * @return true if the transaction-timeout should be set on the XAResource. */ public boolean getApplyTransactionTimeout() { return applyTransactionTimeout; } /** * Set if the transaction-timeout should be set on the XAResource when the XAResource is * enlisted. * @param applyTransactionTimeout true if the transaction-timeout should be set. */ public void setApplyTransactionTimeout(boolean applyTransactionTimeout) { this.applyTransactionTimeout = applyTransactionTimeout; } /** * Set whether connections in the ACCESSIBLE state can be shared within the context * of a transaction. * @param shareAccessibleConnections the shareAccessibleConnections to set. */ public void setShareTransactionConnections(boolean shareAccessibleConnections) { this.shareTransactionConnections = shareAccessibleConnections; } /** * @return true if accessible connections can be shared. */ public boolean getShareTransactionConnections() { return shareTransactionConnections; } /** * Set whether XA recovery errors should quarantine the resource or be ignored. * @param ignoreRecoveryFailures true if recovery errors should be ignored, false otherwise. */ public void setIgnoreRecoveryFailures(boolean ignoreRecoveryFailures) { this.ignoreRecoveryFailures = ignoreRecoveryFailures; } /** * @return true if recovery errors should be ignored, false otherwise. */ public boolean getIgnoreRecoveryFailures() { return ignoreRecoveryFailures; } /** * Set whether this resource is disabled, meaning it's temporarily forbidden to acquire * a connection from its pool. * @param disabled true to disable the resource, false to enable it. */ public void setDisabled(boolean disabled) { this.disabled = disabled; } /** * @return true if the resource is disabled, false if it is enabled. */ public boolean isDisabled() { return disabled; } /** * Increment a transient counter. This is used for assigning per-resource numbers to connections. * @return the current value of the counter. */ public int incCreatedResourcesCounter() { return this.createdResourcesCounter++; } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/0000755000175000017500000000000012147207062017473 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/resource/jms/package.html0000644000175000017500000000015712147207062021757 0ustar tonytony

Synchronous JMS specific resource management code.

btm-dist-2.1.4/src/bitronix/tm/resource/jms/JmsPooledConnection.java0000644000175000017500000002670212147207062024261 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import bitronix.tm.internal.BitronixSystemException; import bitronix.tm.resource.common.AbstractXAStatefulHolder; import bitronix.tm.resource.common.RecoveryXAResourceHolder; import bitronix.tm.resource.common.StateChangeListener; import bitronix.tm.resource.common.TransactionContextHelper; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.resource.common.XAStatefulHolder; import bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.ManagementRegistrar; import bitronix.tm.utils.MonotonicClock; import bitronix.tm.utils.Scheduler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jms.JMSException; import javax.jms.Session; import javax.jms.TemporaryQueue; import javax.jms.XAConnection; import javax.jms.XASession; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; /** * Implementation of a JMS pooled connection wrapping vendor's {@link XAConnection} implementation. * * @author lorban * TODO: how can the JMS connection be accurately tested? */ public class JmsPooledConnection extends AbstractXAStatefulHolder implements JmsPooledConnectionMBean { private final static Logger log = LoggerFactory.getLogger(JmsPooledConnection.class); private final XAConnection xaConnection; private final PoolingConnectionFactory poolingConnectionFactory; private final List sessions = Collections.synchronizedList(new ArrayList()); private boolean closed = false; /* management */ private final String jmxName; private volatile Date acquisitionDate; private volatile Date lastReleaseDate; protected JmsPooledConnection(PoolingConnectionFactory poolingConnectionFactory, XAConnection connection) { this.poolingConnectionFactory = poolingConnectionFactory; this.xaConnection = connection; this.lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); addStateChangeEventListener(new JmsPooledConnectionStateChangeListener()); if (poolingConnectionFactory.getClassName().equals(LrcXAConnectionFactory.class.getName())) { if (log.isDebugEnabled()) log.debug("emulating XA for resource " + poolingConnectionFactory.getUniqueName() + " - changing twoPcOrderingPosition to ALWAYS_LAST_POSITION"); poolingConnectionFactory.setTwoPcOrderingPosition(Scheduler.ALWAYS_LAST_POSITION); if (log.isDebugEnabled()) log.debug("emulating XA for resource " + poolingConnectionFactory.getUniqueName() + " - changing deferConnectionRelease to true"); poolingConnectionFactory.setDeferConnectionRelease(true); if (log.isDebugEnabled()) log.debug("emulating XA for resource " + poolingConnectionFactory.getUniqueName() + " - changing useTmJoin to true"); poolingConnectionFactory.setUseTmJoin(true); } this.jmxName = "bitronix.tm:type=JMS,UniqueName=" + ManagementRegistrar.makeValidName(poolingConnectionFactory.getUniqueName()) + ",Id=" + poolingConnectionFactory.incCreatedResourcesCounter(); ManagementRegistrar.register(jmxName, this); } public XAConnection getXAConnection() { return xaConnection; } public PoolingConnectionFactory getPoolingConnectionFactory() { return poolingConnectionFactory; } public synchronized RecoveryXAResourceHolder createRecoveryXAResourceHolder() throws JMSException { DualSessionWrapper dualSessionWrapper = new DualSessionWrapper(this, false, 0); dualSessionWrapper.getSession(true); // force creation of XASession to allow access to XAResource return new RecoveryXAResourceHolder(dualSessionWrapper); } public synchronized void close() throws JMSException { if (!closed) { setState(STATE_CLOSED); xaConnection.close(); } closed = true; } public List getXAResourceHolders() { synchronized (sessions) { return new ArrayList(sessions); } } public Object getConnectionHandle() throws Exception { if (log.isDebugEnabled()) log.debug("getting connection handle from " + this); int oldState = getState(); setState(STATE_ACCESSIBLE); if (oldState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("connection " + xaConnection + " was in state IN_POOL, testing it"); testXAConnection(); } else { if (log.isDebugEnabled()) log.debug("connection " + xaConnection + " was in state " + Decoder.decodeXAStatefulHolderState(oldState) + ", no need to test it"); } if (log.isDebugEnabled()) log.debug("got connection handle from " + this); return new JmsConnectionHandle(this, xaConnection); } private void testXAConnection() throws JMSException { if (!poolingConnectionFactory.getTestConnections()) { if (log.isDebugEnabled()) log.debug("not testing connection of " + this); return; } if (log.isDebugEnabled()) log.debug("testing connection of " + this); XASession xaSession = xaConnection.createXASession(); try { TemporaryQueue tq = xaSession.createTemporaryQueue(); tq.delete(); } finally { xaSession.close(); } } protected void release() throws JMSException { if (log.isDebugEnabled()) log.debug("releasing to pool " + this); closePendingSessions(); // requeuing try { TransactionContextHelper.requeue(this, poolingConnectionFactory); } catch (BitronixSystemException ex) { throw (JMSException) new JMSException("error requeueing " + this).initCause(ex); } if (log.isDebugEnabled()) log.debug("released to pool " + this); } private void closePendingSessions() { synchronized (sessions) { for (DualSessionWrapper dualSessionWrapper : sessions) { if (dualSessionWrapper.getState() != STATE_ACCESSIBLE) continue; try { if (log.isDebugEnabled()) log.debug("trying to close pending session " + dualSessionWrapper); dualSessionWrapper.close(); } catch (JMSException ex) { log.warn("error closing pending session " + dualSessionWrapper, ex); } } } } protected Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { DualSessionWrapper sessionHandle = getNotAccessibleSession(); if (sessionHandle == null) { if (log.isDebugEnabled()) log.debug("no session handle found in NOT_ACCESSIBLE state, creating new session"); sessionHandle = new DualSessionWrapper(this, transacted, acknowledgeMode); sessionHandle.addStateChangeEventListener(new JmsConnectionHandleStateChangeListener()); synchronized (sessions) { sessions.add(sessionHandle); } } else { if (log.isDebugEnabled()) log.debug("found session handle in NOT_ACCESSIBLE state, recycling it: " + sessionHandle); sessionHandle.setState(XAResourceHolder.STATE_ACCESSIBLE); } return sessionHandle; } private DualSessionWrapper getNotAccessibleSession() { synchronized (sessions) { if (log.isDebugEnabled()) log.debug(sessions.size() + " session(s) open from " + this); for (DualSessionWrapper sessionHandle : sessions) { if (sessionHandle.getState() == XAResourceHolder.STATE_NOT_ACCESSIBLE) return sessionHandle; } return null; } } public Date getLastReleaseDate() { return lastReleaseDate; } public String toString() { synchronized (sessions) { return "a JmsPooledConnection of pool " + poolingConnectionFactory.getUniqueName() + " in state " + Decoder.decodeXAStatefulHolderState(getState()) + " with underlying connection " + xaConnection; } } /* management */ public String getStateDescription() { return Decoder.decodeXAStatefulHolderState(getState()); } public Date getAcquisitionDate() { return acquisitionDate; } public Collection getTransactionGtridsCurrentlyHoldingThis() { synchronized (sessions) { Set result = new HashSet(); for (DualSessionWrapper dsw : sessions) { result.addAll(dsw.getXAResourceHolderStateGtrids()); } return result; } } /** * {@link JmsPooledConnection} {@link bitronix.tm.resource.common.StateChangeListener}. * When state changes to STATE_CLOSED, the conenction is unregistered from * {@link bitronix.tm.utils.ManagementRegistrar}. */ private class JmsPooledConnectionStateChangeListener implements StateChangeListener { public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("requeued JMS connection of " + poolingConnectionFactory); lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_IN_POOL && newState == STATE_ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } if (newState == STATE_CLOSED) { ManagementRegistrar.unregister(jmxName); } } public void stateChanging(XAStatefulHolder source, int currentState, int futureState) { } } /** * {@link JmsConnectionHandle} {@link bitronix.tm.resource.common.StateChangeListener}. * When state changes to STATE_CLOSED, the session is removed from the list of opened sessions. */ private class JmsConnectionHandleStateChangeListener implements StateChangeListener { public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == XAResourceHolder.STATE_CLOSED) { synchronized (sessions) { sessions.remove(source); if (log.isDebugEnabled()) log.debug("DualSessionWrapper has been closed, " + sessions.size() + " session(s) left open in pooled connection"); } } } public void stateChanging(XAStatefulHolder source, int currentState, int futureState) { } } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/MessageProducerWrapper.java0000644000175000017500000001224112147207062024767 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import bitronix.tm.resource.common.TransactionContextHelper; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageProducer; import javax.transaction.RollbackException; import javax.transaction.SystemException; /** * {@link MessageProducer} wrapper that adds XA enlistment semantics. * * @author lorban */ public class MessageProducerWrapper implements MessageProducer { private final MessageProducer messageProducer; protected final DualSessionWrapper session; private final PoolingConnectionFactory poolingConnectionFactory; public MessageProducerWrapper(MessageProducer messageProducer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory) { this.messageProducer = messageProducer; this.session = session; this.poolingConnectionFactory = poolingConnectionFactory; } public MessageProducer getMessageProducer() { return messageProducer; } /** * Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource. * If no transaction is running then this method does nothing. * @throws JMSException */ protected void enlistResource() throws JMSException { if (poolingConnectionFactory.getAutomaticEnlistingEnabled()) { session.getSession(); // make sure the session is created before enlisting it try { TransactionContextHelper.enlistInCurrentTransaction(session); } catch (SystemException ex) { throw (JMSException) new JMSException("error enlisting " + this).initCause(ex); } catch (RollbackException ex) { throw (JMSException) new JMSException("error enlisting " + this).initCause(ex); } } // if getAutomaticEnlistingEnabled } public String toString() { return "a MessageProducerWrapper of " + session; } /* MessageProducer with special XA semantics implementation */ public void send(Message message) throws JMSException { enlistResource(); getMessageProducer().send(message); } public void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException { enlistResource(); getMessageProducer().send(message, deliveryMode, priority, timeToLive); } public void send(Destination destination, Message message) throws JMSException { enlistResource(); getMessageProducer().send(destination, message); } public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException { enlistResource(); getMessageProducer().send(destination, message, deliveryMode, priority, timeToLive); } public void close() throws JMSException { // do nothing as the close is handled by the session handle } /* dumb wrapping of MessageProducer methods */ public void setDisableMessageID(boolean value) throws JMSException { getMessageProducer().setDisableMessageID(value); } public boolean getDisableMessageID() throws JMSException { return getMessageProducer().getDisableMessageID(); } public void setDisableMessageTimestamp(boolean value) throws JMSException { getMessageProducer().setDisableMessageTimestamp(value); } public boolean getDisableMessageTimestamp() throws JMSException { return getMessageProducer().getDisableMessageTimestamp(); } public void setDeliveryMode(int deliveryMode) throws JMSException { getMessageProducer().setDeliveryMode(deliveryMode); } public int getDeliveryMode() throws JMSException { return getMessageProducer().getDeliveryMode(); } public void setPriority(int defaultPriority) throws JMSException { getMessageProducer().setPriority(defaultPriority); } public int getPriority() throws JMSException { return getMessageProducer().getPriority(); } public void setTimeToLive(long timeToLive) throws JMSException { getMessageProducer().setTimeToLive(timeToLive); } public long getTimeToLive() throws JMSException { return getMessageProducer().getTimeToLive(); } public Destination getDestination() throws JMSException { return getMessageProducer().getDestination(); } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/TopicSubscriberWrapper.java0000644000175000017500000000324612147207062025006 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import javax.jms.JMSException; import javax.jms.Topic; import javax.jms.TopicSubscriber; /** * {@link TopicSubscriber} wrapper that adds XA enlistment semantics. * * @author lorban */ public class TopicSubscriberWrapper extends MessageConsumerWrapper implements TopicSubscriber { public TopicSubscriberWrapper(TopicSubscriber topicSubscriber, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory) { super(topicSubscriber, session, poolingConnectionFactory); } public Topic getTopic() throws JMSException { return ((TopicSubscriber) getMessageConsumer()).getTopic(); } public boolean getNoLocal() throws JMSException { return ((TopicSubscriber) getMessageConsumer()).getNoLocal(); } public String toString() { return "a TopicSubscriberWrapper of " + session; } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/MessageConsumerWrapper.java0000644000175000017500000000750012147207062025001 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import bitronix.tm.resource.common.TransactionContextHelper; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.transaction.RollbackException; import javax.transaction.SystemException; /** * {@link MessageConsumer} wrapper that adds XA enlistment semantics. * * @author lorban */ public class MessageConsumerWrapper implements MessageConsumer { private final MessageConsumer messageConsumer; protected final DualSessionWrapper session; private final PoolingConnectionFactory poolingConnectionFactory; public MessageConsumerWrapper(MessageConsumer messageConsumer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory) { this.messageConsumer = messageConsumer; this.session = session; this.poolingConnectionFactory = poolingConnectionFactory; } public MessageConsumer getMessageConsumer() { return messageConsumer; } /** * Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource. * If no transaction is running then this method does nothing. * @throws javax.jms.JMSException */ protected void enlistResource() throws JMSException { if (poolingConnectionFactory.getAutomaticEnlistingEnabled()) { session.getSession(); // make sure the session is created before enlisting it try { TransactionContextHelper.enlistInCurrentTransaction(session); } catch (SystemException ex) { throw (JMSException) new JMSException("error enlisting " + this).initCause(ex); } catch (RollbackException ex) { throw (JMSException) new JMSException("error enlisting " + this).initCause(ex); } } // if getAutomaticEnlistingEnabled } public String toString() { return "a MessageConsumerWrapper of " + session; } /* MessageProducer with special XA semantics implementation */ public Message receive() throws JMSException { enlistResource(); return getMessageConsumer().receive(); } public Message receive(long timeout) throws JMSException { enlistResource(); return getMessageConsumer().receive(timeout); } public Message receiveNoWait() throws JMSException { enlistResource(); return getMessageConsumer().receiveNoWait(); } public void close() throws JMSException { // do nothing as the close is handled by the session handle } /* dumb wrapping of MessageProducer methods */ public String getMessageSelector() throws JMSException { return getMessageConsumer().getMessageSelector(); } public MessageListener getMessageListener() throws JMSException { return getMessageConsumer().getMessageListener(); } public void setMessageListener(MessageListener listener) throws JMSException { getMessageConsumer().setMessageListener(listener); } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/lrc/0000755000175000017500000000000012147207062020253 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/resource/jms/lrc/package.html0000644000175000017500000000072312147207062022536 0ustar tonytony

XAConnectionFactory emulator using Last Resource Commit on an underlying non-XA ConnectionFactory. Note that if you use the classes of this package you have accepted the heuristic hazard. A crash during commit of a connection returned by this connection factory could lead to an inconsistent global state. This is a limitation of the Last Resource Commit technique, not of BTM.

btm-dist-2.1.4/src/bitronix/tm/resource/jms/lrc/LrcXAResource.java0000644000175000017500000002620412147207062023603 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms.lrc; import bitronix.tm.internal.BitronixXAException; import bitronix.tm.utils.Decoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jms.JMSException; import javax.jms.Session; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; /** * XAResource implementation for a non-XA JMS connection emulating XA with Last Resource Commit. *

The XA protocol flow is implemented by this state machine:

*
 * NO_TX
 *   |
 *   | start(TMNOFLAGS)
 *   |
 *   |       end(TMFAIL)
 * STARTED -------------- NO_TX
 *   |
 *   | end(TMSUCCESS)
 *   |
 *   |    start(TMJOIN)
 * ENDED ---------------- STARTED
 *   |\
 *   | \  commit (one phase)
 *   |  ----------------- NO_TX
 *   |
 *   | prepare()
 *   |
 *   |       commit() or
 *   |       rollback()
 * PREPARED ------------- NO_TX
 * 
* {@link XAResource#TMSUSPEND} and {@link XAResource#TMRESUME} are not supported. * * @author lorban */ public class LrcXAResource implements XAResource { private final static Logger log = LoggerFactory.getLogger(LrcXAResource.class); public static final int NO_TX = 0; public static final int STARTED = 1; public static final int ENDED = 2; public static final int PREPARED = 3; private final Session session; private volatile Xid xid; private volatile int state = NO_TX; public LrcXAResource(Session session) { this.session = session; } public int getState() { return state; } private String xlatedState() { switch (state) { case NO_TX: return "NO_TX"; case STARTED: return "STARTED"; case ENDED: return "ENDED"; case PREPARED: return "PREPARED"; default: return "!invalid state (" + state + ")!"; } } public int getTransactionTimeout() throws XAException { return 0; } public boolean setTransactionTimeout(int seconds) throws XAException { return false; } public void forget(Xid xid) throws XAException { } public Xid[] recover(int flags) throws XAException { return new Xid[0]; } public boolean isSameRM(XAResource xaResource) throws XAException { return xaResource == this; } public void start(Xid xid, int flag) throws XAException { if (flag != XAResource.TMNOFLAGS && flag != XAResource.TMJOIN) throw new BitronixXAException("unsupported start flag " + Decoder.decodeXAResourceFlag(flag), XAException.XAER_RMERR); if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { if (this.xid != null) throw new BitronixXAException("resource already started on XID " + this.xid, XAException.XAER_PROTO); else { if (flag == XAResource.TMJOIN) throw new BitronixXAException("resource not yet started", XAException.XAER_PROTO); else { if (log.isDebugEnabled()) log.debug("OK to start, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); this.xid = xid; } } } else if (state == STARTED) { throw new BitronixXAException("resource already started on XID " + this.xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (flag == XAResource.TMNOFLAGS) throw new BitronixXAException("resource already registered XID " + this.xid, XAException.XAER_DUPID); else { if (xid.equals(this.xid)) { if (log.isDebugEnabled()) log.debug("OK to join, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot start it on more than one XID at a time", XAException.XAER_RMERR); } } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } this.state = STARTED; } public void end(Xid xid, int flag) throws XAException { if (flag != XAResource.TMSUCCESS && flag != XAResource.TMFAIL) throw new BitronixXAException("unsupported end flag " + Decoder.decodeXAResourceFlag(flag), XAException.XAER_RMERR); if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to end, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot end it on another XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { throw new BitronixXAException("resource already ended on XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("cannot end, resource already prepared on XID " + xid, XAException.XAER_PROTO); } if (flag == XAResource.TMFAIL) { try { session.rollback(); state = NO_TX; this.xid = null; return; } catch (JMSException ex) { throw new BitronixXAException("error rolling back resource on end", XAException.XAER_RMERR, ex); } } this.state = ENDED; } public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { session.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } } public void commit(Xid xid, boolean onePhase) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (onePhase) { if (log.isDebugEnabled()) log.debug("OK to commit with 1PC, old state=" + xlatedState() + ", XID=" + xid); try { session.commit(); } catch (JMSException ex) { throw new BitronixXAException("error committing (one phase) non-XA resource", XAException.XAER_RMERR, ex); } } else throw new BitronixXAException("resource never prepared on XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { if (!onePhase) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to commit, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot commit it on another XID " + xid, XAException.XAER_PROTO); } else throw new BitronixXAException("cannot commit in one phase as resource has been prepared on XID " + xid, XAException.XAER_PROTO); } this.state = NO_TX; this.xid = null; } public void rollback(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to rollback, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot roll it back on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { this.state = NO_TX; throw new BitronixXAException("resource committed during prepare on XID " + this.xid, XAException.XA_HEURCOM); } try { session.rollback(); } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } finally { this.state = NO_TX; this.xid = null; } } public String toString() { return "a JMS LrcXAResource in state " + xlatedState() + " of session " + session; } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/lrc/LrcXAConnectionFactory.java0000644000175000017500000000635112147207062025444 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms.lrc; import bitronix.tm.utils.ClassLoaderUtils; import bitronix.tm.utils.PropertyUtils; import javax.jms.ConnectionFactory; import javax.jms.JMSException; import javax.jms.XAConnection; import javax.jms.XAConnectionFactory; import java.util.Properties; /** * XAConnectionFactory implementation for a non-XA JMS resource emulating XA with Last Resource Commit. * * @author lorban */ public class LrcXAConnectionFactory implements XAConnectionFactory { private volatile String connectionFactoryClassName; private volatile Properties properties = new Properties(); public LrcXAConnectionFactory() { } public String getConnectionFactoryClassName() { return connectionFactoryClassName; } public void setConnectionFactoryClassName(String connectionFactoryClassName) { this.connectionFactoryClassName = connectionFactoryClassName; } public Properties getProperties() { return properties; } public void setProperties(Properties properties) { this.properties = properties; } public XAConnection createXAConnection() throws JMSException { try { Class clazz = ClassLoaderUtils.loadClass(connectionFactoryClassName); ConnectionFactory nonXaConnectionFactory = (ConnectionFactory) clazz.newInstance(); PropertyUtils.setProperties(nonXaConnectionFactory, properties); return new LrcXAConnection(nonXaConnectionFactory.createConnection()); } catch (Exception ex) { throw (JMSException) new JMSException("unable to connect to non-XA resource " + connectionFactoryClassName).initCause(ex); } } public XAConnection createXAConnection(String user, String password) throws JMSException { try { Class clazz = ClassLoaderUtils.loadClass(connectionFactoryClassName); ConnectionFactory nonXaConnectionFactory = (ConnectionFactory) clazz.newInstance(); PropertyUtils.setProperties(nonXaConnectionFactory, properties); return new LrcXAConnection(nonXaConnectionFactory.createConnection(user, password)); } catch (Exception ex) { throw (JMSException) new JMSException("unable to connect to non-XA resource " + connectionFactoryClassName).initCause(ex); } } public String toString() { return "a JMS LrcXAConnectionFactory on " + connectionFactoryClassName + " with properties " + properties; } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/lrc/LrcXAConnection.java0000644000175000017500000000674412147207062024122 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms.lrc; import javax.jms.Connection; import javax.jms.ConnectionConsumer; import javax.jms.ConnectionMetaData; import javax.jms.Destination; import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.ServerSessionPool; import javax.jms.Session; import javax.jms.Topic; import javax.jms.XAConnection; import javax.jms.XASession; /** * XAConnection implementation for a non-XA JMS resource emulating XA with Last Resource Commit. * * @author lorban */ public class LrcXAConnection implements XAConnection { private final Connection nonXaConnection; public LrcXAConnection(Connection connection) { this.nonXaConnection = connection; } public XASession createXASession() throws JMSException { return new LrcXASession(nonXaConnection.createSession(true, Session.AUTO_ACKNOWLEDGE)); } public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { throw new JMSException(LrcXAConnection.class.getName() + " can only respond to createXASession()"); } public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool serverSessionPool, int maxMessages) throws JMSException { return nonXaConnection.createConnectionConsumer(destination, messageSelector, serverSessionPool, maxMessages); } public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool serverSessionPool, int maxMessages) throws JMSException { return nonXaConnection.createDurableConnectionConsumer(topic, subscriptionName, messageSelector, serverSessionPool, maxMessages); } public String getClientID() throws JMSException { return nonXaConnection.getClientID(); } public void setClientID(String clientID) throws JMSException { nonXaConnection.setClientID(clientID); } public ConnectionMetaData getMetaData() throws JMSException { return nonXaConnection.getMetaData(); } public ExceptionListener getExceptionListener() throws JMSException { return nonXaConnection.getExceptionListener(); } public void setExceptionListener(ExceptionListener exceptionListener) throws JMSException { nonXaConnection.setExceptionListener(exceptionListener); } public void start() throws JMSException { nonXaConnection.start(); } public void stop() throws JMSException { nonXaConnection.stop(); } public void close() throws JMSException { nonXaConnection.close(); } public String toString() { return "a JMS LrcXAConnection on " + nonXaConnection; } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/lrc/LrcXASession.java0000644000175000017500000001434712147207062023444 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms.lrc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jms.BytesMessage; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MapMessage; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.StreamMessage; import javax.jms.TemporaryQueue; import javax.jms.TemporaryTopic; import javax.jms.TextMessage; import javax.jms.Topic; import javax.jms.TopicSubscriber; import javax.jms.XASession; import javax.transaction.xa.XAResource; import java.io.Serializable; /** * XASession implementation for a non-XA JMS resource emulating XA with Last Resource Commit. * * @author lorban */ public class LrcXASession implements XASession { private final static Logger log = LoggerFactory.getLogger(LrcXASession.class); private final Session nonXaSession; private final XAResource xaResource; public LrcXASession(Session session) { this.nonXaSession = session; this.xaResource = new LrcXAResource(session); if (log.isDebugEnabled()) log.debug("creating new LrcXASession with " + xaResource); } public Session getSession() throws JMSException { return nonXaSession; } public XAResource getXAResource() { return xaResource; } public BytesMessage createBytesMessage() throws JMSException { return nonXaSession.createBytesMessage(); } public MapMessage createMapMessage() throws JMSException { return nonXaSession.createMapMessage(); } public Message createMessage() throws JMSException { return nonXaSession.createMessage(); } public ObjectMessage createObjectMessage() throws JMSException { return nonXaSession.createObjectMessage(); } public ObjectMessage createObjectMessage(Serializable serializable) throws JMSException { return nonXaSession.createObjectMessage(serializable); } public StreamMessage createStreamMessage() throws JMSException { return nonXaSession.createStreamMessage(); } public TextMessage createTextMessage() throws JMSException { return nonXaSession.createTextMessage(); } public TextMessage createTextMessage(String text) throws JMSException { return nonXaSession.createTextMessage(text); } public boolean getTransacted() throws JMSException { return nonXaSession.getTransacted(); } public int getAcknowledgeMode() throws JMSException { return nonXaSession.getAcknowledgeMode(); } public void commit() throws JMSException { nonXaSession.commit(); } public void rollback() throws JMSException { nonXaSession.rollback(); } public void close() throws JMSException { nonXaSession.close(); } public void recover() throws JMSException { nonXaSession.recover(); } public MessageListener getMessageListener() throws JMSException { return nonXaSession.getMessageListener(); } public void setMessageListener(MessageListener messageListener) throws JMSException { nonXaSession.setMessageListener(messageListener); } public void run() { nonXaSession.run(); } public MessageProducer createProducer(Destination destination) throws JMSException { return nonXaSession.createProducer(destination); } public MessageConsumer createConsumer(Destination destination) throws JMSException { return nonXaSession.createConsumer(destination); } public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException { return nonXaSession.createConsumer(destination, messageSelector); } public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal) throws JMSException { return nonXaSession.createConsumer(destination, messageSelector, noLocal); } public Queue createQueue(String queueName) throws JMSException { return nonXaSession.createQueue(queueName); } public Topic createTopic(String topicName) throws JMSException { return nonXaSession.createTopic(topicName); } public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException { return nonXaSession.createDurableSubscriber(topic, name); } public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException { return nonXaSession.createDurableSubscriber(topic, name, messageSelector, noLocal); } public QueueBrowser createBrowser(Queue queue) throws JMSException { return nonXaSession.createBrowser(queue); } public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException { return nonXaSession.createBrowser(queue, messageSelector); } public TemporaryQueue createTemporaryQueue() throws JMSException { return nonXaSession.createTemporaryQueue(); } public TemporaryTopic createTemporaryTopic() throws JMSException { return nonXaSession.createTemporaryTopic(); } public void unsubscribe(String name) throws JMSException { nonXaSession.unsubscribe(name); } public String toString() { return "a JMS LrcXASession on " + nonXaSession; } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/JndiXAConnectionFactory.java0000644000175000017500000002235112147207062025026 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import javax.jms.JMSException; import javax.jms.XAConnection; import javax.jms.XAConnectionFactory; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import java.util.Hashtable; import java.util.Properties; /** * {@link XAConnectionFactory} implementation that wraps another {@link XAConnectionFactory} implementation available * in some JNDI tree. * * @author lorban */ public class JndiXAConnectionFactory implements XAConnectionFactory { private volatile String initialContextFactory; private volatile String providerUrl; private volatile String urlPkgPrefixes; private volatile String name; private volatile String securityPrincipal; private volatile String securityCredentials; private volatile Properties extraJndiProperties = new Properties(); private volatile boolean narrowJndiObject = false; private volatile XAConnectionFactory wrappedFactory; public JndiXAConnectionFactory() { } /** * The {@link Context#INITIAL_CONTEXT_FACTORY} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * @return the {@link Context#INITIAL_CONTEXT_FACTORY} value. */ public String getInitialContextFactory() { return initialContextFactory; } /** * Set the {@link Context#INITIAL_CONTEXT_FACTORY} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * If not set, the {@link Context} is created without the environment parameter, using the default constructor. This means * all other properties (providerUrl, urlPkgPrefixes, extraJndiProperties...) are then ignored. * @param initialContextFactory the {@link Context#INITIAL_CONTEXT_FACTORY} value. */ public void setInitialContextFactory(String initialContextFactory) { this.initialContextFactory = initialContextFactory; } /** * The {@link Context#PROVIDER_URL} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * @return the {@link Context#PROVIDER_URL} value. */ public String getProviderUrl() { return providerUrl; } /** * Set the {@link Context#PROVIDER_URL} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * @param providerUrl the {@link Context#PROVIDER_URL} value. */ public void setProviderUrl(String providerUrl) { this.providerUrl = providerUrl; } /** * The {@link Context#URL_PKG_PREFIXES} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * @return the {@link Context#URL_PKG_PREFIXES} value. */ public String getUrlPkgPrefixes() { return urlPkgPrefixes; } /** * Set the {@link Context#URL_PKG_PREFIXES} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * @param urlPkgPrefixes the {@link Context#URL_PKG_PREFIXES} value. */ public void setUrlPkgPrefixes(String urlPkgPrefixes) { this.urlPkgPrefixes = urlPkgPrefixes; } /** * The {@link Context#SECURITY_PRINCIPAL} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * @return the {@link Context#SECURITY_PRINCIPAL} value. */ public String getSecurityPrincipal() { return securityPrincipal; } /** * Set the {@link Context#SECURITY_PRINCIPAL} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * If {@link Context#INITIAL_CONTEXT_FACTORY} and {@link Context#PROVIDER_URL} are not set, this value is ignored. * @param securityPrincipal the {@link Context#SECURITY_PRINCIPAL} value. */ public void setSecurityPrincipal(String securityPrincipal) { this.securityPrincipal = securityPrincipal; } /** * The {@link Context#SECURITY_CREDENTIALS} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * @return the {@link Context#SECURITY_CREDENTIALS} value. */ public String getSecurityCredentials() { return securityCredentials; } /** * Set the {@link Context#SECURITY_CREDENTIALS} of the JNDI {@link Context} used to fetch the {@link XAConnectionFactory}. * If {@link Context#INITIAL_CONTEXT_FACTORY} and {@link Context#PROVIDER_URL} are not set, this value is ignored. * @param securityCredentials the {@link Context#SECURITY_CREDENTIALS} value. */ public void setSecurityCredentials(String securityCredentials) { this.securityCredentials = securityCredentials; } /** * The JNDI name under which the {@link XAConnectionFactory} is available. * @return The JNDI name. */ public String getName() { return name; } /** * Set the JNDI name under which the {@link XAConnectionFactory} is available. * @param name the JNDI name. */ public void setName(String name) { this.name = name; } /** * The extra JNDI environment properties added the the {@link InitialContext}'s environment upon creation. * @return The extra JNDI environment properties. */ public Properties getExtraJndiProperties() { return extraJndiProperties; } /** * Set the extra JNDI environment properties added the the {@link InitialContext}'s environment upon creation. * @param extraJndiProperties The extra JNDI environment properties. */ public void setExtraJndiProperties(Properties extraJndiProperties) { this.extraJndiProperties = extraJndiProperties; } /** * Should {@link PortableRemoteObject#narrow(Object, Class)} be applied on the object looked up from * JNDI before trying to cast it to {@link XAConnectionFactory} ? * @return true if the object should be narrowed, false otherwise. */ public boolean isNarrowJndiObject() { return narrowJndiObject; } /** * Set if {@link PortableRemoteObject#narrow(Object, Class)} should be applied on the object looked up from * JNDI before trying to cast it to {@link XAConnectionFactory} ? * @param narrowJndiObject true if the object should be narrowed, false otherwise. */ public void setNarrowJndiObject(boolean narrowJndiObject) { this.narrowJndiObject = narrowJndiObject; } protected void init() throws NamingException { if (wrappedFactory != null) return; Context ctx; if (!isEmpty(initialContextFactory)) { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory); if (!isEmpty(providerUrl)) env.put(Context.PROVIDER_URL, providerUrl); if (!isEmpty(urlPkgPrefixes)) env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes); if (!isEmpty(securityPrincipal)) env.put(Context.SECURITY_PRINCIPAL, securityPrincipal); if (!isEmpty(securityCredentials)) env.put(Context.SECURITY_CREDENTIALS, securityCredentials); if (!extraJndiProperties.isEmpty()) env.putAll(extraJndiProperties); ctx = new InitialContext(env); } else { ctx = new InitialContext(); } try { Object lookedUpObject = ctx.lookup(name); if (narrowJndiObject) { wrappedFactory = (XAConnectionFactory) PortableRemoteObject.narrow(lookedUpObject, XAConnectionFactory.class); } else { wrappedFactory = (XAConnectionFactory) lookedUpObject; } } finally { ctx.close(); } } public XAConnection createXAConnection() throws JMSException { try { init(); return wrappedFactory.createXAConnection(); } catch (NamingException ex) { throw (JMSException) new JMSException("error looking up wrapped XAConnectionFactory at " + name).initCause(ex); } } public XAConnection createXAConnection(String userName, String password) throws JMSException { try { init(); return wrappedFactory.createXAConnection(userName, password); } catch (NamingException ex) { throw (JMSException) new JMSException("error looking up wrapped XAConnectionFactory at " + name).initCause(ex); } } private static boolean isEmpty(String str) { return str == null || str.trim().equals(""); } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/PoolingConnectionFactory.java0000644000175000017500000002311612147207062025320 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.recovery.RecoveryException; import bitronix.tm.resource.ResourceConfigurationException; import bitronix.tm.resource.ResourceObjectFactory; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.common.RecoveryXAResourceHolder; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.resource.common.XAPool; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.resource.common.XAResourceProducer; import bitronix.tm.resource.common.XAStatefulHolder; import bitronix.tm.utils.ManagementRegistrar; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; import javax.jms.XAConnection; import javax.jms.XAConnectionFactory; import javax.naming.NamingException; import javax.naming.Reference; import javax.naming.StringRefAddr; import javax.transaction.xa.XAResource; /** * Implementation of a JMS {@link ConnectionFactory} wrapping vendor's {@link XAConnectionFactory} implementation. * * @author lorban */ public class PoolingConnectionFactory extends ResourceBean implements ConnectionFactory, XAResourceProducer, PoolingConnectionFactoryMBean { private final static Logger log = LoggerFactory.getLogger(PoolingConnectionFactory.class); private volatile transient XAPool pool; private volatile transient JmsPooledConnection recoveryPooledConnection; private volatile transient RecoveryXAResourceHolder recoveryXAResourceHolder; private volatile boolean cacheProducersConsumers = true; private volatile boolean testConnections = false; private volatile String user; private volatile String password; private volatile JmsConnectionHandle recoveryConnectionHandle; private volatile String jmxName; public PoolingConnectionFactory() { } /** * Initialize the pool by creating the initial amount of connections. */ public synchronized void init() { try { if (pool != null) return; buildXAPool(); this.jmxName = "bitronix.tm:type=JMS,UniqueName=" + ManagementRegistrar.makeValidName(getUniqueName()); ManagementRegistrar.register(jmxName, this); } catch (Exception ex) { throw new ResourceConfigurationException("cannot create JMS connection factory named " + getUniqueName(), ex); } } public boolean getCacheProducersConsumers() { return cacheProducersConsumers; } public void setCacheProducersConsumers(boolean cacheProducersConsumers) { this.cacheProducersConsumers = cacheProducersConsumers; } public boolean getTestConnections() { return testConnections; } public void setTestConnections(boolean testConnections) { this.testConnections = testConnections; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } private void buildXAPool() throws Exception { if (pool != null) return; if (log.isDebugEnabled()) log.debug("building JMS XA pool for " + getUniqueName() + " with " + getMinPoolSize() + " connection(s)"); pool = new XAPool(this, this); try { ResourceRegistrar.register(this); } catch (RecoveryException ex) { pool = null; throw ex; } } public Connection createConnection() throws JMSException { if (isDisabled()) { throw new JMSException("JMS connection pool '" + getUniqueName() + "' is disabled, cannot get a connection from it"); } try { init(); return (Connection) pool.getConnectionHandle(); } catch (Exception ex) { throw (JMSException) new JMSException("unable to get a connection from pool of " + this).initCause(ex); } } public Connection createConnection(String userName, String password) throws JMSException { if (log.isDebugEnabled()) log.debug("JMS connections are pooled, username and password ignored"); return createConnection(); } public String toString() { return "a PoolingConnectionFactory with " + pool; } /* XAResourceProducer implementation */ public XAResourceHolderState startRecovery() throws RecoveryException { init(); if (recoveryPooledConnection != null) throw new RecoveryException("recovery already in progress on " + this); try { recoveryConnectionHandle = (JmsConnectionHandle) pool.getConnectionHandle(false); recoveryPooledConnection = recoveryConnectionHandle.getPooledConnection(); recoveryXAResourceHolder = recoveryPooledConnection.createRecoveryXAResourceHolder(); return new XAResourceHolderState(recoveryXAResourceHolder, recoveryPooledConnection.getPoolingConnectionFactory()); } catch (Exception ex) { throw new RecoveryException("error starting recovery", ex); } } public void endRecovery() throws RecoveryException { if (recoveryPooledConnection == null) return; try { if (recoveryConnectionHandle != null) { try { if (log.isDebugEnabled()) log.debug("recovery connection handle is being closed: " + recoveryConnectionHandle); recoveryConnectionHandle.close(); } catch (Exception ex) { throw new RecoveryException("error ending recovery", ex); } } if (recoveryXAResourceHolder != null) { try { if (log.isDebugEnabled()) log.debug("recovery xa resource is being closed: " + recoveryXAResourceHolder); recoveryXAResourceHolder.close(); } catch (Exception ex) { throw new RecoveryException("error ending recovery", ex); } } } finally { recoveryConnectionHandle = null; recoveryXAResourceHolder = null; recoveryPooledConnection = null; } } public void setFailed(boolean failed) { pool.setFailed(failed); } public boolean isFailed() { return pool.isFailed(); } public void close() { if (pool == null) return; if (log.isDebugEnabled()) log.debug("closing " + pool); pool.close(); pool = null; ManagementRegistrar.unregister(jmxName); jmxName = null; ResourceRegistrar.unregister(this); } public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception { if (!(xaFactory instanceof XAConnectionFactory)) throw new IllegalArgumentException("class '" + xaFactory.getClass().getName() + "' does not implement " + XAConnectionFactory.class.getName()); XAConnectionFactory xaConnectionFactory = (XAConnectionFactory) xaFactory; XAConnection xaConnection; if (user == null || password == null) { if (log.isDebugEnabled()) log.debug("creating new JMS XAConnection with no credentials"); xaConnection = xaConnectionFactory.createXAConnection(); } else { if (log.isDebugEnabled()) log.debug("creating new JMS XAConnection with user <" + user + "> and password <" + password + ">"); xaConnection = xaConnectionFactory.createXAConnection(user, password); } return new JmsPooledConnection(this, xaConnection); } public XAResourceHolder findXAResourceHolder(XAResource xaResource) { return pool.findXAResourceHolder(xaResource); } /* Referenceable implementation */ /** * {@link PoolingConnectionFactory} must alway have a unique name so this method builds a reference to this object * using the unique name as {@link javax.naming.RefAddr}. * @return a reference to this {@link PoolingConnectionFactory}. */ public Reference getReference() throws NamingException { if (log.isDebugEnabled()) log.debug("creating new JNDI reference of " + this); return new Reference( PoolingConnectionFactory.class.getName(), new StringRefAddr("uniqueName", getUniqueName()), ResourceObjectFactory.class.getName(), null); } /* management */ public long getInPoolSize() { return pool.inPoolSize(); } public long getTotalPoolSize() { return pool.totalPoolSize(); } public void reset() throws Exception { pool.reset(); } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/PoolingConnectionFactoryMBean.java0000644000175000017500000000227712147207062026230 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; /** * * @author lorban */ public interface PoolingConnectionFactoryMBean { public int getMinPoolSize(); public int getMaxPoolSize(); public long getInPoolSize(); public long getTotalPoolSize(); public boolean isFailed(); public void reset() throws Exception; public boolean isDisabled(); public void setDisabled(boolean disabled); } btm-dist-2.1.4/src/bitronix/tm/resource/jms/JmsPooledConnectionMBean.java0000644000175000017500000000220412147207062025153 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import java.util.Collection; import java.util.Date; /** * {@link JmsPooledConnection} Management interface. * * @author lorban */ public interface JmsPooledConnectionMBean { String getStateDescription(); Date getAcquisitionDate(); Collection getTransactionGtridsCurrentlyHoldingThis(); } btm-dist-2.1.4/src/bitronix/tm/resource/jms/DualSessionWrapper.java0000644000175000017500000005362212147207062024140 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import bitronix.tm.BitronixTransaction; import bitronix.tm.internal.BitronixRollbackSystemException; import bitronix.tm.internal.BitronixSystemException; import bitronix.tm.resource.common.AbstractXAResourceHolder; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.resource.common.StateChangeListener; import bitronix.tm.resource.common.TransactionContextHelper; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.resource.common.XAStatefulHolder; import bitronix.tm.utils.Decoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.jms.BytesMessage; import javax.jms.Destination; import javax.jms.IllegalStateException; import javax.jms.JMSException; import javax.jms.MapMessage; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.StreamMessage; import javax.jms.TemporaryQueue; import javax.jms.TemporaryTopic; import javax.jms.TextMessage; import javax.jms.Topic; import javax.jms.TopicSubscriber; import javax.jms.TransactionInProgressException; import javax.jms.TransactionRolledBackException; import javax.jms.XASession; import javax.transaction.RollbackException; import javax.transaction.SystemException; import javax.transaction.xa.XAResource; import java.io.Serializable; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling * context. * * @author lorban */ public class DualSessionWrapper extends AbstractXAResourceHolder implements Session, StateChangeListener { private final static Logger log = LoggerFactory.getLogger(DualSessionWrapper.class); private final JmsPooledConnection pooledConnection; private final boolean transacted; private final int acknowledgeMode; private XASession xaSession; private Session session; private XAResource xaResource; private MessageListener listener; //TODO: shouldn't producers/consumers/subscribers be separated between XA and non-XA session ? private final Map messageProducers = new HashMap(); private final Map messageConsumers = new HashMap(); private final Map topicSubscribers = new HashMap(); public DualSessionWrapper(JmsPooledConnection pooledConnection, boolean transacted, int acknowledgeMode) { this.pooledConnection = pooledConnection; this.transacted = transacted; this.acknowledgeMode = acknowledgeMode; if (log.isDebugEnabled()) log.debug("getting session handle from " + pooledConnection); setState(STATE_ACCESSIBLE); addStateChangeEventListener(this); } public PoolingConnectionFactory getPoolingConnectionFactory() { return pooledConnection.getPoolingConnectionFactory(); } public Session getSession() throws JMSException { return getSession(false); } public Session getSession(boolean forceXa) throws JMSException { if (getState() == STATE_CLOSED) throw new IllegalStateException("session handle is closed"); if (forceXa) { if (log.isDebugEnabled()) log.debug("choosing XA session (forced)"); return createXASession(); } else { BitronixTransaction currentTransaction = TransactionContextHelper.currentTransaction(); if (currentTransaction != null) { if (log.isDebugEnabled()) log.debug("choosing XA session"); return createXASession(); } if (log.isDebugEnabled()) log.debug("choosing non-XA session"); return createNonXASession(); } } private Session createNonXASession() throws JMSException { // non-XA if (session == null) { session = pooledConnection.getXAConnection().createSession(transacted, acknowledgeMode); if (listener != null) { session.setMessageListener(listener); if (log.isDebugEnabled()) log.debug("get non-XA session registered message listener: " + listener); } } return session; } private Session createXASession() throws JMSException { // XA if (xaSession == null) { xaSession = pooledConnection.getXAConnection().createXASession(); if (listener != null) { xaSession.setMessageListener(listener); if (log.isDebugEnabled()) log.debug("get XA session registered message listener: " + listener); } xaResource = xaSession.getXAResource(); } return xaSession.getSession(); } public String toString() { return "a DualSessionWrapper in state " + Decoder.decodeXAStatefulHolderState(getState()) + " of " + pooledConnection; } /* wrapped Session methods that have special XA semantics */ public void close() throws JMSException { if (getState() != STATE_ACCESSIBLE) { if (log.isDebugEnabled()) log.debug("not closing already closed " + this); return; } if (log.isDebugEnabled()) log.debug("closing " + this); // delisting try { TransactionContextHelper.delistFromCurrentTransaction(this); } catch (BitronixRollbackSystemException ex) { throw (JMSException) new TransactionRolledBackException("unilateral rollback of " + this).initCause(ex); } catch (SystemException ex) { throw (JMSException) new JMSException("error delisting " + this).initCause(ex); } finally { // requeuing try { TransactionContextHelper.requeue(this, pooledConnection.getPoolingConnectionFactory()); } catch (BitronixSystemException ex) { // this may hide the exception thrown by delistFromCurrentTransaction() but // an error requeuing must absolutely be reported as an exception. // Too bad if this happens... See JdbcPooledConnection.release() as well. throw (JMSException) new JMSException("error requeuing " + this).initCause(ex); } } } public Date getLastReleaseDate() { return null; } /* * When the session is closed (directly or deferred) the action is to change its state to IN_POOL. * There is no such state for JMS sessions, this just means that it has been closed -> force a * state switch to CLOSED then clean up. */ public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == STATE_IN_POOL) { setState(STATE_CLOSED); } else if (newState == STATE_CLOSED) { if (log.isDebugEnabled()) log.debug("session state changing to CLOSED, cleaning it up: " + this); if (xaSession != null) { try { xaSession.close(); } catch (JMSException ex) { log.error("error closing XA session", ex); } xaSession = null; xaResource = null; } if (session != null) { try { session.close(); } catch (JMSException ex) { log.error("error closing session", ex); } session = null; } Iterator it = messageProducers.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); MessageProducerWrapper messageProducerWrapper = (MessageProducerWrapper) entry.getValue(); try { messageProducerWrapper.close(); } catch (JMSException ex) { log.error("error closing message producer", ex); } } messageProducers.clear(); it = messageConsumers.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); MessageConsumerWrapper messageConsumerWrapper = (MessageConsumerWrapper) entry.getValue(); try { messageConsumerWrapper.close(); } catch (JMSException ex) { log.error("error closing message consumer", ex); } } messageConsumers.clear(); } // if newState == STATE_CLOSED } public void stateChanging(XAStatefulHolder source, int currentState, int futureState) { } public MessageProducer createProducer(Destination destination) throws JMSException { MessageProducerConsumerKey key = new MessageProducerConsumerKey(destination); if (log.isDebugEnabled()) log.debug("looking for producer based on " + key); MessageProducerWrapper messageProducer = (MessageProducerWrapper) messageProducers.get(key); if (messageProducer == null) { if (log.isDebugEnabled()) log.debug("found no producer based on " + key + ", creating it"); messageProducer = new MessageProducerWrapper(getSession().createProducer(destination), this, pooledConnection.getPoolingConnectionFactory()); if (pooledConnection.getPoolingConnectionFactory().getCacheProducersConsumers()) { if (log.isDebugEnabled()) log.debug("caching producer via key " + key); messageProducers.put(key, messageProducer); } } else if (log.isDebugEnabled()) log.debug("found producer based on " + key + ", recycling it: " + messageProducer); return messageProducer; } public MessageConsumer createConsumer(Destination destination) throws JMSException { MessageProducerConsumerKey key = new MessageProducerConsumerKey(destination); if (log.isDebugEnabled()) log.debug("looking for consumer based on " + key); MessageConsumerWrapper messageConsumer = (MessageConsumerWrapper) messageConsumers.get(key); if (messageConsumer == null) { if (log.isDebugEnabled()) log.debug("found no consumer based on " + key + ", creating it"); messageConsumer = new MessageConsumerWrapper(getSession().createConsumer(destination), this, pooledConnection.getPoolingConnectionFactory()); if (pooledConnection.getPoolingConnectionFactory().getCacheProducersConsumers()) { if (log.isDebugEnabled()) log.debug("caching consumer via key " + key); messageConsumers.put(key, messageConsumer); } } else if (log.isDebugEnabled()) log.debug("found consumer based on " + key + ", recycling it: " + messageConsumer); return messageConsumer; } public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException { MessageProducerConsumerKey key = new MessageProducerConsumerKey(destination, messageSelector); if (log.isDebugEnabled()) log.debug("looking for consumer based on " + key); MessageConsumerWrapper messageConsumer = (MessageConsumerWrapper) messageConsumers.get(key); if (messageConsumer == null) { if (log.isDebugEnabled()) log.debug("found no consumer based on " + key + ", creating it"); messageConsumer = new MessageConsumerWrapper(getSession().createConsumer(destination, messageSelector), this, pooledConnection.getPoolingConnectionFactory()); if (pooledConnection.getPoolingConnectionFactory().getCacheProducersConsumers()) { if (log.isDebugEnabled()) log.debug("caching consumer via key " + key); messageConsumers.put(key, messageConsumer); } } else if (log.isDebugEnabled()) log.debug("found consumer based on " + key + ", recycling it: " + messageConsumer); return messageConsumer; } public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal) throws JMSException { MessageProducerConsumerKey key = new MessageProducerConsumerKey(destination, messageSelector, noLocal); if (log.isDebugEnabled()) log.debug("looking for consumer based on " + key); MessageConsumerWrapper messageConsumer = (MessageConsumerWrapper) messageConsumers.get(key); if (messageConsumer == null) { if (log.isDebugEnabled()) log.debug("found no consumer based on " + key + ", creating it"); messageConsumer = new MessageConsumerWrapper(getSession().createConsumer(destination, messageSelector, noLocal), this, pooledConnection.getPoolingConnectionFactory()); if (pooledConnection.getPoolingConnectionFactory().getCacheProducersConsumers()) { if (log.isDebugEnabled()) log.debug("caching consumer via key " + key); messageConsumers.put(key, messageConsumer); } } else if (log.isDebugEnabled()) log.debug("found consumer based on " + key + ", recycling it: " + messageConsumer); return messageConsumer; } public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException { MessageProducerConsumerKey key = new MessageProducerConsumerKey(topic); if (log.isDebugEnabled()) log.debug("looking for durable subscriber based on " + key); TopicSubscriberWrapper topicSubscriber = topicSubscribers.get(key); if (topicSubscriber == null) { if (log.isDebugEnabled()) log.debug("found no durable subscriber based on " + key + ", creating it"); topicSubscriber = new TopicSubscriberWrapper(getSession().createDurableSubscriber(topic, name), this, pooledConnection.getPoolingConnectionFactory()); if (pooledConnection.getPoolingConnectionFactory().getCacheProducersConsumers()) { if (log.isDebugEnabled()) log.debug("caching durable subscriber via key " + key); topicSubscribers.put(key, topicSubscriber); } } else if (log.isDebugEnabled()) log.debug("found durable subscriber based on " + key + ", recycling it: " + topicSubscriber); return topicSubscriber; } public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException { MessageProducerConsumerKey key = new MessageProducerConsumerKey(topic, messageSelector, noLocal); if (log.isDebugEnabled()) log.debug("looking for durable subscriber based on " + key); TopicSubscriberWrapper topicSubscriber = topicSubscribers.get(key); if (topicSubscriber == null) { if (log.isDebugEnabled()) log.debug("found no durable subscriber based on " + key + ", creating it"); topicSubscriber = new TopicSubscriberWrapper(getSession().createDurableSubscriber(topic, name, messageSelector, noLocal), this, pooledConnection.getPoolingConnectionFactory()); if (pooledConnection.getPoolingConnectionFactory().getCacheProducersConsumers()) { if (log.isDebugEnabled()) log.debug("caching durable subscriber via key " + key); topicSubscribers.put(key, topicSubscriber); } } else if (log.isDebugEnabled()) log.debug("found durable subscriber based on " + key + ", recycling it: " + topicSubscriber); return topicSubscriber; } public MessageListener getMessageListener() throws JMSException { return listener; } public void setMessageListener(MessageListener listener) throws JMSException { if (getState() == STATE_CLOSED) throw new IllegalStateException("session handle is closed"); if (session != null) session.setMessageListener(listener); if (xaSession != null) xaSession.setMessageListener(listener); this.listener = listener; } public void run() { try { Session session = getSession(true); if (log.isDebugEnabled()) log.debug("running XA session " + session); session.run(); } catch (JMSException ex) { log.error("error getting session", ex); } } /* XAResourceHolder implementation */ public XAResource getXAResource() { return xaResource; } public ResourceBean getResourceBean() { return getPoolingConnectionFactory(); } /* XAStatefulHolder implementation */ public List getXAResourceHolders() { return Arrays.asList((XAResourceHolder) this); } public Object getConnectionHandle() throws Exception { return null; } /* XA-enhanced methods */ public boolean getTransacted() throws JMSException { if (isParticipatingInActiveGlobalTransaction()) return true; // for consistency with EJB 2.1 spec (17.3.5) return getSession().getTransacted(); } public int getAcknowledgeMode() throws JMSException { if (isParticipatingInActiveGlobalTransaction()) return 0; // for consistency with EJB 2.1 spec (17.3.5) return getSession().getAcknowledgeMode(); } public void commit() throws JMSException { if (isParticipatingInActiveGlobalTransaction()) throw new TransactionInProgressException("cannot commit a resource enlisted in a global transaction"); getSession().commit(); } public void rollback() throws JMSException { if (isParticipatingInActiveGlobalTransaction()) throw new TransactionInProgressException("cannot rollback a resource enlisted in a global transaction"); getSession().rollback(); } public void recover() throws JMSException { if (isParticipatingInActiveGlobalTransaction()) throw new TransactionInProgressException("cannot recover a resource enlisted in a global transaction"); getSession().recover(); } public QueueBrowser createBrowser(javax.jms.Queue queue) throws JMSException { enlistResource(); return getSession().createBrowser(queue); } public QueueBrowser createBrowser(javax.jms.Queue queue, String messageSelector) throws JMSException { enlistResource(); return getSession().createBrowser(queue, messageSelector); } /* dumb wrapping of Session methods */ public BytesMessage createBytesMessage() throws JMSException { return getSession().createBytesMessage(); } public MapMessage createMapMessage() throws JMSException { return getSession().createMapMessage(); } public Message createMessage() throws JMSException { return getSession().createMessage(); } public ObjectMessage createObjectMessage() throws JMSException { return getSession().createObjectMessage(); } public ObjectMessage createObjectMessage(Serializable serializable) throws JMSException { return getSession().createObjectMessage(serializable); } public StreamMessage createStreamMessage() throws JMSException { return getSession().createStreamMessage(); } public TextMessage createTextMessage() throws JMSException { return getSession().createTextMessage(); } public TextMessage createTextMessage(String text) throws JMSException { return getSession().createTextMessage(text); } public javax.jms.Queue createQueue(String queueName) throws JMSException { return getSession().createQueue(queueName); } public Topic createTopic(String topicName) throws JMSException { return getSession().createTopic(topicName); } public TemporaryQueue createTemporaryQueue() throws JMSException { return getSession().createTemporaryQueue(); } public TemporaryTopic createTemporaryTopic() throws JMSException { return getSession().createTemporaryTopic(); } public void unsubscribe(String name) throws JMSException { getSession().unsubscribe(name); } /** * Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource. * If no transaction is running then this method does nothing. * @throws JMSException */ protected void enlistResource() throws JMSException { PoolingConnectionFactory poolingConnectionFactory = pooledConnection.getPoolingConnectionFactory(); if (poolingConnectionFactory.getAutomaticEnlistingEnabled()) { getSession(); // make sure the session is created before enlisting it try { TransactionContextHelper.enlistInCurrentTransaction(this); } catch (SystemException ex) { throw (JMSException) new JMSException("error enlisting " + this).initCause(ex); } catch (RollbackException ex) { throw (JMSException) new JMSException("error enlisting " + this).initCause(ex); } } // if getAutomaticEnlistingEnabled } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/JmsConnectionHandle.java0000644000175000017500000000741112147207062024226 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import javax.jms.Connection; import javax.jms.ConnectionConsumer; import javax.jms.ConnectionMetaData; import javax.jms.Destination; import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.ServerSessionPool; import javax.jms.Session; import javax.jms.Topic; import javax.jms.XAConnection; /** * Disposable Connection handle. * * @author lorban */ public class JmsConnectionHandle implements Connection { private final XAConnection xaConnection; private final JmsPooledConnection pooledConnection; private volatile boolean closed = false; public JmsConnectionHandle(JmsPooledConnection pooledConnection, XAConnection xaConnection) { this.pooledConnection = pooledConnection; this.xaConnection = xaConnection; } public XAConnection getXAConnection() throws JMSException { if (xaConnection == null) throw new JMSException("XA connection handle has been closed"); return xaConnection; } public JmsPooledConnection getPooledConnection() { return pooledConnection; } public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { return pooledConnection.createSession(transacted, acknowledgeMode); } public void close() throws JMSException { if (closed) return; closed = true; pooledConnection.release(); } public String toString() { return "a JmsConnectionHandle of " + pooledConnection; } /* Connection implementation */ public String getClientID() throws JMSException { return getXAConnection().getClientID(); } public void setClientID(String jndiName) throws JMSException { getXAConnection().setClientID(jndiName); } public ConnectionMetaData getMetaData() throws JMSException { return getXAConnection().getMetaData(); } public ExceptionListener getExceptionListener() throws JMSException { return getXAConnection().getExceptionListener(); } public void setExceptionListener(ExceptionListener listener) throws JMSException { getXAConnection().setExceptionListener(listener); } public void start() throws JMSException { getXAConnection().start(); } public void stop() throws JMSException { getXAConnection().stop(); } public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException { return getXAConnection().createConnectionConsumer(destination, messageSelector, sessionPool, maxMessages); } public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException { return getXAConnection().createDurableConnectionConsumer(topic, subscriptionName, messageSelector, sessionPool, maxMessages); } } btm-dist-2.1.4/src/bitronix/tm/resource/jms/MessageProducerConsumerKey.java0000644000175000017500000001005012147207062025607 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jms; import bitronix.tm.internal.BitronixRuntimeException; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Queue; import javax.jms.Topic; /** * JMS destination wrapper optimized for use with hashed collections where it is the key and a * {@link javax.jms.MessageProducer} or a {@link javax.jms.MessageConsumer} is the value. * * @author lorban */ public class MessageProducerConsumerKey { private final Destination destination; private final String messageSelector; private final Boolean noLocal; public MessageProducerConsumerKey(Destination destination) { this.destination = destination; this.messageSelector = null; this.noLocal = null; } public MessageProducerConsumerKey(Destination destination, String messageSelector) { this.destination = destination; this.messageSelector = messageSelector; this.noLocal = null; } public MessageProducerConsumerKey(Destination destination, String messageSelector, boolean noLocal) { this.destination = destination; this.messageSelector = messageSelector; this.noLocal = noLocal; } public boolean equals(Object obj) { if (obj instanceof MessageProducerConsumerKey) { MessageProducerConsumerKey otherKey = (MessageProducerConsumerKey) obj; if (!areEquals(getDestinationName(), otherKey.getDestinationName())) return false; if (!areEquals(messageSelector, otherKey.messageSelector)) return false; if (!areEquals(noLocal, otherKey.noLocal)) return false; return true; } return false; } private static boolean areEquals(Object o1, Object o2) { if (o1 == null && o2 == null) return true; if (o1 != null && o2 == null) return false; if (o1 == null) return false; return o1.equals(o2); } private String getDestinationName() { if (destination == null) { return null; } else if (destination instanceof Queue) { try { return ((Queue) destination).getQueueName(); } catch (JMSException ex) { throw new BitronixRuntimeException("error getting queue name of " + destination, ex); } } else if (destination instanceof Topic) { try { return ((Topic) destination).getTopicName(); } catch (JMSException ex) { throw new BitronixRuntimeException("error getting topic name of " + destination, ex); } } else throw new IllegalArgumentException("unsupported destination: " + destination); } public int hashCode() { return hash(getDestinationName()) + hash(messageSelector) + hash(noLocal); } private static int hash(Object o) { if (o == null) return 0; return o.hashCode(); } public String toString() { return "a MessageProducerConsumerKey on " + destination + (messageSelector == null ? "" : (" with selector '" + messageSelector) + "'") + (noLocal == null ? "" : (" and noLocal=" + noLocal)); } } btm-dist-2.1.4/src/bitronix/tm/resource/ResourceRegistrar.java0000644000175000017500000001313612147207062023223 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource; import bitronix.tm.TransactionManagerServices; import bitronix.tm.recovery.IncrementalRecoverer; import bitronix.tm.recovery.RecoveryException; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.resource.common.XAResourceProducer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.xa.XAResource; import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** * Collection of initialized {@link XAResourceProducer}s. All resources must be registered in the {@link ResourceRegistrar} * before they can be used by the transaction manager. * * @author lorban */ public class ResourceRegistrar { private final static Logger log = LoggerFactory.getLogger(ResourceRegistrar.class); private static final Lock registrationLock = new ReentrantLock(); private static final ConcurrentMap resources = new ConcurrentHashMap(); /** * Get a registered {@link XAResourceProducer}. * @param uniqueName the name of the recoverable resource producer. * @return the {@link XAResourceProducer} or null if there was none registered under that name. */ public static XAResourceProducer get(String uniqueName) { return resources.get(uniqueName); } /** * Get all {@link XAResourceProducer}s unique names. * @return a Set containing all {@link bitronix.tm.resource.common.XAResourceProducer}s unique names. */ public static Set getResourcesUniqueNames() { return Collections.unmodifiableSet(resources.keySet()); } /** * Register a {@link XAResourceProducer}. If registration happens after the transaction manager started, incremental * recovery is run on that resource. * @param producer the {@link XAResourceProducer}. * @throws bitronix.tm.recovery.RecoveryException when an error happens during recovery. */ public static void register(XAResourceProducer producer) throws RecoveryException { registrationLock.lock(); try { String uniqueName = producer.getUniqueName(); if (producer.getUniqueName() == null) throw new IllegalArgumentException("invalid resource with null uniqueName"); if (resources.containsKey(uniqueName)) throw new IllegalArgumentException("resource with uniqueName '" + producer.getUniqueName() + "' has already been registered"); if (TransactionManagerServices.isTransactionManagerRunning()) { if (log.isDebugEnabled()) log.debug("transaction manager is running, recovering resource " + uniqueName); IncrementalRecoverer.recover(producer); } resources.put(uniqueName, producer); } finally { registrationLock.unlock(); } } /** * Unregister a previously registered {@link XAResourceProducer}. * @param producer the {@link XAResourceProducer}. */ public static void unregister(XAResourceProducer producer) { registrationLock.lock(); try { String uniqueName = producer.getUniqueName(); if (producer.getUniqueName() == null) throw new IllegalArgumentException("invalid resource with null uniqueName"); if (!resources.containsKey(uniqueName)) { if (log.isDebugEnabled()) log.debug("resource with uniqueName '" + producer.getUniqueName() + "' has not been registered"); return; } resources.remove(uniqueName); } finally { registrationLock.unlock(); } } /** * Find in the registered {@link XAResourceProducer}s the {@link XAResourceHolder} from which the specified {@link XAResource} comes from. * @param xaResource the {@link XAResource} to look for * @return the associated {@link XAResourceHolder} or null if it cannot be found. */ public static XAResourceHolder findXAResourceHolder(XAResource xaResource) { for (Map.Entry entry : resources.entrySet()) { XAResourceProducer producer = entry.getValue(); XAResourceHolder resourceHolder = producer.findXAResourceHolder(xaResource); if (resourceHolder != null) { if (log.isDebugEnabled()) log.debug("XAResource " + xaResource + " belongs to " + resourceHolder + " that itself belongs to " + producer); return resourceHolder; } if (log.isDebugEnabled()) log.debug("XAResource " + xaResource + " does not belong to any resource of " + producer); } return null; } } btm-dist-2.1.4/src/bitronix/tm/resource/ResourceConfigurationException.java0000644000175000017500000000226612147207062025751 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource; /** * Thrown when a resource cannot be created due to a configuration error. * * @author lorban */ public class ResourceConfigurationException extends RuntimeException { public ResourceConfigurationException(String message, Throwable cause) { super(message, cause); } public ResourceConfigurationException(String s) { super(s); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/0000755000175000017500000000000012215442576017613 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/resource/jdbc/package.html0000644000175000017500000000014412147207062022064 0ustar tonytony

JDBC specific resource management code.

btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcConnectionHandle.java0000644000175000017500000004663012147207062024456 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import bitronix.tm.resource.common.TransactionContextHelper; import bitronix.tm.utils.ClassLoaderUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.RollbackException; import javax.transaction.SystemException; import java.lang.reflect.Proxy; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Savepoint; import java.sql.Statement; /** * Disposable Connection handle. * * @author lorban, brettw */ public class JdbcConnectionHandle extends BaseProxyHandlerClass { // implements Connection private final static Logger log = LoggerFactory.getLogger(JdbcConnectionHandle.class); private final JdbcPooledConnection jdbcPooledConnection; private final Connection delegate; private volatile boolean closed = false; public JdbcConnectionHandle(JdbcPooledConnection jdbcPooledConnection, Connection connection) { this.jdbcPooledConnection = jdbcPooledConnection; this.delegate = connection; } public JdbcPooledConnection getPooledConnection() { return jdbcPooledConnection; } private Connection getDelegate() throws SQLException { if (closed) throw new SQLException("connection is closed"); return delegate; } public Connection getConnection() { return delegate; } public String toString() { return "a JdbcConnectionHandle of " + jdbcPooledConnection + " on " + delegate; } /** * Enlist this connection into the current transaction if automaticEnlistingEnabled = true for this resource. * If no transaction is running then this method does nothing. * @throws SQLException thrown when an error occurs during elistment. */ private void enlistResource() throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.getPoolingDataSource().getAutomaticEnlistingEnabled()) { try { TransactionContextHelper.enlistInCurrentTransaction(jdbcPooledConnection); } catch (SystemException ex) { throw (SQLException) new SQLException("error enlisting " + this).initCause(ex); } catch (RollbackException ex) { throw (SQLException) new SQLException("error enlisting " + this).initCause(ex); } } // if getAutomaticEnlistingEnabled } /* Overridden methods of java.sql.Connection */ public void close() throws SQLException { if (log.isDebugEnabled()) log.debug("closing " + this); // in case the connection has already been closed if (closed) return; jdbcPooledConnection.release(); closed = true; } public void commit() throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) throw new SQLException("cannot commit a resource enlisted in a global transaction"); getDelegate().commit(); } public void rollback() throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) throw new SQLException("cannot rollback a resource enlisted in a global transaction"); getDelegate().rollback(); } public void rollback(Savepoint savepoint) throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) throw new SQLException("cannot rollback a resource enlisted in a global transaction"); getDelegate().rollback(savepoint); } public Savepoint setSavepoint() throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) throw new SQLException("cannot set a savepoint on a resource enlisted in a global transaction"); return getDelegate().setSavepoint(); } public Savepoint setSavepoint(String name) throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) throw new SQLException("cannot set a savepoint on a resource enlisted in a global transaction"); return getDelegate().setSavepoint(name); } public void releaseSavepoint(Savepoint savepoint) throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) throw new SQLException("cannot release a savepoint on a resource enlisted in a global transaction"); getDelegate().releaseSavepoint(savepoint); } public boolean getAutoCommit() throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) return false; return getDelegate().getAutoCommit(); } public void setAutoCommit(boolean autoCommit) throws SQLException { if (closed) throw new SQLException("connection handle already closed"); if (!jdbcPooledConnection.isParticipatingInActiveGlobalTransaction()) getDelegate().setAutoCommit(autoCommit); else if (autoCommit) throw new SQLException("autocommit is not allowed on a resource enlisted in a global transaction"); } public boolean isClosed() throws SQLException { return closed || getDelegate().isClosed(); } public Statement createStatement() throws SQLException { enlistResource(); Statement statement = getDelegate().createStatement(); jdbcPooledConnection.registerUncachedStatement(statement); JdbcStatementHandle statementHandle = new JdbcStatementHandle(statement, jdbcPooledConnection); return (Statement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{Statement.class}, statementHandle); } public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { enlistResource(); Statement statement = getDelegate().createStatement(resultSetType, resultSetConcurrency); jdbcPooledConnection.registerUncachedStatement(statement); JdbcStatementHandle statementHandle = new JdbcStatementHandle(statement, jdbcPooledConnection); return (Statement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{Statement.class}, statementHandle); } public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { enlistResource(); Statement statement = getDelegate().createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); jdbcPooledConnection.registerUncachedStatement(statement); JdbcStatementHandle statementHandle = new JdbcStatementHandle(statement, jdbcPooledConnection); return (Statement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{Statement.class}, statementHandle); } public CallableStatement prepareCall(String sql) throws SQLException { enlistResource(); CallableStatement statement = getDelegate().prepareCall(sql); jdbcPooledConnection.registerUncachedStatement(statement); JdbcCallableStatementHandle statementHandle = new JdbcCallableStatementHandle(statement, jdbcPooledConnection); return (CallableStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{CallableStatement.class}, statementHandle); } public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { enlistResource(); CallableStatement statement = getDelegate().prepareCall(sql, resultSetType, resultSetConcurrency); jdbcPooledConnection.registerUncachedStatement(statement); JdbcCallableStatementHandle statementHandle = new JdbcCallableStatementHandle(statement, jdbcPooledConnection); return (CallableStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{CallableStatement.class}, statementHandle); } public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { enlistResource(); CallableStatement statement = getDelegate().prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); jdbcPooledConnection.registerUncachedStatement(statement); JdbcCallableStatementHandle statementHandle = new JdbcCallableStatementHandle(statement, jdbcPooledConnection); return (CallableStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{CallableStatement.class}, statementHandle); } /* PreparedStatement cache aware methods */ public PreparedStatement prepareStatement(String sql) throws SQLException { enlistResource(); boolean useStatementCache = getPooledConnection().getPoolingDataSource().getPreparedStatementCacheSize() > 0; if (useStatementCache) { JdbcPreparedStatementHandle proposedStmt = new JdbcPreparedStatementHandle(sql); JdbcPreparedStatementHandle cachedStmt = getPooledConnection().getCachedStatement(proposedStmt); if (cachedStmt == null) { PreparedStatement stmt = getDelegate().prepareStatement(sql); proposedStmt.setDelegate(stmt); cachedStmt = getPooledConnection().putCachedStatement(proposedStmt); } cachedStmt.setPooledConnection(getPooledConnection()); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, cachedStmt); } else { PreparedStatement stmt = getDelegate().prepareStatement(sql); jdbcPooledConnection.registerUncachedStatement(stmt); JdbcUncachedPreparedStatementHandle statementHandle = new JdbcUncachedPreparedStatementHandle(stmt, jdbcPooledConnection); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, statementHandle); } } public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { enlistResource(); boolean useStatementCache = getPooledConnection().getPoolingDataSource().getPreparedStatementCacheSize() > 0; if (useStatementCache) { JdbcPreparedStatementHandle proposedStmt = new JdbcPreparedStatementHandle(sql, autoGeneratedKeys); JdbcPreparedStatementHandle cachedStmt = getPooledConnection().getCachedStatement(proposedStmt); if (cachedStmt == null) { PreparedStatement stmt = getDelegate().prepareStatement(sql, autoGeneratedKeys); proposedStmt.setDelegate(stmt); cachedStmt = getPooledConnection().putCachedStatement(proposedStmt); } cachedStmt.setPooledConnection(getPooledConnection()); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, cachedStmt); } else { PreparedStatement stmt = getDelegate().prepareStatement(sql, autoGeneratedKeys); jdbcPooledConnection.registerUncachedStatement(stmt); JdbcUncachedPreparedStatementHandle statementHandle = new JdbcUncachedPreparedStatementHandle(stmt, jdbcPooledConnection); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, statementHandle); } } public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { enlistResource(); boolean useStatementCache = getPooledConnection().getPoolingDataSource().getPreparedStatementCacheSize() > 0; if (useStatementCache) { JdbcPreparedStatementHandle proposedStmt = new JdbcPreparedStatementHandle(sql, resultSetType, resultSetConcurrency); JdbcPreparedStatementHandle cachedStmt = getPooledConnection().getCachedStatement(proposedStmt); if (cachedStmt == null) { PreparedStatement stmt = getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency); proposedStmt.setDelegate(stmt); cachedStmt = getPooledConnection().putCachedStatement(proposedStmt); } cachedStmt.setPooledConnection(getPooledConnection()); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, cachedStmt); } else { PreparedStatement stmt = getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency); jdbcPooledConnection.registerUncachedStatement(stmt); JdbcUncachedPreparedStatementHandle statementHandle = new JdbcUncachedPreparedStatementHandle(stmt, jdbcPooledConnection); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, statementHandle); } } public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { enlistResource(); boolean useStatementCache = getPooledConnection().getPoolingDataSource().getPreparedStatementCacheSize() > 0; if (useStatementCache) { JdbcPreparedStatementHandle proposedStmt = new JdbcPreparedStatementHandle(sql, resultSetType, resultSetConcurrency, resultSetHoldability); JdbcPreparedStatementHandle cachedStmt = getPooledConnection().getCachedStatement(proposedStmt); if (cachedStmt == null) { PreparedStatement stmt = getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); proposedStmt.setDelegate(stmt); cachedStmt = getPooledConnection().putCachedStatement(proposedStmt); } cachedStmt.setPooledConnection(getPooledConnection()); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, cachedStmt); } else { PreparedStatement stmt = getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); jdbcPooledConnection.registerUncachedStatement(stmt); JdbcUncachedPreparedStatementHandle statementHandle = new JdbcUncachedPreparedStatementHandle(stmt, jdbcPooledConnection); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, statementHandle); } } public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { enlistResource(); boolean useStatementCache = getPooledConnection().getPoolingDataSource().getPreparedStatementCacheSize() > 0; if (useStatementCache) { JdbcPreparedStatementHandle proposedStmt = new JdbcPreparedStatementHandle(sql, columnIndexes); JdbcPreparedStatementHandle cachedStmt = getPooledConnection().getCachedStatement(proposedStmt); if (cachedStmt == null) { PreparedStatement stmt = getDelegate().prepareStatement(sql, columnIndexes); proposedStmt.setDelegate(stmt); cachedStmt = getPooledConnection().putCachedStatement(proposedStmt); } cachedStmt.setPooledConnection(getPooledConnection()); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, cachedStmt); } else { PreparedStatement stmt = getDelegate().prepareStatement(sql, columnIndexes); jdbcPooledConnection.registerUncachedStatement(stmt); JdbcUncachedPreparedStatementHandle statementHandle = new JdbcUncachedPreparedStatementHandle(stmt, jdbcPooledConnection); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, statementHandle); } } public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { enlistResource(); boolean useStatementCache = getPooledConnection().getPoolingDataSource().getPreparedStatementCacheSize() > 0; if (useStatementCache) { JdbcPreparedStatementHandle proposedStmt = new JdbcPreparedStatementHandle(sql, columnNames); JdbcPreparedStatementHandle cachedStmt = getPooledConnection().getCachedStatement(proposedStmt); if (cachedStmt == null) { PreparedStatement stmt = getDelegate().prepareStatement(sql, columnNames); proposedStmt.setDelegate(stmt); cachedStmt = getPooledConnection().putCachedStatement(proposedStmt); } cachedStmt.setPooledConnection(getPooledConnection()); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, cachedStmt); } else { PreparedStatement stmt = getDelegate().prepareStatement(sql, columnNames); jdbcPooledConnection.registerUncachedStatement(stmt); JdbcUncachedPreparedStatementHandle statementHandle = new JdbcUncachedPreparedStatementHandle(stmt, jdbcPooledConnection); return (PreparedStatement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{PreparedStatement.class}, statementHandle); } } /* java.sql.Wrapper implementation */ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(delegate.getClass()); } public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(delegate.getClass())) { return (T) delegate; } throw new SQLException(getClass().getName() + " is not a wrapper for " + iface); } /* BaseProxyHandler implementation */ public Object getProxiedDelegate() throws Exception { return delegate; } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/LruStatementCache.java0000644000175000017500000002065612147207062024033 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.sql.PreparedStatement; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.CopyOnWriteArrayList; /** * Last Recently Used PreparedStatement cache with eviction listeners * support implementation. * * * @author lorban, brettw */ public class LruStatementCache { private final static Logger log = LoggerFactory.getLogger(LruStatementCache.class); /** * The target maxSize of the cache. The cache may drift slightly * higher in size in the case that every statement in the cache is * in use and therefore nothing can be evicted. But eventually * (probably quickly) the cache will return to maxSize. */ private int maxSize; /** * We use a LinkedHashMap with _access order_ specified in the * constructor. According to the LinkedHashMap documentation: *
     *   A special constructor is provided to create a linked hash map
     *   whose order of iteration is the order in which its entries
     *   were last accessed, from least-recently accessed to most-recently
     *   (access-order). This kind of map is well-suited to building LRU
     *   caches. Invoking the put or get method results in an access to
     *   the corresponding entry (assuming it exists after the invocation
     *   completes).
     * 
*/ private final LinkedHashMap cache; /** * A list of listeners concerned with prepared statement cache * evictions. */ private final List evictionListners; /** * See the LinkedHashMap documentation. We maintain our own size * here, rather than calling size(), because size() on a LinkedHashMap * is proportional in time (O(n)) with the size of the collection -- i.e. * calling size() must traverse the entire list and count the elements. * Tracking size ourselves provides O(1) access. */ private int size; public LruStatementCache(int maxSize) { this.maxSize = maxSize; cache = new LinkedHashMap(maxSize, 0.75f, true /* access order */); evictionListners = new CopyOnWriteArrayList(); } /** * The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes * in with no actual 'delegate' PreparedStatement. However, it contains all * other pertinent information such as SQL statement, autogeneratedkeys * flag, cursor holdability, etc. See the equals() method in the * JdbcPreparedStatementHandle class. It is a complete key for a cached * statement. * * If there is a matching cached PreparedStatement, it will be set as the * delegate in the provided JdbcPreparedStatementHandle. * * @param key the cache key * @return the cached JdbcPreparedStatementHandle statement, or null */ public JdbcPreparedStatementHandle get(JdbcPreparedStatementHandle key) { synchronized (cache) { // See LinkedHashMap documentation. Getting an entry means it is // updated as the 'youngest' (Most Recently Used) entry. StatementTracker cached = cache.get(key); if (cached != null) { cached.usageCount++; key.setDelegate(cached.statement); if (log.isDebugEnabled()) log.debug("delivered from cache with usage count " + cached.usageCount + " statement <" + key + "> in " + key.getPooledConnection()); return key; } return null; } } /** * A statement is put into the cache. This is called when a * statement is first prepared and also when a statement is * closed (by the client). A "closed" statement has it's * usage counter decremented in the cache. * * @param key a prepared statement handle * @return a prepared statement */ public JdbcPreparedStatementHandle put(JdbcPreparedStatementHandle key) { synchronized (cache) { if (maxSize < 1) { return null; } // See LinkedHashMap documentation. Getting an entry means it is // updated as the 'youngest' (Most Recently Used) entry. StatementTracker cached = cache.get(key); if (cached == null) { if (log.isDebugEnabled()) log.debug("adding to cache statement <" + key + "> in " + key.getPooledConnection()); cache.put(key, new StatementTracker(key.getDelegateUnchecked())); size++; } else { cached.usageCount--; if (log.isDebugEnabled()) log.debug("returning to cache statement <" + key + "> with usage count " + cached.usageCount + " in " + key.getPooledConnection()); } // If the size is exceeded, we will _try_ to evict one (or more) // statements until the max level is again reached. However, if // every statement in the cache is 'in use', the size of the cache // is not reduced. Eventually the cache will be reduced, no worries. if (size > maxSize) { tryEviction(); } return key; } } /** * Evict all statements from the cache. This likely happens on * connection close. */ protected void clear() { synchronized (cache) { Iterator it = cache.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Entry) it.next(); StatementTracker tracker = (StatementTracker) entry.getValue(); it.remove(); fireEvictionEvent(tracker.statement); } cache.clear(); size = 0; } } /** * Try to evict statements from the cache. Only statements with a * current usage count of zero will be evicted. Statements are * evicted until the cache is reduced to maxSize. */ private void tryEviction() { synchronized (cache) { // Iteration order of the LinkedHashMap is from LRU to MRU Iterator it = cache.entrySet().iterator(); while (it.hasNext()) { Entry entry = (Entry) it.next(); StatementTracker tracker = (StatementTracker) entry.getValue(); if (tracker.usageCount == 0) { it.remove(); size--; JdbcPreparedStatementHandle key = (JdbcPreparedStatementHandle) entry.getKey(); if (log.isDebugEnabled()) log.debug("evicting from cache statement <" + key + "> " + key.getDelegateUnchecked() + " in " + key.getPooledConnection()); fireEvictionEvent(tracker.statement); // We can stop evicting if we're at maxSize... if (size <= maxSize) { break; } } } } } private void fireEvictionEvent(Object value) { for (LruEvictionListener listener : evictionListners) { listener.onEviction(value); } } public void addEvictionListener(LruEvictionListener listener) { evictionListners.add(listener); } public void removeEvictionListener(LruEvictionListener listener) { evictionListners.remove(listener); } private final static class StatementTracker { private final PreparedStatement statement; private int usageCount; private StatementTracker(PreparedStatement stmt) { this.statement = stmt; this.usageCount = 1; } } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/PoolingDataSourceMBean.java0000644000175000017500000000226512147207062024741 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; /** * * @author lorban */ public interface PoolingDataSourceMBean { public int getMinPoolSize(); public int getMaxPoolSize(); public long getInPoolSize(); public long getTotalPoolSize(); public boolean isFailed(); public void reset() throws Exception; public boolean isDisabled(); public void setDisabled(boolean disabled); } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcUncachedPreparedStatementHandle.java0000644000175000017500000000650312215442576027443 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import java.lang.reflect.Proxy; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import bitronix.tm.utils.ClassLoaderUtils; public class JdbcUncachedPreparedStatementHandle extends BaseProxyHandlerClass { // The 'parent' connection. Used to remove this statement delegate // from the un-closed statements list when close() is called. private final JdbcPooledConnection parentConnection; private final PreparedStatement delegate; public JdbcUncachedPreparedStatementHandle(PreparedStatement delegate, JdbcPooledConnection pooledConnection) { this.delegate = delegate; this.parentConnection = pooledConnection; } public Object getProxiedDelegate() throws Exception { return delegate; } /* java.sql.Wrapper implementation */ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(delegate.getClass()); } public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(delegate.getClass())) { return (T) delegate; } throw new SQLException(getClass().getName() + " is not a wrapper for " + iface); } /* Overridden methods of java.sql.PreparedStatement */ public void close() throws SQLException { parentConnection.unregisterUncachedStatement(delegate); delegate.close(); } public ResultSet executeQuery(String sql) throws SQLException { return (ResultSet) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{ResultSet.class}, new JdbcResultSetHandle(delegate.executeQuery(sql), this)); } public ResultSet getGeneratedKeys() throws SQLException { return (ResultSet) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{ResultSet.class}, new JdbcResultSetHandle(delegate.getGeneratedKeys(), this)); } public ResultSet getResultSet() throws SQLException { return (ResultSet) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{ResultSet.class}, new JdbcResultSetHandle(delegate.getResultSet(), this)); } public ResultSet executeQuery() throws SQLException { return (ResultSet) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{ResultSet.class}, new JdbcResultSetHandle(delegate.executeQuery(), this)); } public boolean equals(Object object) { Object handler = Proxy.getInvocationHandler(object); return super.equals(handler); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcPooledConnectionMBean.java0000644000175000017500000000217712147207062025406 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import java.util.Collection; import java.util.Date; /** * {@link JdbcPooledConnection} Management interface. * * @author lorban */ public interface JdbcPooledConnectionMBean { String getStateDescription(); Date getAcquisitionDate(); Collection getTransactionGtridsCurrentlyHoldingThis(); } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/ConnectionCustomizer.java0000644000175000017500000000145312147207062024636 0ustar tonytonypackage bitronix.tm.resource.jdbc; import java.sql.Connection; /** * Listener of connections created by a PoolingDataSource. Implementations of this class must be serializable * and are handed raw, physical database Connections * * @author Ludovic Orban */ public interface ConnectionCustomizer { /** * Called when the physical connection is created. * @param connection the physical connection. * @param uniqueName the PoolingDataSource unique name. */ public void onAcquire(Connection connection, String uniqueName); /** * Called when the physical connection is destroyed. * @param connection the physical connection. * @param uniqueName the PoolingDataSource unique name. */ public void onDestroy(Connection connection, String uniqueName); } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/PoolingDataSource.java0000644000175000017500000003437212147207062024042 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.recovery.RecoveryException; import bitronix.tm.resource.ResourceConfigurationException; import bitronix.tm.resource.ResourceObjectFactory; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.common.RecoveryXAResourceHolder; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.resource.common.XAPool; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.resource.common.XAResourceProducer; import bitronix.tm.resource.common.XAStatefulHolder; import bitronix.tm.utils.ClassLoaderUtils; import bitronix.tm.utils.ManagementRegistrar; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.naming.NamingException; import javax.naming.Reference; import javax.naming.StringRefAddr; import javax.sql.DataSource; import javax.sql.XADataSource; import javax.transaction.xa.XAResource; import java.io.PrintWriter; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import java.sql.Connection; import java.sql.SQLException; import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** * Implementation of a JDBC {@link DataSource} wrapping vendor's {@link XADataSource} implementation. * * @author lorban, brettw */ public class PoolingDataSource extends ResourceBean implements DataSource, XAResourceProducer, PoolingDataSourceMBean { private final static Logger log = LoggerFactory.getLogger(PoolingDataSource.class); private volatile transient XAPool pool; private volatile transient XADataSource xaDataSource; private volatile transient RecoveryXAResourceHolder recoveryXAResourceHolder; private volatile transient JdbcConnectionHandle recoveryConnectionHandle; private volatile String testQuery; private volatile boolean enableJdbc4ConnectionTest; private volatile int preparedStatementCacheSize = 0; private volatile String isolationLevel; private volatile String cursorHoldability; private volatile String localAutoCommit; private volatile String jmxName; private final List connectionCustomizers = new CopyOnWriteArrayList(); public PoolingDataSource() { } /** * Initializes the pool by creating the initial amount of connections. */ public synchronized void init() { try { if (this.pool != null) return; buildXAPool(); this.jmxName = "bitronix.tm:type=JDBC,UniqueName=" + ManagementRegistrar.makeValidName(getUniqueName()); ManagementRegistrar.register(jmxName, this); } catch (Exception ex) { throw new ResourceConfigurationException("cannot create JDBC datasource named " + getUniqueName(), ex); } } private synchronized void buildXAPool() throws Exception { if (pool != null) return; if (log.isDebugEnabled()) log.debug("building XA pool for " + getUniqueName() + " with " + getMinPoolSize() + " connection(s)"); pool = new XAPool(this, this); xaDataSource = (XADataSource) pool.getXAFactory(); try { ResourceRegistrar.register(this); } catch (RecoveryException ex) { pool = null; xaDataSource = null; throw ex; } } /** * @return the query that will be used to test connections. */ public String getTestQuery() { return testQuery; } /** * When set, the specified query will be executed on the connection acquired from the pool before being handed to * the caller. The connections won't be tested when not set. Default value is null. * @param testQuery the query that will be used to test connections. */ public void setTestQuery(String testQuery) { this.testQuery = testQuery; } /** * When set and the underlying JDBC driver supports JDBC 4 isValid(), a Connection.isValid() call * is performed to test the connection before handing it to the caller. * If both testQuery and enableJdbc4ConnectionTest are set, enableJdbc4ConnectionTest takes precedence. * @param enableJdbc4ConnectionTest true if JDBC 4 isValid() testing should be performed, false otherwise. */ public void setEnableJdbc4ConnectionTest(boolean enableJdbc4ConnectionTest) { this.enableJdbc4ConnectionTest = enableJdbc4ConnectionTest; } /** * @return true if JDBC 4 isValid() testing should be performed, false otherwise. */ public boolean isEnableJdbc4ConnectionTest() { return enableJdbc4ConnectionTest; } /** * @return the target maximum prepared statement cache size. */ public int getPreparedStatementCacheSize() { return preparedStatementCacheSize; } /** * Set the target maximum size of the prepared statement cache. In * reality under certain unusual conditions the cache may temporarily * drift higher in size. * @param preparedStatementCacheSize the target maximum prepared statement cache size. */ public void setPreparedStatementCacheSize(int preparedStatementCacheSize) { this.preparedStatementCacheSize = preparedStatementCacheSize; } /** * @return the default isolation level. */ public String getIsolationLevel() { return isolationLevel; } /** * Set the default isolation level for connections. * @param isolationLevel the default isolation level. */ public void setIsolationLevel(String isolationLevel) { this.isolationLevel = isolationLevel; } /** * @return cursorHoldability the default cursor holdability. */ public String getCursorHoldability() { return cursorHoldability; } /** * Set the default cursor holdability for connections. * @param cursorHoldability the default cursor holdability. */ public void setCursorHoldability(String cursorHoldability) { this.cursorHoldability = cursorHoldability; } /** * @return localAutoCommit the default local transactions autocommit mode. */ public String getLocalAutoCommit() { return localAutoCommit; } /** * Set the default local transactions autocommit mode. * @param localAutoCommit the default local transactions autocommit mode. */ public void setLocalAutoCommit(String localAutoCommit) { this.localAutoCommit = localAutoCommit; } public void addConnectionCustomizer(ConnectionCustomizer connectionCustomizer) { connectionCustomizers.add(connectionCustomizer); } public void removeConnectionCustomizer(ConnectionCustomizer connectionCustomizer) { Iterator it = connectionCustomizers.iterator(); while (it.hasNext()) { ConnectionCustomizer customizer = (ConnectionCustomizer)it.next(); if (customizer == connectionCustomizer) { it.remove(); return; } } } void fireOnAcquire(Connection connection) { for (ConnectionCustomizer connectionCustomizer : connectionCustomizers) { try { connectionCustomizer.onAcquire(connection, getUniqueName()); } catch (Exception ex) { log.warn("ConnectionCustomizer.onAcquire() failed for " + connectionCustomizer, ex); } } } void fireOnDestroy(Connection connection) { for (ConnectionCustomizer connectionCustomizer : connectionCustomizers) { try { connectionCustomizer.onDestroy(connection, getUniqueName()); } catch (Exception ex) { log.warn("ConnectionCustomizer.onDestroy() failed for " + connectionCustomizer, ex); } } } /* Implementation of DataSource interface */ public Connection getConnection() throws SQLException { if (isDisabled()) { throw new SQLException("JDBC connection pool '" + getUniqueName() + "' is disabled, cannot get a connection from it"); } init(); if (log.isDebugEnabled()) log.debug("acquiring connection from " + this); if (pool == null) { if (log.isDebugEnabled()) log.debug("pool is closed, returning null connection"); return null; } try { InvocationHandler connectionHandle = (InvocationHandler) pool.getConnectionHandle(); if (log.isDebugEnabled()) log.debug("acquired connection from " + this); return (Connection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { Connection.class }, connectionHandle); } catch (Exception ex) { throw (SQLException) new SQLException("unable to get a connection from pool of " + this).initCause(ex); } } public Connection getConnection(String username, String password) throws SQLException { if (log.isDebugEnabled()) log.debug("JDBC connections are pooled, username and password ignored"); return getConnection(); } public String toString() { return "a PoolingDataSource containing " + pool; } /* XAResourceProducer implementation */ public XAResourceHolderState startRecovery() throws RecoveryException { init(); if (recoveryConnectionHandle != null) throw new RecoveryException("recovery already in progress on " + this); try { recoveryConnectionHandle = (JdbcConnectionHandle) pool.getConnectionHandle(false); recoveryXAResourceHolder = recoveryConnectionHandle.getPooledConnection().createRecoveryXAResourceHolder(); return new XAResourceHolderState(recoveryConnectionHandle.getPooledConnection(), this); } catch (Exception ex) { throw new RecoveryException("cannot start recovery on " + this, ex); } } public void endRecovery() throws RecoveryException { if (recoveryConnectionHandle == null) return; try { if (log.isDebugEnabled()) log.debug("recovery xa resource is being closed: " + recoveryXAResourceHolder); recoveryConnectionHandle.close(); } catch (Exception ex) { throw new RecoveryException("error ending recovery on " + this, ex); } finally { recoveryConnectionHandle = null; // the recoveryXAResourceHolder actually wraps the recoveryConnectionHandle so closing it // would close the recoveryConnectionHandle twice which must not happen recoveryXAResourceHolder = null; } } public void setFailed(boolean failed) { pool.setFailed(failed); } public boolean isFailed() { return pool.isFailed(); } public void close() { if (pool == null) { if (log.isDebugEnabled()) log.debug("trying to close already closed PoolingDataSource " + getUniqueName()); return; } if (log.isDebugEnabled()) log.debug("closing " + this); pool.close(); pool = null; connectionCustomizers.clear(); ManagementRegistrar.unregister(jmxName); jmxName = null; ResourceRegistrar.unregister(this); } public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception { if (!(xaFactory instanceof XADataSource)) throw new IllegalArgumentException("class '" + xaFactory.getClass().getName() + "' does not implement " + XADataSource.class.getName()); XADataSource xads = (XADataSource) xaFactory; return new JdbcPooledConnection(this, xads.getXAConnection()); } public XAResourceHolder findXAResourceHolder(XAResource xaResource) { return pool.findXAResourceHolder(xaResource); } /** * {@link PoolingDataSource} must alway have a unique name so this method builds a reference to this object using * the unique name as {@link javax.naming.RefAddr}. * @return a reference to this {@link PoolingDataSource}. */ public Reference getReference() throws NamingException { if (log.isDebugEnabled()) log.debug("creating new JNDI reference of " + this); return new Reference( PoolingDataSource.class.getName(), new StringRefAddr("uniqueName", getUniqueName()), ResourceObjectFactory.class.getName(), null); } /* DataSource implementation */ public int getLoginTimeout() throws SQLException { return xaDataSource.getLoginTimeout(); } public void setLoginTimeout(int seconds) throws SQLException { xaDataSource.setLoginTimeout(seconds); } public PrintWriter getLogWriter() throws SQLException { return xaDataSource.getLogWriter(); } public void setLogWriter(PrintWriter out) throws SQLException { xaDataSource.setLogWriter(out); } /* java.sql.Wrapper implementation */ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(xaDataSource.getClass()); } public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(xaDataSource.getClass())) { return (T) xaDataSource; } throw new SQLException(getClass().getName() + " is not a wrapper for " + iface); } /* management */ public long getInPoolSize() { return pool.inPoolSize(); } public long getTotalPoolSize() { return pool.totalPoolSize(); } public void reset() throws Exception { pool.reset(); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcStatementHandle.java0000644000175000017500000000675312215442436024327 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import java.lang.reflect.Proxy; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import bitronix.tm.utils.ClassLoaderUtils; /** * Statement {@link Statement} wrapper. *

* This class is a proxy handler for a Statement. It does not * implement the Statement interface or extend a class directly, * but you methods implemented here will override those of the * underlying delegate. Simply implement a method with the same * signature, and the local method will be called rather than the delegate. *

* * @author brettw */ public class JdbcStatementHandle extends BaseProxyHandlerClass { // implements Statement // The 'parent' connection. Used to remove this statement delegate // from the un-closed statements list when close() is called. private final JdbcPooledConnection parentConnection; private final Statement delegate; public JdbcStatementHandle(Statement delegate, JdbcPooledConnection pooledConnection) { this.delegate = delegate; this.parentConnection = pooledConnection; } /* java.sql.Wrapper implementation */ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(delegate.getClass()); } public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(delegate.getClass())) { return (T) delegate; } throw new SQLException(getClass().getName() + " is not a wrapper for " + iface); } /* Internal methods */ public Object getProxiedDelegate() throws Exception { return delegate; } /* Overridden methods of java.sql.PreparedStatement */ public void close() throws SQLException { parentConnection.unregisterUncachedStatement(delegate); delegate.close(); } public ResultSet executeQuery(String sql) throws SQLException { return (ResultSet) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{ResultSet.class}, new JdbcResultSetHandle(delegate.executeQuery(sql), this)); } public ResultSet getGeneratedKeys() throws SQLException { return (ResultSet) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{ResultSet.class}, new JdbcResultSetHandle(delegate.getGeneratedKeys(), this)); } public ResultSet getResultSet() throws SQLException { return (ResultSet) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{ResultSet.class}, new JdbcResultSetHandle(delegate.getResultSet(), this)); } public boolean equals(Object object) { Object handler = Proxy.getInvocationHandler(object); return super.equals(handler); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcResultSetHandle.java0000644000175000017500000000515512215442120024276 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import java.lang.reflect.Proxy; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import bitronix.tm.utils.ClassLoaderUtils; /** * ResultSet {@link ResultSet} wrapper. *

* This class is a proxy handler for a ResultSet. It does not * implement the ResultSet interface or extend a class directly, * but you methods implemented here will override those of the * underlying delegate. Simply implement a method with the same * signature, and the local method will be called rather than the delegate. *

* * @author brettw */ public class JdbcResultSetHandle extends BaseProxyHandlerClass { // implements ResultSet private final ResultSet delegate; private final BaseProxyHandlerClass statementHandle; public JdbcResultSetHandle(ResultSet delegate, BaseProxyHandlerClass statementHandle) { this.delegate = delegate; this.statementHandle = statementHandle; } /* java.sql.Wrapper implementation */ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(delegate.getClass()); } public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(delegate.getClass())) { return (T) delegate; } throw new SQLException(getClass().getName() + " is not a wrapper for " + iface); } /* Internal methods */ public Object getProxiedDelegate() throws Exception { return delegate; } /* Overridden methods of java.sql.ResultSet */ public void close() throws SQLException { delegate.close(); } public Statement getStatement() throws SQLException { return (Statement) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{Statement.class}, statementHandle); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/lrc/0000755000175000017500000000000012147207062020364 5ustar tonytonybtm-dist-2.1.4/src/bitronix/tm/resource/jdbc/lrc/package.html0000644000175000017500000000067612147207062022656 0ustar tonytony

XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource. Note that if you use the classes of this package you have accepted the heuristic hazard. A crash during commit of a connection returned by this datasource could lead to an inconsistent global state. This is a limitation of the Last Resource Commit technique, not of BTM.

btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/lrc/LrcXAResource.java0000644000175000017500000003065512147207062023721 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc.lrc; import bitronix.tm.internal.BitronixXAException; import bitronix.tm.utils.Decoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import java.sql.Connection; import java.sql.SQLException; /** * XAResource implementation for a non-XA JDBC connection emulating XA with Last Resource Commit. *

The XA protocol flow is implemented by this state machine:

*
 * NO_TX
 *   |
 *   | start(TMNOFLAGS)
 *   |
 *   |       end(TMFAIL)
 * STARTED -------------- NO_TX
 *   |
 *   | end(TMSUCCESS)
 *   |
 *   |    start(TMJOIN)
 * ENDED ---------------- STARTED
 *   |\
 *   | \  commit (one phase)
 *   |  ----------------- NO_TX
 *   |
 *   | prepare()
 *   |
 *   |       commit() or
 *   |       rollback()
 * PREPARED ------------- NO_TX
 * 
* {@link XAResource#TMSUSPEND} and {@link XAResource#TMRESUME} are not supported. * * @author lorban */ public class LrcXAResource implements XAResource { private final static Logger log = LoggerFactory.getLogger(LrcXAResource.class); public static final int NO_TX = 0; public static final int STARTED = 1; public static final int ENDED = 2; public static final int PREPARED = 3; private final Connection connection; private volatile Xid xid; private volatile boolean autocommitActiveBeforeStart; private volatile int state = NO_TX; public LrcXAResource(Connection connection) { this.connection = connection; } public int getState() { return state; } private String xlatedState() { switch (state) { case NO_TX: return "NO_TX"; case STARTED: return "STARTED"; case ENDED: return "ENDED"; case PREPARED: return "PREPARED"; default: return "!invalid state (" + state + ")!"; } } public int getTransactionTimeout() throws XAException { return 0; } public boolean setTransactionTimeout(int seconds) throws XAException { return false; } public void forget(Xid xid) throws XAException { } public Xid[] recover(int flags) throws XAException { return new Xid[0]; } public boolean isSameRM(XAResource xaResource) throws XAException { return xaResource == this; } public void start(Xid xid, int flag) throws XAException { if (flag != XAResource.TMNOFLAGS && flag != XAResource.TMJOIN) throw new BitronixXAException("unsupported start flag " + Decoder.decodeXAResourceFlag(flag), XAException.XAER_RMERR); if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { if (this.xid != null) throw new BitronixXAException("resource already started on XID " + this.xid, XAException.XAER_PROTO); else { if (flag == XAResource.TMJOIN) throw new BitronixXAException("resource not yet started", XAException.XAER_PROTO); else { if (log.isDebugEnabled()) log.debug("OK to start, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); this.xid = xid; } } } else if (state == STARTED) { throw new BitronixXAException("resource already started on XID " + this.xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (flag == XAResource.TMNOFLAGS) throw new BitronixXAException("resource already registered XID " + this.xid, XAException.XAER_DUPID); else { if (xid.equals(this.xid)) { if (log.isDebugEnabled()) log.debug("OK to join, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot start it on more than one XID at a time", XAException.XAER_RMERR); } } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { autocommitActiveBeforeStart = connection.getAutoCommit(); if (autocommitActiveBeforeStart) { if (log.isDebugEnabled()) log.debug("disabling autocommit mode on non-XA connection"); connection.setAutoCommit(false); } this.state = STARTED; } catch (SQLException ex) { throw new BitronixXAException("cannot disable autocommit on non-XA connection", XAException.XAER_RMERR); } } public void end(Xid xid, int flag) throws XAException { if (flag != XAResource.TMSUCCESS && flag != XAResource.TMFAIL) throw new BitronixXAException("unsupported end flag " + Decoder.decodeXAResourceFlag(flag), XAException.XAER_RMERR); if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to end, old state=" + xlatedState() + ", XID=" + xid + ", flag=" + Decoder.decodeXAResourceFlag(flag)); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot end it on another XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { throw new BitronixXAException("resource already ended on XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("cannot end, resource already prepared on XID " + xid, XAException.XAER_PROTO); } if (flag == XAResource.TMFAIL) { try { connection.rollback(); state = NO_TX; this.xid = null; return; } catch (SQLException ex) { throw new BitronixXAException("error rolling back resource on end", XAException.XAER_RMERR, ex); } } this.state = ENDED; } public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { connection.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (SQLException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } } public void commit(Xid xid, boolean onePhase) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (onePhase) { if (log.isDebugEnabled()) log.debug("OK to commit with 1PC, old state=" + xlatedState() + ", XID=" + xid); try { connection.commit(); } catch (SQLException ex) { throw new BitronixXAException("error committing (one phase) non-XA resource", XAException.XAER_RMERR, ex); } } else throw new BitronixXAException("resource never prepared on XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { if (!onePhase) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to commit, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot commit it on another XID " + xid, XAException.XAER_PROTO); } else throw new BitronixXAException("cannot commit in one phase as resource has been prepared on XID " + xid, XAException.XAER_PROTO); } this.state = NO_TX; this.xid = null; try { if (autocommitActiveBeforeStart) { if (log.isDebugEnabled()) log.debug("enabling back autocommit mode on non-XA connection"); connection.setAutoCommit(true); } } catch (SQLException ex) { throw new BitronixXAException("cannot reset autocommit on non-XA connection", XAException.XAER_RMERR); } } public void rollback(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to rollback, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot roll it back on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { this.state = NO_TX; throw new BitronixXAException("resource committed during prepare on XID " + this.xid, XAException.XA_HEURCOM); } try { connection.rollback(); } catch (SQLException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } finally { this.state = NO_TX; this.xid = null; } try { if (autocommitActiveBeforeStart) { if (log.isDebugEnabled()) log.debug("enabling back autocommit mode on non-XA connection"); connection.setAutoCommit(true); } } catch (SQLException ex) { throw new BitronixXAException("cannot reset autocommit on non-XA connection", XAException.XAER_RMERR); } } public String toString() { return "a JDBC LrcXAResource in state " + xlatedState(); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/lrc/LrcConnectionHandle.java0000644000175000017500000000626412147207062025113 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc.lrc; import bitronix.tm.resource.jdbc.BaseProxyHandlerClass; import java.sql.Connection; import java.sql.SQLException; import java.sql.Savepoint; /** * Connection handle implementation for a non-XA JDBC resource emulating XA with Last Resource Commit. * * @author lorban, brettw */ public class LrcConnectionHandle extends BaseProxyHandlerClass { // implements Connection private final Connection delegate; private final LrcXAResource xaResource; private volatile boolean closed = false; public LrcConnectionHandle(LrcXAResource xaResource, Connection delegate) { this.delegate = delegate; this.xaResource = xaResource; } public Connection getConnection() { return delegate; } private Connection getDelegate() throws SQLException { if (delegate == null) throw new SQLException("connection is closed"); return delegate; } /* wrapped Connection methods that have special XA semantics */ public void close() throws SQLException { closed = true; } public boolean isClosed() throws SQLException { return closed; } public void setAutoCommit(boolean autoCommit) throws SQLException { if (xaResource.getState() != LrcXAResource.NO_TX && autoCommit) throw new SQLException("XA transaction started, cannot enable autocommit mode"); getDelegate().setAutoCommit(autoCommit); } public void commit() throws SQLException { if (xaResource.getState() != LrcXAResource.NO_TX) throw new SQLException("XA transaction started, cannot call commit directly on connection"); getDelegate().commit(); } public void rollback() throws SQLException { if (xaResource.getState() != LrcXAResource.NO_TX) throw new SQLException("XA transaction started, cannot call rollback directly on connection"); getDelegate().rollback(); } public void rollback(Savepoint savepoint) throws SQLException { if (xaResource.getState() != LrcXAResource.NO_TX) throw new SQLException("XA transaction started, cannot call rollback directly on connection"); getDelegate().rollback(savepoint); } public String toString() { return "a JDBC LrcConnectionHandle on " + xaResource; } public Object getProxiedDelegate() throws Exception { return getDelegate(); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/lrc/LrcXADataSource.java0000644000175000017500000001041112147207062024150 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc.lrc; import bitronix.tm.utils.ClassLoaderUtils; import javax.sql.XAConnection; import javax.sql.XADataSource; import java.io.PrintWriter; import java.lang.reflect.Proxy; import java.sql.Connection; import java.sql.Driver; import java.sql.SQLException; import java.util.Properties; /** * XADataSource implementation for a non-XA JDBC resource emulating XA with Last Resource Commit. * * @author lorban, brettw */ public class LrcXADataSource implements XADataSource { private volatile int loginTimeout; private volatile String driverClassName; private volatile String url; private volatile String user; private volatile String password; public LrcXADataSource() { } public int getLoginTimeout() throws SQLException { return loginTimeout; } public void setLoginTimeout(int seconds) throws SQLException { this.loginTimeout = seconds; } public String getDriverClassName() { return driverClassName; } public void setDriverClassName(String driverClassName) { this.driverClassName = driverClassName; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public PrintWriter getLogWriter() throws SQLException { return null; } public void setLogWriter(PrintWriter out) throws SQLException { } public XAConnection getXAConnection() throws SQLException { try { Class driverClazz = ClassLoaderUtils.loadClass(driverClassName); Driver driver = (Driver) driverClazz.newInstance(); Properties props = new Properties(); if (user != null) props.setProperty("user", user); if (password != null) props.setProperty("password", password); Connection connection = driver.connect(url, props); LrcXAConnection lrcXAConnection = new LrcXAConnection(connection); return (XAConnection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { XAConnection.class }, lrcXAConnection); } catch (Exception ex) { throw (SQLException) new SQLException("unable to connect to non-XA resource " + driverClassName).initCause(ex); } } public XAConnection getXAConnection(String user, String password) throws SQLException { try { Class driverClazz = ClassLoaderUtils.loadClass(driverClassName); Driver driver = (Driver) driverClazz.newInstance(); Properties props = new Properties(); props.setProperty("user", user); props.setProperty("password", password); Connection connection = driver.connect(url, props); LrcXAConnection lrcXAConnection = new LrcXAConnection(connection); return (XAConnection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { XAConnection.class }, lrcXAConnection); } catch (Exception ex) { throw (SQLException) new SQLException("unable to connect to non-XA resource " + driverClassName).initCause(ex); } } public String toString() { return "a JDBC LrcXADataSource on " + driverClassName + " with URL " + url; } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/lrc/LrcXAConnection.java0000644000175000017500000000726412147207062024231 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc.lrc; import bitronix.tm.resource.jdbc.BaseProxyHandlerClass; import bitronix.tm.utils.ClassLoaderUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.sql.ConnectionEvent; import javax.sql.ConnectionEventListener; import javax.sql.XAConnection; import javax.transaction.xa.XAResource; import java.lang.reflect.Proxy; import java.sql.Connection; import java.sql.SQLException; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** * XAConnection implementation for a non-XA JDBC resource emulating XA with Last Resource Commit. * * @author lorban, brettw */ public class LrcXAConnection extends BaseProxyHandlerClass { // implements XAConnection private final static Logger log = LoggerFactory.getLogger(LrcXAConnection.class); private final Connection connection; private final LrcXAResource xaResource; private final List connectionEventListeners = new CopyOnWriteArrayList(); public LrcXAConnection(Connection connection) { this.connection = connection; this.xaResource = new LrcXAResource(connection); } public XAResource getXAResource() throws SQLException { return xaResource; } public void close() throws SQLException { connection.close(); fireCloseEvent(); } public Connection getConnection() throws SQLException { LrcConnectionHandle lrcConnectionHandle = new LrcConnectionHandle(xaResource, connection); return (Connection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[] { Connection.class }, lrcConnectionHandle); } public void addConnectionEventListener(ConnectionEventListener listener) { connectionEventListeners.add(listener); } public void removeConnectionEventListener(ConnectionEventListener listener) { connectionEventListeners.remove(listener); } private void fireCloseEvent() { if (log.isDebugEnabled()) log.debug("notifying " + connectionEventListeners.size() + " connectionEventListeners(s) about closing of " + this); for (ConnectionEventListener connectionEventListener : connectionEventListeners) { XAConnection conn = (XAConnection) Proxy.newProxyInstance(ClassLoaderUtils.getClassLoader(), new Class[]{XAConnection.class}, this); connectionEventListener.connectionClosed(new ConnectionEvent(conn)); } } public boolean equals(Object obj) { if (!(obj instanceof LrcXAConnection)) return false; LrcXAConnection other = (LrcXAConnection) obj; return this.connection.equals(other.connection); } public int hashCode() { return this.connection.hashCode(); } public String toString() { return "a JDBC LrcXAConnection on " + connection; } public Object getProxiedDelegate() throws Exception { return connection; } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/LruEvictionListener.java0000644000175000017500000000177212147207062024427 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; /** * Eviction listener interface for {@link LruStatementCache}. * * @author lorban */ public interface LruEvictionListener { public void onEviction(Object value); } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcPooledConnection.java0000644000175000017500000004640312147207062024503 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import bitronix.tm.internal.BitronixRollbackSystemException; import bitronix.tm.internal.BitronixSystemException; import bitronix.tm.resource.common.AbstractXAResourceHolder; import bitronix.tm.resource.common.RecoveryXAResourceHolder; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.resource.common.StateChangeListener; import bitronix.tm.resource.common.TransactionContextHelper; import bitronix.tm.resource.common.XAResourceHolder; import bitronix.tm.resource.common.XAStatefulHolder; import bitronix.tm.resource.jdbc.lrc.LrcXADataSource; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.ManagementRegistrar; import bitronix.tm.utils.MonotonicClock; import bitronix.tm.utils.Scheduler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.sql.XAConnection; import javax.transaction.SystemException; import javax.transaction.xa.XAResource; import java.lang.reflect.Method; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; /** * Implementation of a JDBC pooled connection wrapping vendor's {@link XAConnection} implementation. * * @author lorban, brettw */ public class JdbcPooledConnection extends AbstractXAResourceHolder implements StateChangeListener, JdbcPooledConnectionMBean { private final static Logger log = LoggerFactory.getLogger(JdbcPooledConnection.class); private final static int DETECTION_TIMEOUT = 5; // seconds private final XAConnection xaConnection; private final Connection connection; private final XAResource xaResource; private final PoolingDataSource poolingDataSource; private final LruStatementCache statementsCache; private final List uncachedStatements; private volatile int usageCount; /* management */ private final String jmxName; private volatile Date acquisitionDate; private volatile Date lastReleaseDate; private volatile int jdbcVersionDetected; private volatile Method isValidMethod; public JdbcPooledConnection(PoolingDataSource poolingDataSource, XAConnection xaConnection) throws SQLException { this.poolingDataSource = poolingDataSource; this.xaConnection = xaConnection; this.xaResource = xaConnection.getXAResource(); this.statementsCache = new LruStatementCache(poolingDataSource.getPreparedStatementCacheSize()); this.uncachedStatements = Collections.synchronizedList(new ArrayList()); this.lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); statementsCache.addEvictionListener(new LruEvictionListener() { public void onEviction(Object value) { PreparedStatement stmt = (PreparedStatement) value; try { stmt.close(); } catch (SQLException ex) { log.warn("error closing evicted statement", ex); } } }); connection = xaConnection.getConnection(); detectJdbcVersion(connection); addStateChangeEventListener(this); if (poolingDataSource.getClassName().equals(LrcXADataSource.class.getName())) { if (log.isDebugEnabled()) log.debug("emulating XA for resource " + poolingDataSource.getUniqueName() + " - changing twoPcOrderingPosition to ALWAYS_LAST_POSITION"); poolingDataSource.setTwoPcOrderingPosition(Scheduler.ALWAYS_LAST_POSITION); if (log.isDebugEnabled()) log.debug("emulating XA for resource " + poolingDataSource.getUniqueName() + " - changing deferConnectionRelease to true"); poolingDataSource.setDeferConnectionRelease(true); if (log.isDebugEnabled()) log.debug("emulating XA for resource " + poolingDataSource.getUniqueName() + " - changing useTmJoin to true"); poolingDataSource.setUseTmJoin(true); } this.jmxName = "bitronix.tm:type=JDBC,UniqueName=" + ManagementRegistrar.makeValidName(poolingDataSource.getUniqueName()) + ",Id=" + poolingDataSource.incCreatedResourcesCounter(); ManagementRegistrar.register(jmxName, this); poolingDataSource.fireOnAcquire(connection); } private synchronized void detectJdbcVersion(Connection connection) { if (jdbcVersionDetected > 0) return; try { isValidMethod = connection.getClass().getMethod("isValid", Integer.TYPE); isValidMethod.invoke(connection, DETECTION_TIMEOUT); // test invoke jdbcVersionDetected = 4; if (!poolingDataSource.isEnableJdbc4ConnectionTest()) { if (log.isDebugEnabled()) log.debug("dataSource is JDBC4 or newer and supports isValid(), but enableJdbc4ConnectionTest is not set or is false"); } } catch (Exception ex) { jdbcVersionDetected = 3; } catch (AbstractMethodError er) { // this happens if the driver implements JDBC 3 but runs on JDK 1.6+ (which embeds the JDBC 4 interfaces) jdbcVersionDetected = 3; } if (log.isDebugEnabled()) log.debug("detected JDBC connection class '" + connection.getClass() + "' is version " + jdbcVersionDetected + " type"); } private void applyIsolationLevel() throws SQLException { String isolationLevel = getPoolingDataSource().getIsolationLevel(); if (isolationLevel != null) { int level = translateIsolationLevel(isolationLevel); if (level < 0) { log.warn("invalid transaction isolation level '" + isolationLevel + "' configured, keeping the default isolation level."); } else { if (log.isDebugEnabled()) log.debug("setting connection's isolation level to " + isolationLevel); connection.setTransactionIsolation(level); } } } private static int translateIsolationLevel(String isolationLevelGuarantee) { if ("READ_COMMITTED".equals(isolationLevelGuarantee)) return Connection.TRANSACTION_READ_COMMITTED; if ("READ_UNCOMMITTED".equals(isolationLevelGuarantee)) return Connection.TRANSACTION_READ_UNCOMMITTED; if ("REPEATABLE_READ".equals(isolationLevelGuarantee)) return Connection.TRANSACTION_REPEATABLE_READ; if ("SERIALIZABLE".equals(isolationLevelGuarantee)) return Connection.TRANSACTION_SERIALIZABLE; return -1; } public void close() throws SQLException { // this should never happen, should we throw an exception or log at warn/error? if (usageCount > 0) { if (log.isDebugEnabled()) log.debug("close connection with usage count > 0, " + this); } setState(STATE_CLOSED); // cleanup of pooled resources statementsCache.clear(); ManagementRegistrar.unregister(jmxName); connection.close(); xaConnection.close(); poolingDataSource.fireOnDestroy(connection); } public RecoveryXAResourceHolder createRecoveryXAResourceHolder() { return new RecoveryXAResourceHolder(this); } private void testConnection(Connection connection) throws SQLException { if (poolingDataSource.isEnableJdbc4ConnectionTest() && jdbcVersionDetected >= 4) { Boolean isValid = null; try { if (log.isDebugEnabled()) log.debug("testing with JDBC4 isValid() method, connection of " + this); isValid = (Boolean) isValidMethod.invoke(connection, poolingDataSource.getAcquisitionTimeout()); } catch (Exception e) { log.warn("dysfunctional JDBC4 Connection.isValid() method, or negative acquisition timeout, in call to test connection of " + this + ". Falling back to test query."); jdbcVersionDetected = 3; } // if isValid is null, and exception was caught above and we fall through to the query test if (isValid != null) { if (isValid) { if (log.isDebugEnabled()) log.debug("isValid successfully tested connection of " + this); return; } throw new SQLException("connection is no longer valid"); } } String query = poolingDataSource.getTestQuery(); if (query == null) { if (log.isDebugEnabled()) log.debug("no query to test connection of " + this + ", skipping test"); return; } // Throws a SQLException if the connection is dead if (log.isDebugEnabled()) log.debug("testing with query '" + query + "' connection of " + this); PreparedStatement stmt = connection.prepareStatement(query); ResultSet rs = stmt.executeQuery(); rs.close(); stmt.close(); if (log.isDebugEnabled()) log.debug("testQuery successfully tested connection of " + this); } protected void release() throws SQLException { if (log.isDebugEnabled()) log.debug("releasing to pool " + this); --usageCount; // delisting try { TransactionContextHelper.delistFromCurrentTransaction(this); } catch (BitronixRollbackSystemException ex) { throw (SQLException) new SQLException("unilateral rollback of " + this).initCause(ex); } catch (SystemException ex) { throw (SQLException) new SQLException("error delisting " + this).initCause(ex); } finally { // Only requeue a connection if it is no longer in use. In the case of non-shared connections, // usageCount will always be 0 here, so the default behavior is unchanged. if (usageCount == 0) { try { TransactionContextHelper.requeue(this, poolingDataSource); } catch (BitronixSystemException ex) { // Requeue failed, restore the usageCount to previous value (see testcase // NewJdbcStrangeUsageMockTest.testClosingSuspendedConnectionsInDifferentContext). // This can happen when a close is attempted while the connection is participating // in a global transaction. usageCount++; // this may hide the exception thrown by delistFromCurrentTransaction() but // an error requeuing must absolutely be reported as an exception. // Too bad if this happens... See DualSessionWrapper.close() as well. throw (SQLException) new SQLException("error requeuing " + this).initCause(ex); } if (log.isDebugEnabled()) log.debug("released to pool " + this); } else { if (log.isDebugEnabled()) log.debug("not releasing " + this + " to pool yet, connection is still shared"); } } // finally } public XAResource getXAResource() { return xaResource; } public ResourceBean getResourceBean() { return getPoolingDataSource(); } public PoolingDataSource getPoolingDataSource() { return poolingDataSource; } public List getXAResourceHolders() { return Arrays.asList((XAResourceHolder) this); } public Object getConnectionHandle() throws Exception { if (log.isDebugEnabled()) log.debug("getting connection handle from " + this); int oldState = getState(); // Increment the usage count usageCount++; // Only transition to STATE_ACCESSIBLE on the first usage. If we're not sharing // connections (default behavior) usageCount is always 1 here, so this transition // will always occur (current behavior unchanged). If we _are_ sharing connections, // and this is _not_ the first usage, it is valid for the state to already be // STATE_ACCESSIBLE. Calling setState() with STATE_ACCESSIBLE when the state is // already STATE_ACCESSIBLE fails the sanity check in AbstractXAStatefulHolder. // Even if the connection is shared (usageCount > 1), if the state was STATE_NOT_ACCESSIBLE // we transition back to STATE_ACCESSIBLE. if (usageCount == 1 || oldState == STATE_NOT_ACCESSIBLE) { setState(STATE_ACCESSIBLE); } if (oldState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("connection " + xaConnection + " was in state IN_POOL, testing it"); testConnection(connection); applyIsolationLevel(); applyCursorHoldabilty(); if (TransactionContextHelper.currentTransaction() == null) { // it is safe to set the auto-commit flag outside of a global transaction applyLocalAutoCommit(); } } else { if (log.isDebugEnabled()) log.debug("connection " + xaConnection + " was in state " + Decoder.decodeXAStatefulHolderState(oldState) + ", no need to test it"); } if (log.isDebugEnabled()) log.debug("got connection handle from " + this); return new JdbcConnectionHandle(this, connection); } public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == STATE_IN_POOL) { if (log.isDebugEnabled()) log.debug("requeued JDBC connection of " + poolingDataSource); lastReleaseDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_IN_POOL && newState == STATE_ACCESSIBLE) { acquisitionDate = new Date(MonotonicClock.currentTimeMillis()); } if (oldState == STATE_NOT_ACCESSIBLE && newState == STATE_ACCESSIBLE) { TransactionContextHelper.recycle(this); } } public void stateChanging(XAStatefulHolder source, int currentState, int futureState) { if (futureState == STATE_IN_POOL) { if (usageCount > 0) { log.warn("usage count too high (" + usageCount + ") on connection returned to pool " + source); } } if (futureState == STATE_IN_POOL || futureState == STATE_NOT_ACCESSIBLE) { // close all uncached statements if (log.isDebugEnabled()) log.debug("closing " + uncachedStatements.size() + " dangling uncached statement(s)"); for (Statement statement : uncachedStatements) { try { statement.close(); } catch (SQLException ex) { if (log.isDebugEnabled()) log.debug("error trying to close uncached statement " + statement, ex); } } uncachedStatements.clear(); // clear SQL warnings try { if (log.isDebugEnabled()) log.debug("clearing warnings of " + connection); connection.clearWarnings(); } catch (SQLException ex) { if (log.isDebugEnabled()) log.debug("error cleaning warnings of " + connection, ex); } } } /** * Get a PreparedStatement from cache. * @param stmt the key that has been used to cache the statement. * @return the cached statement corresponding to the key or null if no statement is cached under that key. */ protected JdbcPreparedStatementHandle getCachedStatement(JdbcPreparedStatementHandle stmt) { return statementsCache.get(stmt); } /** * Put a PreparedStatement in the cache. * @param stmt the statement to cache. * @return the cached statement. */ protected JdbcPreparedStatementHandle putCachedStatement(JdbcPreparedStatementHandle stmt) { return statementsCache.put(stmt); } /** * Register uncached statement so that it can be closed when the connection is put back in the pool. * * @param stmt the statement to register. * @return the registered statement. */ protected Statement registerUncachedStatement(Statement stmt) { uncachedStatements.add(stmt); return stmt; } protected void unregisterUncachedStatement(Statement stmt) { uncachedStatements.remove(stmt); } public String toString() { return "a JdbcPooledConnection from datasource " + poolingDataSource.getUniqueName() + " in state " + Decoder.decodeXAStatefulHolderState(getState()) + " with usage count " + usageCount + " wrapping " + xaConnection; } private void applyCursorHoldabilty() throws SQLException { String cursorHoldability = getPoolingDataSource().getCursorHoldability(); if (cursorHoldability != null) { int holdability = translateCursorHoldability(cursorHoldability); if (holdability < 0) { log.warn("invalid cursor holdability '" + cursorHoldability + "' configured, keeping the default cursor holdability."); } else { if (log.isDebugEnabled()) log.debug("setting connection's cursor holdability to " + cursorHoldability); connection.setHoldability(holdability); } } } private static int translateCursorHoldability(String cursorHoldability) { if ("CLOSE_CURSORS_AT_COMMIT".equals(cursorHoldability)) return ResultSet.CLOSE_CURSORS_AT_COMMIT; if ("HOLD_CURSORS_OVER_COMMIT".equals(cursorHoldability)) return ResultSet.HOLD_CURSORS_OVER_COMMIT; return -1; } private void applyLocalAutoCommit() throws SQLException { String localAutoCommit = getPoolingDataSource().getLocalAutoCommit(); if (localAutoCommit != null) { if (localAutoCommit.equalsIgnoreCase("true")) { if (log.isDebugEnabled()) log.debug("setting connection's auto commit to true"); connection.setAutoCommit(true); } else if (localAutoCommit.equalsIgnoreCase("false")) { if (log.isDebugEnabled()) log.debug("setting connection's auto commit to false"); connection.setAutoCommit(false); } else { log.warn("invalid auto commit '" + localAutoCommit + "' configured, keeping default auto commit"); } } } /* management */ public String getStateDescription() { return Decoder.decodeXAStatefulHolderState(getState()); } public Date getAcquisitionDate() { return acquisitionDate; } public Date getLastReleaseDate() { return lastReleaseDate; } public Collection getTransactionGtridsCurrentlyHoldingThis() { return getXAResourceHolderStateGtrids(); } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcPreparedStatementHandle.java0000644000175000017500000001610312147207062025776 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; /** * Caching {@link PreparedStatement} wrapper. *

* This class is a proxy handler for a PreparedStatement. It does not * implement the PreparedStatement interface or extend a class directly, * but you methods implemented here will override those of the * underlying delegate. Simply implement a method with the same * signature, and the local method will be called rather than the delegate. *

* * @author lorban, brettw */ public class JdbcPreparedStatementHandle extends BaseProxyHandlerClass { // implements PreparedStatement private PreparedStatement delegate; private boolean pretendClosed = false; // The 'parent' connection. Used to return the connection to the pool upon // close(). private JdbcPooledConnection parentConnection; // Brett Wooldridge: the following must be taken into account when caching a // prepared statement. Defaults are per JDBC-specification. // // All of these attributes must match a proposed statement before the // statement can be considered "the same" and delivered from the cache. private final String sql; private int resultSetType = ResultSet.TYPE_FORWARD_ONLY; private int resultSetConcurrency = ResultSet.CONCUR_READ_ONLY; private Integer resultSetHoldability; private Integer autoGeneratedKeys; private int[] columnIndexes; private String[] columnNames; /* * PreparedStatement Constructors */ public JdbcPreparedStatementHandle(String sql) { this.sql = sql; } public JdbcPreparedStatementHandle(String sql, int autoGeneratedKeys) { this.sql = sql; this.autoGeneratedKeys = new Integer(autoGeneratedKeys); } public JdbcPreparedStatementHandle(String sql, int resultSetType, int resultSetConcurrency) { this.sql = sql; this.resultSetType = resultSetType; this.resultSetConcurrency = resultSetConcurrency; } public JdbcPreparedStatementHandle(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) { this.sql = sql; this.resultSetType = resultSetType; this.resultSetConcurrency = resultSetConcurrency; this.resultSetHoldability = new Integer(resultSetHoldability); } public JdbcPreparedStatementHandle(String sql, int[] columnIndexes) { this.sql = sql; this.columnIndexes = new int[columnIndexes.length]; System.arraycopy(columnIndexes, 0, this.columnIndexes, 0, columnIndexes.length); } public JdbcPreparedStatementHandle(String sql, String[] columnNames) { this.sql = sql; this.columnNames = new String[columnNames.length]; System.arraycopy(columnNames, 0, this.columnNames, 0, columnNames.length); } /* java.sql.Wrapper implementation */ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(delegate.getClass()); } public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(delegate.getClass())) { return (T) delegate; } throw new SQLException(getClass().getName() + " is not a wrapper for interface " + iface.getName()); } /* Internal methods */ /** * Set the parent connection that created this statement. We need this to * return the PreparedStatement to the pool. * * @param pooledConnection the parent JdbcPooledConnection */ protected void setPooledConnection(JdbcPooledConnection pooledConnection) { this.parentConnection = pooledConnection; } protected JdbcPooledConnection getPooledConnection() { return parentConnection; } private PreparedStatement getDelegate() throws SQLException { if (pretendClosed) throw new SQLException("prepared statement closed"); return delegate; } protected PreparedStatement getDelegateUnchecked() { return delegate; } protected void setDelegate(PreparedStatement delegate) { this.delegate = delegate; } public Object getProxiedDelegate() throws Exception { return getDelegate(); } /* Overridden java.lang.Object methods */ /** * Overridden equals() that takes all PreparedStatement attributes into * account. */ public boolean equals(Object obj) { if (!(obj instanceof JdbcPreparedStatementHandle)) { return false; } JdbcPreparedStatementHandle otherStmt = (JdbcPreparedStatementHandle) obj; if (!sql.equals(otherStmt.sql)) { return false; } else if (resultSetType != otherStmt.resultSetType) { return false; } else if (resultSetConcurrency != otherStmt.resultSetConcurrency) { return false; } else if (!Arrays.equals(columnIndexes, otherStmt.columnIndexes)) { return false; } else if (!Arrays.equals(columnNames, otherStmt.columnNames)) { return false; } else if ((autoGeneratedKeys == null && otherStmt.autoGeneratedKeys != null) || (autoGeneratedKeys != null && !autoGeneratedKeys.equals(otherStmt.autoGeneratedKeys))) { return false; } else if ((resultSetHoldability == null && otherStmt.resultSetHoldability != null) || (resultSetHoldability != null && !resultSetHoldability.equals(otherStmt.resultSetHoldability))) { return false; } return true; } public int hashCode() { return sql != null ? sql.hashCode() : System.identityHashCode(this); } public String toString() { return "a JdbcPreparedStatementHandle with sql=[" + sql + "]"; } /* Overridden methods of java.sql.PreparedStatement */ public void close() throws SQLException { if (!pretendClosed) { // Clear the parameters so the next use of this cached statement // doesn't pick up unexpected values. delegate.clearParameters(); // Return to cache so the usage count can be updated parentConnection.putCachedStatement(this); } pretendClosed = true; } public boolean isClosed() throws SQLException { return pretendClosed; } } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/BaseProxyHandlerClass.java0000644000175000017500000001171112147207062024650 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** * Base class for Proxy InvocationHandlers. Maintains a method cache * for swift delegation to either the overridden methods (implemented * in a sub-class of this class) or the underlying delegate class' * methods. Makes proxying an interface almost completely painless. *

* * @author brettw */ public abstract class BaseProxyHandlerClass implements InvocationHandler { private static final ConcurrentMap> classMethodCache = new ConcurrentHashMap>(); private final ConcurrentMap methodCache; public BaseProxyHandlerClass() { ConcurrentMap methodCache = classMethodCache.get(this.getClass()); if (methodCache == null) { methodCache = new ConcurrentHashMap(); ConcurrentMap previous = classMethodCache.putIfAbsent(this.getClass(), methodCache); if (previous != null) methodCache = previous; } this.methodCache = methodCache; } /** * Implementation of the InvocationHandler interface. * * @see java.lang.reflect.InvocationHandler */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { // If the method is directly overridden by "this" (i.e. sub-class) // class call "this" class' Method with "this" object, otherwise // call the non-overridden Method with the proxied object Method delegatedMethod = getDelegatedMethod(method); return delegatedMethod.invoke(isOurMethod(delegatedMethod) ? this : getProxiedDelegate(), args); } catch (InvocationTargetException ite) { // the InvocationTargetException's target actually is the exception thrown by the delegate // throw this one to avoid the caller to receive proxy-related exceptions throw ite.getTargetException(); } } /** * Get the overridden Method for the super-class of this base class, if it * exists. Otherwise, the method provided is not overridden by us and should * go to the underlying proxied class. *

* This method will return the original Method that was passed in, or if * the method is overridden by us it will return the Method from "this" * class. Where "this" is actually the sub-class of this class. * * @param method the Method object to map * @return the Method object that should be invoked, either ours * (overridden) or the underlying proxied object */ private Method getDelegatedMethod(Method method) { Method delegated = methodCache.get(method); if (delegated != null) { return delegated; } try { Class[] parameterTypes = method.getParameterTypes(); delegated = this.getClass().getMethod(method.getName(), parameterTypes); } catch (Exception ex) { delegated = method; } Method previous = methodCache.putIfAbsent(method, delegated); if (previous != null) { delegated = previous; } return delegated; } /** * Check whether the specified Method is overridden by us or not. * * @param method the Method object to check * @return true if the Method is ours, false if it belongs to the proxied * Class */ private boolean isOurMethod(Method method) { return this.getClass().equals(method.getDeclaringClass()); } /** * Must be implemented by the sub-class of this class. This method * should return the "true" object to be delegated to in the case * that the method is not overridden by the sub-class. * * @return the true delegate object * @throws Exception can throw any exception if desired */ public abstract Object getProxiedDelegate() throws Exception; } btm-dist-2.1.4/src/bitronix/tm/resource/jdbc/JdbcCallableStatementHandle.java0000644000175000017500000000514612147207062025740 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.jdbc; import java.sql.CallableStatement; import java.sql.SQLException; import java.sql.Statement; /** * CallableStatement {@link Statement} wrapper. *

* This class is a proxy handler for a CallableStatement. It does not * implement the CallableStatement interface or extend a class directly, * but you methods implemented here will override those of the * underlying delegate. Simply implement a method with the same * signature, and the local method will be called rather than the delegate. *

* * @author brettw */ public class JdbcCallableStatementHandle extends BaseProxyHandlerClass { // implements CallableStatement // The 'parent' connection. Used to remove this statement delegate // from the un-closed statements list when close() is called. private final JdbcPooledConnection parentConnection; private final CallableStatement delegate; public JdbcCallableStatementHandle(CallableStatement delegate, JdbcPooledConnection pooledConnection) { this.delegate = delegate; this.parentConnection = pooledConnection; } public Object getProxiedDelegate() throws Exception { return delegate; } /* java.sql.Wrapper implementation */ public boolean isWrapperFor(Class iface) throws SQLException { return iface.isAssignableFrom(delegate.getClass()); } public T unwrap(Class iface) throws SQLException { if (iface.isAssignableFrom(delegate.getClass())) { return (T) delegate; } throw new SQLException(getClass().getName() + " is not a wrapper for interface " + iface.getName()); } /* Overridden methods of java.sql.PreparedStatement */ public void close() throws SQLException { parentConnection.unregisterUncachedStatement(delegate); delegate.close(); } } btm-dist-2.1.4/src/bitronix/tm/BitronixTransactionManager.java0000644000175000017500000005053712147207062023227 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.internal.BitronixSystemException; import bitronix.tm.internal.ThreadContext; import bitronix.tm.internal.XAResourceManager; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.InitializationException; import bitronix.tm.utils.MonotonicClock; import bitronix.tm.utils.Scheduler; import bitronix.tm.utils.Service; import bitronix.tm.utils.Uid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; import javax.naming.NamingException; import javax.naming.Reference; import javax.naming.Referenceable; import javax.naming.StringRefAddr; import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicRollbackException; import javax.transaction.InvalidTransactionException; import javax.transaction.NotSupportedException; import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.Synchronization; import javax.transaction.SystemException; import javax.transaction.Transaction; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; import javax.transaction.xa.XAException; import java.io.IOException; import java.util.Date; import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * Implementation of {@link TransactionManager} and {@link UserTransaction}. * * @author lorban */ public class BitronixTransactionManager implements TransactionManager, UserTransaction, Referenceable, Service { private final static Logger log = LoggerFactory.getLogger(BitronixTransactionManager.class); private final static String MDC_GTRID_KEY = "btm-gtrid"; private final Map contexts = new ConcurrentHashMap(128, 0.75f, 128); private final Map inFlightTransactions = new ConcurrentHashMap(128, 0.75f, 128); private volatile boolean shuttingDown; /** * Create the {@link BitronixTransactionManager}. Open the journal, load resources and perform recovery * synchronously. The recovery service then gets scheduled for background recovery. */ public BitronixTransactionManager() { try { shuttingDown = false; logVersion(); Configuration configuration = TransactionManagerServices.getConfiguration(); configuration.buildServerIdArray(); // first call will initialize the ServerId if (log.isDebugEnabled()) log.debug("starting BitronixTransactionManager using " + configuration); TransactionManagerServices.getJournal().open(); TransactionManagerServices.getResourceLoader().init(); TransactionManagerServices.getRecoverer().run(); int backgroundRecoveryInterval = TransactionManagerServices.getConfiguration().getBackgroundRecoveryIntervalSeconds(); if (backgroundRecoveryInterval < 1) { throw new InitializationException("invalid configuration value for backgroundRecoveryIntervalSeconds, found '" + backgroundRecoveryInterval + "' but it must be greater than 0"); } if (log.isDebugEnabled()) log.debug("recovery will run in the background every " + backgroundRecoveryInterval + " second(s)"); Date nextExecutionDate = new Date(MonotonicClock.currentTimeMillis() + (backgroundRecoveryInterval * 1000L)); TransactionManagerServices.getTaskScheduler().scheduleRecovery(TransactionManagerServices.getRecoverer(), nextExecutionDate); } catch (IOException ex) { throw new InitializationException("cannot open disk journal", ex); } catch (Exception ex) { TransactionManagerServices.getJournal().shutdown(); TransactionManagerServices.getResourceLoader().shutdown(); throw new InitializationException("initialization failed, cannot safely start the transaction manager", ex); } } /** * Start a new transaction and bind the context to the calling thread. * @throws NotSupportedException if a transaction is already bound to the calling thread. * @throws SystemException if the transaction manager is shutting down. */ public void begin() throws NotSupportedException, SystemException { if (log.isDebugEnabled()) log.debug("beginning a new transaction"); if (isShuttingDown()) throw new BitronixSystemException("cannot start a new transaction, transaction manager is shutting down"); dumpTransactionContexts(); BitronixTransaction currentTx = getCurrentTransaction(); if (currentTx != null) throw new NotSupportedException("nested transactions not supported"); currentTx = createTransaction(); ClearContextSynchronization clearContextSynchronization = new ClearContextSynchronization(currentTx); try { currentTx.getSynchronizationScheduler().add(clearContextSynchronization, Scheduler.ALWAYS_LAST_POSITION -1); currentTx.setActive(getOrCreateCurrentContext().getTimeout()); if (log.isDebugEnabled()) log.debug("begun new transaction at " + new Date(currentTx.getResourceManager().getGtrid().extractTimestamp())); } catch (RuntimeException ex) { clearContextSynchronization.afterCompletion(Status.STATUS_NO_TRANSACTION); throw ex; } catch (SystemException ex) { clearContextSynchronization.afterCompletion(Status.STATUS_NO_TRANSACTION); throw ex; } } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { BitronixTransaction currentTx = getCurrentTransaction(); if (log.isDebugEnabled()) log.debug("committing transaction " + currentTx); if (currentTx == null) throw new IllegalStateException("no transaction started on this thread"); currentTx.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { BitronixTransaction currentTx = getCurrentTransaction(); if (log.isDebugEnabled()) log.debug("rolling back transaction " + currentTx); if (currentTx == null) throw new IllegalStateException("no transaction started on this thread"); currentTx.rollback(); } public int getStatus() throws SystemException { BitronixTransaction currentTx = getCurrentTransaction(); if (currentTx == null) return Status.STATUS_NO_TRANSACTION; return currentTx.getStatus(); } public Transaction getTransaction() throws SystemException { return getCurrentTransaction(); } public void setRollbackOnly() throws IllegalStateException, SystemException { BitronixTransaction currentTx = getCurrentTransaction(); if (log.isDebugEnabled()) log.debug("marking transaction as rollback only: " + currentTx); if (currentTx == null) throw new IllegalStateException("no transaction started on this thread"); currentTx.setRollbackOnly(); } public void setTransactionTimeout(int seconds) throws SystemException { if (seconds < 0) throw new BitronixSystemException("cannot set a timeout to less than 0 second (was: " + seconds + "s)"); getOrCreateCurrentContext().setTimeout(seconds); } public Transaction suspend() throws SystemException { BitronixTransaction currentTx = getCurrentTransaction(); if (log.isDebugEnabled()) log.debug("suspending transaction " + currentTx); if (currentTx == null) return null; try { currentTx.getResourceManager().suspend(); clearCurrentContextForSuspension(); return currentTx; } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); throw new BitronixSystemException("cannot suspend " + currentTx + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } public void resume(Transaction transaction) throws InvalidTransactionException, IllegalStateException, SystemException { if (log.isDebugEnabled()) log.debug("resuming " + transaction); if (transaction == null) throw new InvalidTransactionException("resumed transaction cannot be null"); if (!(transaction instanceof BitronixTransaction)) throw new InvalidTransactionException("resumed transaction must be an instance of BitronixTransaction"); BitronixTransaction tx = (BitronixTransaction) transaction; BitronixTransaction currentTx = getCurrentTransaction(); if (currentTx != null) throw new IllegalStateException("a transaction is already running on this thread"); try { XAResourceManager resourceManager = tx.getResourceManager(); resourceManager.resume(); ThreadContext ctx = new ThreadContext(); ctx.setTransaction(tx); setCurrentContext(ctx); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); throw new BitronixSystemException("cannot resume " + tx + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } /** * BitronixTransactionManager can only have a single instance per JVM so this method always returns a reference * with no special information to find back the sole instance. BitronixTransactionManagerObjectFactory will be used * by the JNDI server to get the BitronixTransactionManager instance of the JVM. * * @return an empty reference to get the BitronixTransactionManager. */ public Reference getReference() throws NamingException { return new Reference( BitronixTransactionManager.class.getName(), new StringRefAddr("TransactionManager", "BitronixTransactionManager"), BitronixTransactionManagerObjectFactory.class.getName(), null ); } /** * Return all in-flight transactions. * @return a map of {@link BitronixTransaction} objects using {@link Uid} as key and {@link BitronixTransaction} as value. */ public Map getInFlightTransactions() { return inFlightTransactions; } /** * Return the timestamp of the oldest in-flight transaction. * @return the timestamp or Long.MIN_VALUE if there is no in-flight transaction. */ public long getOldestInFlightTransactionTimestamp() { if (inFlightTransactions.isEmpty()) { if (log.isDebugEnabled()) log.debug("oldest in-flight transaction's timestamp: " + Long.MIN_VALUE); return Long.MIN_VALUE; } long oldestTimestamp = Long.MAX_VALUE; for (Map.Entry entry : inFlightTransactions.entrySet()) { Uid gtrid = entry.getKey(); long currentTimestamp = gtrid.extractTimestamp(); if (currentTimestamp < oldestTimestamp) oldestTimestamp = currentTimestamp; } if (log.isDebugEnabled()) log.debug("oldest in-flight transaction's timestamp: " + oldestTimestamp); return oldestTimestamp; } /** * Get the transaction currently registered on the current thread context. * @return the current transaction or null if no transaction has been started on the current thread. */ public BitronixTransaction getCurrentTransaction() { if (contexts.get(Thread.currentThread()) == null) return null; return getOrCreateCurrentContext().getTransaction(); } /** * Check if the transaction manager is in the process of shutting down. * @return true if the transaction manager is in the process of shutting down. */ private boolean isShuttingDown() { return shuttingDown; } /** * Dump an overview of all running transactions as debug logs. */ public void dumpTransactionContexts() { if (log.isDebugEnabled()) { if (log.isDebugEnabled()) log.debug("dumping " + inFlightTransactions.size() + " transaction context(s)"); for (Map.Entry entry : inFlightTransactions.entrySet()) { BitronixTransaction tx = entry.getValue(); if (log.isDebugEnabled()) log.debug(tx.toString()); } } // if } /** * Shut down the transaction manager and release all resources held by it. *

This call will also close the resources pools registered by the {@link bitronix.tm.resource.ResourceLoader} * like JMS and JDBC pools. The manually created ones are left untouched.

*

The Transaction Manager will wait during a configurable graceful period before forcibly killing active * transactions.

* After this method is called, attempts to create new transactions (via calls to * {@link javax.transaction.TransactionManager#begin()}) will be rejected with a {@link SystemException}.

* @see Configuration#getGracefulShutdownInterval() */ public synchronized void shutdown() { if (isShuttingDown()) { if (log.isDebugEnabled()) log.debug("Transaction Manager has already shut down"); return; } log.info("shutting down Bitronix Transaction Manager"); internalShutdown(); if (log.isDebugEnabled()) log.debug("shutting down resource loader"); TransactionManagerServices.getResourceLoader().shutdown(); if (log.isDebugEnabled()) log.debug("shutting down executor"); TransactionManagerServices.getExecutor().shutdown(); if (log.isDebugEnabled()) log.debug("shutting down task scheduler"); TransactionManagerServices.getTaskScheduler().shutdown(); if (log.isDebugEnabled()) log.debug("shutting down journal"); TransactionManagerServices.getJournal().shutdown(); if (log.isDebugEnabled()) log.debug("shutting down recoverer"); TransactionManagerServices.getRecoverer().shutdown(); if (log.isDebugEnabled()) log.debug("shutting down configuration"); TransactionManagerServices.getConfiguration().shutdown(); // clear references TransactionManagerServices.clear(); if (log.isDebugEnabled()) log.debug("shutdown ran successfully"); } private void internalShutdown() { shuttingDown = true; dumpTransactionContexts(); int seconds = TransactionManagerServices.getConfiguration().getGracefulShutdownInterval(); int txCount = 0; try { txCount = inFlightTransactions.size(); while (seconds > 0 && txCount > 0) { if (log.isDebugEnabled()) log.debug("still " + txCount + " in-flight transactions, waiting... (" + seconds + " second(s) left)"); try { Thread.sleep(1000); } catch (InterruptedException ex) { // ignore } seconds--; txCount = inFlightTransactions.size(); } } catch (Exception ex) { log.error("cannot get a list of in-flight transactions", ex); } if (txCount > 0) { if (log.isDebugEnabled()) log.debug("still " + txCount + " in-flight transactions, shutting down anyway"); dumpTransactionContexts(); } else { if (log.isDebugEnabled()) log.debug("all transactions finished, resuming shutdown"); } } public String toString() { return "a BitronixTransactionManager with " + inFlightTransactions.size() + " in-flight transaction(s)"; } /* * Internal impl */ /** * Output BTM version information as INFO log. */ private void logVersion() { log.info("Bitronix Transaction Manager version " + Version.getVersion()); if (log.isDebugEnabled()) log.debug("JVM version " + System.getProperty("java.version")); } /** * Create a new transaction on the current thread's context. * @return the created transaction. */ private BitronixTransaction createTransaction() { BitronixTransaction transaction = new BitronixTransaction(); getOrCreateCurrentContext().setTransaction(transaction); inFlightTransactions.put(transaction.getResourceManager().getGtrid(), transaction); MDC.put(MDC_GTRID_KEY, transaction.getGtrid()); return transaction; } /** * Unlink the transaction from the current thread's context. */ private void clearCurrentContextForSuspension() { if (log.isDebugEnabled()) log.debug("clearing current thread context: " + getOrCreateCurrentContext()); contexts.remove(Thread.currentThread()); if (log.isDebugEnabled()) log.debug("cleared current thread context: " + getOrCreateCurrentContext()); MDC.remove(MDC_GTRID_KEY); } /** * Bind a new context on the current thread. * @param context the context to bind. */ private void setCurrentContext(ThreadContext context) { if (log.isDebugEnabled()) log.debug("changing current thread context to " + context); if (context == null) throw new IllegalArgumentException("setCurrentContext() should not be called with a null context, clearCurrentContextForSuspension() should be used instead"); contexts.put(Thread.currentThread(), context); if (context.getTransaction() != null) { MDC.put(MDC_GTRID_KEY, context.getTransaction().getGtrid()); } } /** * Get the context attached to the current thread. If there is no current context, return null. * @return the context. */ ThreadContext currentThreadContext() { return contexts.get(Thread.currentThread()); } /** * Get the context attached to the current thread. If there is no current context, a new one is created. * @return the context. */ private ThreadContext getOrCreateCurrentContext() { ThreadContext threadContext = contexts.get(Thread.currentThread()); if (threadContext == null) { if (log.isDebugEnabled()) log.debug("creating new thread context"); threadContext = new ThreadContext(); setCurrentContext(threadContext); } return threadContext; } private class ClearContextSynchronization implements Synchronization { private final BitronixTransaction currentTx; public ClearContextSynchronization(BitronixTransaction currentTx) { this.currentTx = currentTx; } public void beforeCompletion() { } public void afterCompletion(int status) { Iterator> it = contexts.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = it.next(); ThreadContext context = entry.getValue(); if (context.getTransaction() == currentTx) { if (log.isDebugEnabled()) log.debug("clearing thread context: " + context); it.remove(); break; } } inFlightTransactions.remove(currentTx.getResourceManager().getGtrid()); MDC.remove(MDC_GTRID_KEY); } public String toString() { return "a ClearContextSynchronization for " + currentTx; } } } btm-dist-2.1.4/doc/0000777000175000017500000000000012215446662012566 5ustar tonytonybtm-dist-2.1.4/doc/bitronix.html0000644000175000017500000000025112147207062015275 0ustar tonytony redirecting to API javadoc ... btm-dist-2.1.4/doc/api/0000777000175000017500000000000012215446662013337 5ustar tonytonybtm-dist-2.1.4/doc/api/package-list0000644000175000017500000000057012215446622015620 0ustar tonytonybitronix.tm bitronix.tm.gui bitronix.tm.internal bitronix.tm.jndi bitronix.tm.journal bitronix.tm.recovery bitronix.tm.resource bitronix.tm.resource.common bitronix.tm.resource.ehcache bitronix.tm.resource.jdbc bitronix.tm.resource.jdbc.lrc bitronix.tm.resource.jms bitronix.tm.resource.jms.lrc bitronix.tm.timer bitronix.tm.twopc bitronix.tm.twopc.executor bitronix.tm.utils btm-dist-2.1.4/doc/api/resources/0000755000175000017500000000000012215446622015341 5ustar tonytonybtm-dist-2.1.4/doc/api/resources/inherit.gif0000644000175000017500000000007112215446622017470 0ustar tonytonyGIF89a€ÿÿÿ,„ ¡½®DršjñÔ;߀Q@–¦…N;btm-dist-2.1.4/doc/api/allclasses-noframe.html0000644000175000017500000004260212215446622017774 0ustar tonytony All Classes (Bitronix Transaction Manager :: Core 2.1.4 API) All Classes
AbstractPhaseEngine
AbstractXAResourceHolder
AbstractXAStatefulHolder
AsyncExecutor
BaseProxyHandlerClass
BitronixContext
BitronixHeuristicCommitException
BitronixHeuristicMixedException
BitronixHeuristicRollbackException
BitronixInitialContextFactory
BitronixMultiSystemException
BitronixRollbackException
BitronixRollbackSystemException
BitronixRuntimeException
BitronixSystemException
BitronixTransaction
BitronixTransactionManager
BitronixTransactionManagerObjectFactory
BitronixTransactionMBean
BitronixTransactionSynchronizationRegistry
BitronixTransactionSynchronizationRegistryObjectFactory
BitronixUserTransactionObjectFactory
BitronixXAException
BitronixXid
ClassLoaderUtils
CollectionUtils
Committer
Configuration
ConnectionCustomizer
Console
CorruptedTransactionLogException
CryptoEngine
DanglingTransaction
Decoder
DefaultExceptionAnalyzer
DeferredReleaseSynchronization
DiskForceBatcherThread
DiskForceWaitQueue
DiskJournal
DualSessionWrapper
DuplicatedGtridTableModel
EhCacheXAResourceHolder
EhCacheXAResourceProducer
Encoder
ExceptionAnalyzer
ExceptionUtils
Executor
IncrementalRecoverer
InitializationException
JdbcCallableStatementHandle
JdbcConnectionHandle
JdbcPooledConnection
JdbcPooledConnectionMBean
JdbcPreparedStatementHandle
JdbcResultSetHandle
JdbcStatementHandle
JdbcUncachedPreparedStatementHandle
JmsConnectionHandle
JmsPooledConnection
JmsPooledConnectionMBean
JndiXAConnectionFactory
Job
Journal
LrcConnectionHandle
LrcXAConnection
LrcXAConnection
LrcXAConnectionFactory
LrcXADataSource
LrcXAResource
LrcXAResource
LrcXASession
LruEvictionListener
LruStatementCache
ManagementRegistrar
MessageConsumerWrapper
MessageProducerConsumerKey
MessageProducerWrapper
MonotonicClock
NullJournal
PendingTransactionTableModel
PhaseException
PoolingConnectionFactory
PoolingConnectionFactoryMBean
PoolingDataSource
PoolingDataSourceMBean
PoolShrinkingTask
Preparer
PropertyException
PropertyUtils
RawTransactionTableModel
Recoverer
RecovererMBean
RecoveryException
RecoveryHelper
RecoveryTask
RecoveryXAResourceHolder
ResourceBean
ResourceConfigurationException
ResourceLoader
ResourceObjectFactory
ResourceRegistrar
ResourcesPanel
ResourcesTreeModel
Rollbacker
Scheduler
Service
StackTrace
StateChangeListener
SyncExecutor
Task
TaskException
TaskScheduler
ThreadContext
TopicSubscriberWrapper
TransactionContextHelper
TransactionLogAppender
TransactionLogCursor
TransactionLogDialog
TransactionLogHeader
TransactionLogHeaderPanel
TransactionLogRecord
TransactionManagerServices
TransactionStatusChangeListener
TransactionTableCellRenderer
TransactionTableModel
TransactionTableMouseListener
TransactionTimeoutTask
Uid
UidGenerator
Version
XAPool
XAResourceHolder
XAResourceHolderState
XAResourceManager
XAResourceProducer
XAStatefulHolder
btm-dist-2.1.4/doc/api/index-all.html0000644000175000017500000152754712215446622016117 0ustar tonytony Index (Bitronix Transaction Manager :: Core 2.1.4 API)
A B C D E F G H I J L M N O P R S T U V W X

A

AbstractPhaseEngine - Class in bitronix.tm.twopc
Abstract phase execution engine.
AbstractPhaseEngine(Executor) - Constructor for class bitronix.tm.twopc.AbstractPhaseEngine
 
AbstractXAResourceHolder - Class in bitronix.tm.resource.common
Implementation of all services required by a XAResourceHolder.
AbstractXAResourceHolder() - Constructor for class bitronix.tm.resource.common.AbstractXAResourceHolder
 
AbstractXAStatefulHolder - Class in bitronix.tm.resource.common
Implementation of all services required by a XAStatefulHolder.
AbstractXAStatefulHolder() - Constructor for class bitronix.tm.resource.common.AbstractXAStatefulHolder
 
acceptLog(TransactionLogRecord) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
acceptLog(TransactionLogRecord) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
acceptLog(TransactionLogRecord) - Method in class bitronix.tm.gui.TransactionTableModel
 
add(T, Integer) - Method in class bitronix.tm.utils.Scheduler
 
addConnectionCustomizer(ConnectionCustomizer) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
addConnectionEventListener(ConnectionEventListener) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
addEvictionListener(LruEvictionListener) - Method in class bitronix.tm.resource.jdbc.LruStatementCache
 
addStateChangeEventListener(StateChangeListener) - Method in class bitronix.tm.resource.common.AbstractXAStatefulHolder
 
addStateChangeEventListener(StateChangeListener) - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Register an implementation of StateChangeListener.
addTableModelListener(TableModelListener) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
addTableModelListener(TableModelListener) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
addToEnvironment(String, Object) - Method in class bitronix.tm.jndi.BitronixContext
 
addTransactionStatusChangeListener(TransactionStatusChangeListener) - Method in class bitronix.tm.BitronixTransaction
 
addTreeModelListener(TreeModelListener) - Method in class bitronix.tm.gui.ResourcesTreeModel
 
afterCompletion(int) - Method in class bitronix.tm.resource.common.DeferredReleaseSynchronization
 
ALWAYS_FIRST_POSITION - Static variable in class bitronix.tm.utils.Scheduler
 
ALWAYS_LAST_POSITION - Static variable in class bitronix.tm.utils.Scheduler
 
AsyncExecutor - Class in bitronix.tm.twopc.executor
This implementation executes submitted jobs using a java.util.concurrent cached thread pool.
AsyncExecutor() - Constructor for class bitronix.tm.twopc.executor.AsyncExecutor
 

B

BaseProxyHandlerClass - Class in bitronix.tm.resource.jdbc
Base class for Proxy InvocationHandlers.
BaseProxyHandlerClass() - Constructor for class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
 
beforeCompletion() - Method in class bitronix.tm.resource.common.DeferredReleaseSynchronization
 
begin() - Method in class bitronix.tm.BitronixTransactionManager
Start a new transaction and bind the context to the calling thread.
bind(Name, Object) - Method in class bitronix.tm.jndi.BitronixContext
 
bind(String, Object) - Method in class bitronix.tm.jndi.BitronixContext
 
bitronix.tm - package bitronix.tm
JTA interfaces implementations and global services.
bitronix.tm.gui - package bitronix.tm.gui
GUI admin console.
bitronix.tm.internal - package bitronix.tm.internal
Internal implementation details.
bitronix.tm.jndi - package bitronix.tm.jndi
JNDI provider implementation that allows looking up transaction manager and resources.
bitronix.tm.journal - package bitronix.tm.journal
Transactions disk journal.
bitronix.tm.recovery - package bitronix.tm.recovery
Recovery logic.
bitronix.tm.resource - package bitronix.tm.resource
Transaction Manager's resource management services.
bitronix.tm.resource.common - package bitronix.tm.resource.common
Resource management code common across all resource types.
bitronix.tm.resource.ehcache - package bitronix.tm.resource.ehcache
Ehcache specific resource management code.
bitronix.tm.resource.jdbc - package bitronix.tm.resource.jdbc
JDBC specific resource management code.
bitronix.tm.resource.jdbc.lrc - package bitronix.tm.resource.jdbc.lrc
XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource.
bitronix.tm.resource.jms - package bitronix.tm.resource.jms
Synchronous JMS specific resource management code.
bitronix.tm.resource.jms.lrc - package bitronix.tm.resource.jms.lrc
XAConnectionFactory emulator using Last Resource Commit on an underlying non-XA ConnectionFactory.
bitronix.tm.timer - package bitronix.tm.timer
Timed tasks scheduler.
bitronix.tm.twopc - package bitronix.tm.twopc
Two-phase commit logic.
bitronix.tm.twopc.executor - package bitronix.tm.twopc.executor
Two-phase commit commands executors.
bitronix.tm.utils - package bitronix.tm.utils
Misc utility classes.
BitronixContext - Class in bitronix.tm.jndi
Implementation of Context that allows lookup of transaction manager and registered resources.
BitronixContext() - Constructor for class bitronix.tm.jndi.BitronixContext
 
BitronixHeuristicCommitException - Exception in bitronix.tm.internal
Subclass of HeuristicCommitException supporting nested Throwables.
BitronixHeuristicCommitException(String) - Constructor for exception bitronix.tm.internal.BitronixHeuristicCommitException
 
BitronixHeuristicCommitException(String, Throwable) - Constructor for exception bitronix.tm.internal.BitronixHeuristicCommitException
 
BitronixHeuristicMixedException - Exception in bitronix.tm.internal
Subclass of HeuristicMixedException supporting nested Throwables.
BitronixHeuristicMixedException(String) - Constructor for exception bitronix.tm.internal.BitronixHeuristicMixedException
 
BitronixHeuristicMixedException(String, Throwable) - Constructor for exception bitronix.tm.internal.BitronixHeuristicMixedException
 
BitronixHeuristicRollbackException - Exception in bitronix.tm.internal
Subclass of HeuristicRollbackException supporting nested Throwables.
BitronixHeuristicRollbackException(String) - Constructor for exception bitronix.tm.internal.BitronixHeuristicRollbackException
 
BitronixHeuristicRollbackException(String, Throwable) - Constructor for exception bitronix.tm.internal.BitronixHeuristicRollbackException
 
BitronixInitialContextFactory - Class in bitronix.tm.jndi
Implementation of InitialContextFactory that allows lookup of transaction manager and registered resources.
BitronixInitialContextFactory() - Constructor for class bitronix.tm.jndi.BitronixInitialContextFactory
 
BitronixMultiSystemException - Exception in bitronix.tm.internal
Subclass of SystemException supporting nested Throwables.
BitronixMultiSystemException(String, List, List) - Constructor for exception bitronix.tm.internal.BitronixMultiSystemException
 
BitronixRollbackException - Exception in bitronix.tm.internal
Subclass of RollbackException supporting nested Throwables.
BitronixRollbackException(String) - Constructor for exception bitronix.tm.internal.BitronixRollbackException
 
BitronixRollbackException(String, Throwable) - Constructor for exception bitronix.tm.internal.BitronixRollbackException
 
BitronixRollbackSystemException - Exception in bitronix.tm.internal
Subclass of SystemException indicating a rollback must be performed.
BitronixRollbackSystemException(String, Throwable) - Constructor for exception bitronix.tm.internal.BitronixRollbackSystemException
 
BitronixRuntimeException - Exception in bitronix.tm.internal
Thrown when a runtime exception happens.
BitronixRuntimeException(String, Throwable) - Constructor for exception bitronix.tm.internal.BitronixRuntimeException
 
BitronixRuntimeException(String) - Constructor for exception bitronix.tm.internal.BitronixRuntimeException
 
BitronixSystemException - Exception in bitronix.tm.internal
Subclass of SystemException supporting nested Throwables.
BitronixSystemException(int) - Constructor for exception bitronix.tm.internal.BitronixSystemException
 
BitronixSystemException(String) - Constructor for exception bitronix.tm.internal.BitronixSystemException
 
BitronixSystemException(String, Throwable) - Constructor for exception bitronix.tm.internal.BitronixSystemException
 
BitronixTransaction - Class in bitronix.tm
Implementation of Transaction.
BitronixTransaction() - Constructor for class bitronix.tm.BitronixTransaction
 
BitronixTransactionManager - Class in bitronix.tm
Implementation of TransactionManager and UserTransaction.
BitronixTransactionManager() - Constructor for class bitronix.tm.BitronixTransactionManager
Create the BitronixTransactionManager.
BitronixTransactionManagerObjectFactory - Class in bitronix.tm
BitronixTransactionManager object factory for JNDI references.
BitronixTransactionManagerObjectFactory() - Constructor for class bitronix.tm.BitronixTransactionManagerObjectFactory
 
BitronixTransactionMBean - Interface in bitronix.tm
BitronixTransaction Management interface.
BitronixTransactionSynchronizationRegistry - Class in bitronix.tm
Implementation of JTA 1.1 TransactionSynchronizationRegistry.
BitronixTransactionSynchronizationRegistry() - Constructor for class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
BitronixTransactionSynchronizationRegistryObjectFactory - Class in bitronix.tm
BitronixTransactionSynchronizationRegistry object factory for JNDI references.
BitronixTransactionSynchronizationRegistryObjectFactory() - Constructor for class bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory
 
BitronixUserTransactionObjectFactory - Class in bitronix.tm
BitronixTransactionManager object factory for JNDI references.
BitronixUserTransactionObjectFactory() - Constructor for class bitronix.tm.BitronixUserTransactionObjectFactory
 
BitronixXAException - Exception in bitronix.tm.internal
Subclass of XAException supporting nested Throwables.
BitronixXAException(String, int) - Constructor for exception bitronix.tm.internal.BitronixXAException
 
BitronixXAException(String, int, Throwable) - Constructor for exception bitronix.tm.internal.BitronixXAException
 
BitronixXid - Class in bitronix.tm
Implementation of Xid.
BitronixXid(Uid, Uid) - Constructor for class bitronix.tm.BitronixXid
Create a new XID using the specified GTRID and BQUAL.
BitronixXid(Xid) - Constructor for class bitronix.tm.BitronixXid
 
buildServerIdArray() - Method in class bitronix.tm.Configuration
Build the server ID byte array that will be prepended in generated UIDs.
bytesToInt(byte[], int) - Static method in class bitronix.tm.utils.Encoder
 
bytesToLong(byte[], int) - Static method in class bitronix.tm.utils.Encoder
 

C

calculateCrc32() - Method in class bitronix.tm.journal.TransactionLogRecord
Calculate the CRC32 value of this record.
cancelPoolShrinking(XAPool) - Method in class bitronix.tm.timer.TaskScheduler
Cancel the task that will tell a XA pool to close idle connections.
cancelRecovery(Recoverer) - Method in class bitronix.tm.timer.TaskScheduler
Cancel the task that will run background recovery at the specified date.
cancelTransactionTimeout(BitronixTransaction) - Method in class bitronix.tm.timer.TaskScheduler
Cancel the task that will mark the transaction as timed out at the specified date.
ClassLoaderUtils - Class in bitronix.tm.utils
Static utility methods for loading classes and resources.
ClassLoaderUtils() - Constructor for class bitronix.tm.utils.ClassLoaderUtils
 
CLEAN_LOG_STATE - Static variable in class bitronix.tm.journal.TransactionLogHeader
State of the log file when it has been closed properly.
clear() - Method in class bitronix.tm.journal.DiskForceWaitQueue
 
clear() - Method in class bitronix.tm.resource.jdbc.LruStatementCache
Evict all statements from the cache.
clear() - Static method in class bitronix.tm.TransactionManagerServices
Clear services references.
clearXAResourceHolderStates() - Method in class bitronix.tm.internal.XAResourceManager
Remove this transaction's XAResourceHolderState from all enlisted XAResourceHolders.
close() - Method in class bitronix.tm.jndi.BitronixContext
 
close() - Method in class bitronix.tm.journal.DiskJournal
Close the disk journal and the underlying files.
close() - Method in interface bitronix.tm.journal.Journal
Close this journal and release all underlying resources.
close() - Method in class bitronix.tm.journal.NullJournal
 
close() - Method in class bitronix.tm.journal.TransactionLogAppender
Close the appender and the underlying file.
close() - Method in class bitronix.tm.journal.TransactionLogCursor
Close the cursor and the underlying file
close() - Method in class bitronix.tm.resource.common.RecoveryXAResourceHolder
 
close() - Method in class bitronix.tm.resource.common.XAPool
 
close() - Method in interface bitronix.tm.resource.common.XAResourceProducer
Release this XAResourceProducer's internal resources.
close() - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Close the physical connection that this XAStatefulHolder represents.
close() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
Close the physical connection that this XAStatefulHolder represents.
close() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Release this XAResourceProducer's internal resources.
close() - Method in class bitronix.tm.resource.jdbc.JdbcCallableStatementHandle
 
close() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
close() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
close() - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
close() - Method in class bitronix.tm.resource.jdbc.JdbcResultSetHandle
 
close() - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
close() - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
close() - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
close() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
close() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
close() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
close() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
close() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
close() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
close() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
close() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
close() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
close() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
collectDanglingRecords() - Method in class bitronix.tm.journal.DiskJournal
Collect all dangling records of the active log file.
collectDanglingRecords() - Method in interface bitronix.tm.journal.Journal
Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record.
collectDanglingRecords() - Method in class bitronix.tm.journal.NullJournal
 
CollectionUtils - Class in bitronix.tm.utils
Collection helper functions.
CollectionUtils() - Constructor for class bitronix.tm.utils.CollectionUtils
 
collectNotInterestedResources(List<XAResourceHolderState>, List<XAResourceHolderState>) - Static method in class bitronix.tm.twopc.AbstractPhaseEngine
 
collectResourcesNames(Collection<XAResourceHolderState>) - Static method in class bitronix.tm.utils.Decoder
Create a String representation of a list of XAResourceHolders.
collectResourcesUniqueNames(List<XAResourceHolderState>) - Static method in class bitronix.tm.twopc.AbstractPhaseEngine
 
collectUniqueNames() - Method in class bitronix.tm.internal.XAResourceManager
Get a Set of unique names of all the enlisted XAResourceHolderStates.
commit() - Method in class bitronix.tm.BitronixTransaction
 
commit() - Method in class bitronix.tm.BitronixTransactionManager
 
commit(XAResourceHolderState, Xid) - Static method in class bitronix.tm.recovery.RecoveryHelper
Commit the specified branch of a dangling transaction.
commit() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
commit() - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
commit(Xid, boolean) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
commit() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
commit(Xid, boolean) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
commit() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
commit(BitronixTransaction, List<XAResourceHolderState>) - Method in class bitronix.tm.twopc.Committer
Execute phase 2 commit.
Committer - Class in bitronix.tm.twopc
Phase 2 Commit logic engine.
Committer(Executor) - Constructor for class bitronix.tm.twopc.Committer
 
compareTo(Task) - Method in class bitronix.tm.timer.Task
 
composeName(Name, Name) - Method in class bitronix.tm.jndi.BitronixContext
 
composeName(String, String) - Method in class bitronix.tm.jndi.BitronixContext
 
Configuration - Class in bitronix.tm
Configuration repository of the transaction manager.
Configuration() - Constructor for class bitronix.tm.Configuration
 
ConnectionCustomizer - Interface in bitronix.tm.resource.jdbc
Listener of connections created by a PoolingDataSource.
Console - Class in bitronix.tm.gui
Console() - Constructor for class bitronix.tm.gui.Console
 
containsByIdentity(Collection<?>, Object) - Static method in class bitronix.tm.utils.CollectionUtils
Check if a collection contains a specific object by searching for it by identity instead of by using equals/hashcode.
CorruptedTransactionLogException - Exception in bitronix.tm.journal
Thrown by TransactionLogCursor when an integrity check fails upon reading a record.
CorruptedTransactionLogException(String) - Constructor for exception bitronix.tm.journal.CorruptedTransactionLogException
 
countTasksQueued() - Method in class bitronix.tm.timer.TaskScheduler
Get the amount of tasks currently queued.
createBrowser(Queue) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createBrowser(Queue, String) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createBrowser(Queue) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createBrowser(Queue, String) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createBytesMessage() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createBytesMessage() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createConnection() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
createConnection(String, String) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
createConnectionConsumer(Destination, String, ServerSessionPool, int) - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
createConnectionConsumer(Destination, String, ServerSessionPool, int) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
createConsumer(Destination) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createConsumer(Destination, String) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createConsumer(Destination, String, boolean) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createConsumer(Destination) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createConsumer(Destination, String) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createConsumer(Destination, String, boolean) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createDurableConnectionConsumer(Topic, String, String, ServerSessionPool, int) - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
createDurableConnectionConsumer(Topic, String, String, ServerSessionPool, int) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
createDurableSubscriber(Topic, String) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createDurableSubscriber(Topic, String, String, boolean) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createDurableSubscriber(Topic, String) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createDurableSubscriber(Topic, String, String, boolean) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createJob(XAResourceHolderState) - Method in class bitronix.tm.twopc.AbstractPhaseEngine
Create a Job that is going to execute the phase command on the given resource.
createJob(XAResourceHolderState) - Method in class bitronix.tm.twopc.Committer
 
createJob(XAResourceHolderState) - Method in class bitronix.tm.twopc.Preparer
 
createJob(XAResourceHolderState) - Method in class bitronix.tm.twopc.Rollbacker
 
createMapMessage() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createMapMessage() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createMessage() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createMessage() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createObjectMessage() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createObjectMessage(Serializable) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createObjectMessage() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createObjectMessage(Serializable) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createPooledConnection(Object, ResourceBean) - Method in interface bitronix.tm.resource.common.XAResourceProducer
Create a XAStatefulHolder that will be placed in an XAPool.
createPooledConnection(Object, ResourceBean) - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Create a XAStatefulHolder that will be placed in an XAPool.
createPooledConnection(Object, ResourceBean) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
createPooledConnection(Object, ResourceBean) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
createProducer(Destination) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createProducer(Destination) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createQueue(String) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createQueue(String) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createRecoveryXAResourceHolder() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
createRecoveryXAResourceHolder() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
createSession(boolean, int) - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
createSession(boolean, int) - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
createSession(boolean, int) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
createStatement() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
createStatement(int, int) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
createStatement(int, int, int) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
createStreamMessage() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createStreamMessage() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createSubcontext(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
createSubcontext(String) - Method in class bitronix.tm.jndi.BitronixContext
 
createTemporaryQueue() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createTemporaryQueue() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createTemporaryTopic() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createTemporaryTopic() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createTextMessage() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createTextMessage(String) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createTextMessage() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createTextMessage(String) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createTopic(String) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
createTopic(String) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
createXAConnection() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
 
createXAConnection(String, String) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
 
createXAConnection() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
createXAConnection(String, String) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
createXASession() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
crypt(String, String) - Static method in class bitronix.tm.utils.CryptoEngine
Crypt the given data using the given cipher.
CryptoEngine - Class in bitronix.tm.utils
Simple crypto helper that uses symetric keys to crypt and decrypt resources passwords.
CryptoEngine() - Constructor for class bitronix.tm.utils.CryptoEngine
 
CURRENT_POSITION_HEADER - Static variable in class bitronix.tm.journal.TransactionLogHeader
Position of the current log position in the header.
currentTimeMillis() - Static method in class bitronix.tm.utils.MonotonicClock
Return the current time in milliseconds, guaranteeing monotonic time increment.
currentTransaction() - Static method in class bitronix.tm.resource.common.TransactionContextHelper
Get the transaction running on the current thead context.

D

DanglingTransaction - Class in bitronix.tm.recovery
Simple bean containing a unique resource name paired with a XID corresponding to a branch on that resource.
DanglingTransaction(String, Xid) - Constructor for class bitronix.tm.recovery.DanglingTransaction
 
dateFormatter - Static variable in class bitronix.tm.gui.Console
 
decodeHeaderState(byte) - Static method in class bitronix.tm.utils.Decoder
 
decodePrepareVote(int) - Static method in class bitronix.tm.utils.Decoder
 
Decoder - Class in bitronix.tm.utils
Constant to string decoder.
Decoder() - Constructor for class bitronix.tm.utils.Decoder
 
decodeStatus(int) - Static method in class bitronix.tm.utils.Decoder
 
decodeXAExceptionErrorCode(XAException) - Static method in class bitronix.tm.utils.Decoder
 
decodeXAResourceFlag(int) - Static method in class bitronix.tm.utils.Decoder
 
decodeXAStatefulHolderState(int) - Static method in class bitronix.tm.utils.Decoder
 
decrypt(String, String) - Static method in class bitronix.tm.utils.CryptoEngine
Decrypt using the given cipher the given base64-encoded, crypted data.
DEFAULT_POSITION - Static variable in class bitronix.tm.utils.Scheduler
 
DefaultExceptionAnalyzer - Class in bitronix.tm.utils
Default implementation of ExceptionAnalyzer.
DefaultExceptionAnalyzer() - Constructor for class bitronix.tm.utils.DefaultExceptionAnalyzer
 
DeferredReleaseSynchronization - Class in bitronix.tm.resource.common
Synchronization used to release a XAStatefulHolder object after 2PC has executed.
DeferredReleaseSynchronization(XAStatefulHolder) - Constructor for class bitronix.tm.resource.common.DeferredReleaseSynchronization
 
delist(XAResourceHolderState, int) - Method in class bitronix.tm.internal.XAResourceManager
Delist the specified XAResourceHolderState.
delistFromCurrentTransaction(XAResourceHolder) - Static method in class bitronix.tm.resource.common.TransactionContextHelper
Delist the XAResourceHolder from the current transaction or do nothing if there is no global transaction context for this thread.
delistResource(XAResource, int) - Method in class bitronix.tm.BitronixTransaction
 
destroySubcontext(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
destroySubcontext(String) - Method in class bitronix.tm.jndi.BitronixContext
 
DiskForceBatcherThread - Class in bitronix.tm.journal
Thread that executes disk force batches.
DiskForceWaitQueue - Class in bitronix.tm.journal
TransactionLogAppenders waiting for a disk force get enqueued here.
DiskForceWaitQueue() - Constructor for class bitronix.tm.journal.DiskForceWaitQueue
 
DiskJournal - Class in bitronix.tm.journal
Simple implementation of a journal that writes on a two-files disk log.
DiskJournal() - Constructor for class bitronix.tm.journal.DiskJournal
Create an uninitialized disk journal.
doForce() - Method in class bitronix.tm.journal.TransactionLogAppender
 
DualSessionWrapper - Class in bitronix.tm.resource.jms
JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
DualSessionWrapper(JmsPooledConnection, boolean, int) - Constructor for class bitronix.tm.resource.jms.DualSessionWrapper
 
dumpTransactionContexts() - Method in class bitronix.tm.BitronixTransactionManager
Dump an overview of all running transactions as debug logs.
DuplicatedGtridTableModel - Class in bitronix.tm.gui
DuplicatedGtridTableModel(Map) - Constructor for class bitronix.tm.gui.DuplicatedGtridTableModel
 

E

EhCacheXAResourceHolder - Class in bitronix.tm.resource.ehcache
Ehcache implementation of BTM's XAResourceHolder.
EhCacheXAResourceHolder(XAResource, ResourceBean) - Constructor for class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
Create a new EhCacheXAResourceHolder for a particular XAResource
EhCacheXAResourceProducer - Class in bitronix.tm.resource.ehcache
EHCache implementation of BTM's XAResourceProducer.
Encoder - Class in bitronix.tm.utils
Number to byte array and byte array to number encoder.
Encoder() - Constructor for class bitronix.tm.utils.Encoder
 
end(int) - Method in class bitronix.tm.internal.XAResourceHolderState
 
end(Xid, int) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
end(Xid, int) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
END_RECORD - Static variable in class bitronix.tm.journal.TransactionLogAppender
int-encoded "xntB" ASCII string.
ENDED - Static variable in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
ENDED - Static variable in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
endRecovery() - Method in interface bitronix.tm.resource.common.XAResourceProducer
Release internal resources held after call to startRecovery().
endRecovery() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Release internal resources held after call to startRecovery().
endRecovery() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
endRecovery() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
enlist(XAResourceHolderState) - Method in class bitronix.tm.internal.XAResourceManager
Enlist the specified XAResourceHolderState.
enlistInCurrentTransaction(XAResourceHolder) - Static method in class bitronix.tm.resource.common.TransactionContextHelper
Enlist the XAResourceHolder in the current transaction or do nothing if there is no global transaction context for this thread.
enlistResource(XAResource) - Method in class bitronix.tm.BitronixTransaction
 
enlistResource() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource.
enlistResource() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource.
enlistResource() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource.
enqueue(TransactionLogAppender) - Method in class bitronix.tm.journal.DiskForceBatcherThread
Add the TransactionLogAppender to the wait queue and wait until the disk force is done.
enqueue(TransactionLogAppender) - Method in class bitronix.tm.journal.DiskForceWaitQueue
 
equals(Object) - Method in class bitronix.tm.BitronixTransaction
 
equals(Object) - Method in class bitronix.tm.BitronixXid
Compare two XIDs for equality.
equals(Object) - Method in class bitronix.tm.internal.XAResourceHolderState
 
equals(Object) - Method in class bitronix.tm.recovery.DanglingTransaction
 
equals(Object) - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
Overridden equals() that takes all PreparedStatement attributes into account.
equals(Object) - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
equals(Object) - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
equals(Object) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
equals(Object) - Method in class bitronix.tm.resource.jms.MessageProducerConsumerKey
 
equals(Object) - Method in class bitronix.tm.utils.Uid
 
ExceptionAnalyzer - Interface in bitronix.tm.utils
Exception analyzers are used to extract non-standard information from vendor exceptions.
ExceptionUtils - Class in bitronix.tm.utils
Exception related utilities.
execute() - Method in class bitronix.tm.timer.PoolShrinkingTask
 
execute() - Method in class bitronix.tm.timer.RecoveryTask
 
execute() - Method in class bitronix.tm.timer.Task
 
execute() - Method in class bitronix.tm.timer.TransactionTimeoutTask
 
execute() - Method in class bitronix.tm.twopc.executor.Job
 
executePhase(XAResourceManager, boolean) - Method in class bitronix.tm.twopc.AbstractPhaseEngine
Execute the phase.
executeQuery(String) - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
executeQuery(String) - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
executeQuery() - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
Executor - Interface in bitronix.tm.twopc.executor
Thread pool interface required by the two-phase commit logic.
extractExtraXAExceptionDetails(XAException) - Method in class bitronix.tm.utils.DefaultExceptionAnalyzer
 
extractExtraXAExceptionDetails(XAException) - Method in interface bitronix.tm.utils.ExceptionAnalyzer
Extract information from a vendor's XAException that isn't available through standard APIs.
extractSequence() - Method in class bitronix.tm.utils.Uid
 
extractServerId() - Method in class bitronix.tm.utils.Uid
 
extractTimestamp() - Method in class bitronix.tm.utils.Uid
 

F

filterByGtrid(String) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
findXAResourceHolder(XAResource) - Method in class bitronix.tm.resource.common.XAPool
 
findXAResourceHolder(XAResource) - Method in interface bitronix.tm.resource.common.XAResourceProducer
Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
findXAResourceHolder(XAResource) - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
findXAResourceHolder(XAResource) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
findXAResourceHolder(XAResource) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
findXAResourceHolder(XAResource) - Static method in class bitronix.tm.resource.ResourceRegistrar
Find in the registered XAResourceProducers the XAResourceHolder from which the specified XAResource comes from.
findXAResourceHolderState(XAResource) - Method in class bitronix.tm.internal.XAResourceManager
Look if an XAResource has already been enlisted.
force() - Method in class bitronix.tm.journal.DiskJournal
Force active log file to synchronize with the underlying disk device.
force() - Method in interface bitronix.tm.journal.Journal
Force journal to synchronize with permanent storage.
force() - Method in class bitronix.tm.journal.NullJournal
 
force() - Method in class bitronix.tm.journal.TransactionLogAppender
Force flushing the logs to disk
forget(Xid) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
forget(Xid) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
FORMAT_ID - Static variable in class bitronix.tm.BitronixXid
int-encoded "Btnx" string.
FORMAT_ID_HEADER - Static variable in class bitronix.tm.journal.TransactionLogHeader
Position of the format ID in the header (see BitronixXid.FORMAT_ID).

G

generateUid() - Static method in class bitronix.tm.utils.UidGenerator
Generate a UID, globally unique.
generateXid(Uid) - Static method in class bitronix.tm.utils.UidGenerator
Generate a XID with the specified globalTransactionId.
get(JdbcPreparedStatementHandle) - Method in class bitronix.tm.resource.jdbc.LruStatementCache
The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes in with no actual 'delegate' PreparedStatement.
get(String) - Static method in class bitronix.tm.resource.ResourceRegistrar
Get a registered XAResourceProducer.
getAcknowledgeMode() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getAcknowledgeMode() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
getAcquireIncrement() - Method in class bitronix.tm.resource.common.ResourceBean
 
getAcquisitionDate() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getAcquisitionDate() - Method in interface bitronix.tm.resource.jdbc.JdbcPooledConnectionMBean
 
getAcquisitionDate() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getAcquisitionDate() - Method in interface bitronix.tm.resource.jms.JmsPooledConnectionMBean
 
getAcquisitionInterval() - Method in class bitronix.tm.resource.common.ResourceBean
 
getAcquisitionTimeout() - Method in class bitronix.tm.resource.common.ResourceBean
 
getAllowLocalTransactions() - Method in class bitronix.tm.resource.common.ResourceBean
 
getAllResources() - Method in class bitronix.tm.internal.XAResourceManager
 
getApplyTransactionTimeout() - Method in class bitronix.tm.resource.common.ResourceBean
 
getArray() - Method in class bitronix.tm.utils.Uid
 
getAutoCommit() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
getAutomaticEnlistingEnabled() - Method in class bitronix.tm.resource.common.ResourceBean
 
getBackgroundRecoveryInterval() - Method in class bitronix.tm.Configuration
Deprecated. superceded by #getBackgroundRecoveryIntervalSeconds().
getBackgroundRecoveryIntervalSeconds() - Method in class bitronix.tm.Configuration
Interval in seconds at which to run the recovery process in the background.
getBranchQualifier() - Method in class bitronix.tm.BitronixXid
Get the BQUAL of the XID.
getBranchQualifierUid() - Method in class bitronix.tm.BitronixXid
 
getByNaturalOrderForPosition(Integer) - Method in class bitronix.tm.utils.Scheduler
 
getByReverseOrderForPosition(Integer) - Method in class bitronix.tm.utils.Scheduler
 
getCachedStatement(JdbcPreparedStatementHandle) - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
Get a PreparedStatement from cache.
getCacheProducersConsumers() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
getChild(Object, int) - Method in class bitronix.tm.gui.ResourcesTreeModel
 
getChildCount(Object) - Method in class bitronix.tm.gui.ResourcesTreeModel
 
getClassLoader() - Static method in class bitronix.tm.utils.ClassLoaderUtils
Get the class loader which can be used to generate proxies without leaking memory.
getClassName() - Method in class bitronix.tm.resource.common.ResourceBean
 
getClientID() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
getClientID() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
getColumnClass(int) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
getColumnClass(int) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
getColumnCount() - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
getColumnCount() - Method in class bitronix.tm.gui.RawTransactionTableModel
 
getColumnName(int) - Method in class bitronix.tm.gui.DuplicatedGtridTableModel
 
getColumnName(int) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
getColumnName(int) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
getCommittedCount() - Method in class bitronix.tm.recovery.Recoverer
Get the amount of transactions committed during the last recovery run.
getCommittedCount() - Method in interface bitronix.tm.recovery.RecovererMBean
 
getCompletionException() - Method in class bitronix.tm.recovery.Recoverer
Get the exception reported when recovery failed.
getCompletionException() - Method in interface bitronix.tm.recovery.RecovererMBean
 
getConfiguration() - Static method in class bitronix.tm.TransactionManagerServices
Create the configuration of all the components of the transaction manager.
getConnection() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
getConnection() - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
getConnection() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
getConnection() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getConnection(String, String) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getConnectionFactoryClassName() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
getConnectionHandle() - Method in class bitronix.tm.resource.common.RecoveryXAResourceHolder
 
getConnectionHandle() - Method in class bitronix.tm.resource.common.XAPool
 
getConnectionHandle(boolean) - Method in class bitronix.tm.resource.common.XAPool
 
getConnectionHandle() - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
getConnectionHandle() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
getConnectionHandle() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getConnectionHandle() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getConnectionHandle() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getCrc32() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getCurrentTransaction() - Method in class bitronix.tm.BitronixTransactionManager
Get the transaction currently registered on the current thread context.
getCursor() - Method in class bitronix.tm.journal.TransactionLogAppender
Creates a cursor on this journal file allowing iteration of its records.
getCursorHoldability() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getDefaultTransactionTimeout() - Method in class bitronix.tm.Configuration
Default transaction timeout in seconds.
getDeferConnectionRelease() - Method in class bitronix.tm.resource.common.ResourceBean
 
getDelegateUnchecked() - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
getDeliveryMode() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
getDestination() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
getDisableMessageID() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
getDisableMessageTimestamp() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
getDriverClassName() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getDriverProperties() - Method in class bitronix.tm.resource.common.ResourceBean
 
getEndRecord() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getEnlistedResourcesUniqueNames() - Method in class bitronix.tm.BitronixTransaction
 
getEnlistedResourcesUniqueNames() - Method in interface bitronix.tm.BitronixTransactionMBean
 
getEnvironment() - Method in class bitronix.tm.jndi.BitronixContext
 
getExceptionAnalyzer() - Method in class bitronix.tm.Configuration
Get the exception analyzer implementation.
getExceptionAnalyzer() - Static method in class bitronix.tm.TransactionManagerServices
Create the exception analyzer.
getExceptionListener() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
getExceptionListener() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
getExceptions() - Method in exception bitronix.tm.internal.BitronixMultiSystemException
Get the list of exceptions that have been thrown during execution.
getExceptions() - Method in exception bitronix.tm.twopc.PhaseException
Get the list of exceptions that have been thrown during a phase execution.
getExecutionsCount() - Method in class bitronix.tm.recovery.Recoverer
Get how many times the recoverer has run since the transaction manager started.
getExecutionsCount() - Method in interface bitronix.tm.recovery.RecovererMBean
 
getExecutionTime() - Method in class bitronix.tm.timer.Task
 
getExecutor() - Static method in class bitronix.tm.TransactionManagerServices
Create the 2PC executor.
getExtraJndiProperties() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
The extra JNDI environment properties added the the InitialContext's environment upon creation.
getFormatId() - Method in class bitronix.tm.BitronixXid
Get Bitronix XID format ID.
getFormatId() - Method in class bitronix.tm.journal.TransactionLogHeader
Get FORMAT_ID_HEADER.
getFuture() - Method in class bitronix.tm.twopc.executor.Job
 
getGeneratedKeys() - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
getGeneratedKeys() - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
getGlobalTransactionId() - Method in class bitronix.tm.BitronixXid
Get the GTRID of the XID.
getGlobalTransactionIdUid() - Method in class bitronix.tm.BitronixXid
 
getGracefulShutdownInterval() - Method in class bitronix.tm.Configuration
Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
getGtrid() - Method in class bitronix.tm.BitronixTransaction
 
getGtrid() - Method in interface bitronix.tm.BitronixTransactionMBean
 
getGtrid() - Method in class bitronix.tm.internal.XAResourceManager
Get the GTRID of the transaction the XAResourceManager instance is attached to.
getGtrid() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getHeader() - Method in class bitronix.tm.journal.TransactionLogAppender
Return a TransactionLogHeader that allows reading and controlling the log file's header.
getHeaderLength() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getIgnoreRecoveryFailures() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getIgnoreRecoveryFailures() - Method in class bitronix.tm.resource.common.ResourceBean
 
getIndexOfChild(Object, Object) - Method in class bitronix.tm.gui.ResourcesTreeModel
 
getInFlightTransactions() - Method in class bitronix.tm.BitronixTransactionManager
Return all in-flight transactions.
getInitialContext(Hashtable) - Method in class bitronix.tm.jndi.BitronixInitialContextFactory
 
getInitialContextFactory() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
The Context.INITIAL_CONTEXT_FACTORY of the JNDI Context used to fetch the XAConnectionFactory.
getInPoolSize() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getInPoolSize() - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
getInPoolSize() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
getInPoolSize() - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
getInstance() - Static method in class bitronix.tm.journal.DiskForceBatcherThread
Get the single instance of the DiskForceBatcherThread.
getIsolationLevel() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getJndiTransactionSynchronizationRegistryName() - Method in class bitronix.tm.Configuration
Get the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
getJndiUserTransactionName() - Method in class bitronix.tm.Configuration
Get the name the UserTransaction should be bound under in the BitronixContext.
getJournal() - Method in class bitronix.tm.Configuration
Get the journal implementation.
getJournal() - Static method in class bitronix.tm.TransactionManagerServices
Create the transactions journal.
getLastReleaseDate() - Method in class bitronix.tm.resource.common.RecoveryXAResourceHolder
 
getLastReleaseDate() - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Get the date at which this object was last released to the pool.
getLastReleaseDate() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
Get the date at which this object was last released to the pool.
getLastReleaseDate() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getLastReleaseDate() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getLastReleaseDate() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getLocalAutoCommit() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getLoginTimeout() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getLoginTimeout() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getLogPart1Filename() - Method in class bitronix.tm.Configuration
Get the journal fragment file 1 name.
getLogPart2Filename() - Method in class bitronix.tm.Configuration
Get the journal fragment file 2 name.
getLogWriter() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getLogWriter() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getMaxIdleTime() - Method in class bitronix.tm.resource.common.ResourceBean
 
getMaxLogSizeInMb() - Method in class bitronix.tm.Configuration
Maximum size in megabytes of the journal fragments.
getMaxPoolSize() - Method in class bitronix.tm.resource.common.ResourceBean
 
getMaxPoolSize() - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
getMaxPoolSize() - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
getMessage() - Method in exception bitronix.tm.internal.BitronixMultiSystemException
 
getMessage() - Method in exception bitronix.tm.twopc.PhaseException
 
getMessageConsumer() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
getMessageListener() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getMessageListener() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
getMessageListener() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
getMessageProducer() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
getMessageSelector() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
getMetaData() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
getMetaData() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
getMinPoolSize() - Method in class bitronix.tm.resource.common.ResourceBean
 
getMinPoolSize() - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
getMinPoolSize() - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
getName() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
The JNDI name under which the XAConnectionFactory is available.
getNameInNamespace() - Method in class bitronix.tm.jndi.BitronixContext
 
getNameParser(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
getNameParser(String) - Method in class bitronix.tm.jndi.BitronixContext
 
getNaturalOrderPositions() - Method in class bitronix.tm.internal.XAResourceManager
 
getNaturalOrderPositions() - Method in class bitronix.tm.utils.Scheduler
 
getNaturalOrderResourcesForPosition(Integer) - Method in class bitronix.tm.internal.XAResourceManager
 
getNextShrinkDate() - Method in class bitronix.tm.resource.common.XAPool
 
getNoLocal() - Method in class bitronix.tm.resource.jms.TopicSubscriberWrapper
 
getObject() - Method in class bitronix.tm.timer.PoolShrinkingTask
 
getObject() - Method in class bitronix.tm.timer.RecoveryTask
 
getObject() - Method in class bitronix.tm.timer.Task
 
getObject() - Method in class bitronix.tm.timer.TransactionTimeoutTask
 
getObjectInstance(Object, Name, Context, Hashtable<?, ?>) - Method in class bitronix.tm.BitronixTransactionManagerObjectFactory
Since there can be only one transaction manager per VM instance, this method always returns a reference to the unique BitronixTransactionManager object.
getObjectInstance(Object, Name, Context, Hashtable<?, ?>) - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory
Since there can be only one synchronization registry per VM instance, this method always returns a reference to the unique BitronixTransactionSynchronizationRegistry object.
getObjectInstance(Object, Name, Context, Hashtable<?, ?>) - Method in class bitronix.tm.resource.ResourceObjectFactory
 
getOldestInFlightTransactionTimestamp() - Method in class bitronix.tm.BitronixTransactionManager
Return the timestamp of the oldest in-flight transaction.
getPassword() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getPassword() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
getPooledConnection() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
getPooledConnection() - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
getPooledConnection() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
getPoolingConnectionFactory() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getPoolingConnectionFactory() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getPoolingDataSource() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getPosition() - Method in class bitronix.tm.journal.TransactionLogHeader
Get CURRENT_POSITION_HEADER.
getPreparedStatementCacheSize() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getPriority() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
getProperties() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
getProperties(Object) - Static method in class bitronix.tm.utils.PropertyUtils
Build a map of direct javabeans properties of the target object.
getProperty(Object, String) - Static method in class bitronix.tm.utils.PropertyUtils
Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
getProviderUrl() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
The Context.PROVIDER_URL of the JNDI Context used to fetch the XAConnectionFactory.
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
Must be implemented by the sub-class of this class.
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.JdbcCallableStatementHandle
 
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.JdbcResultSetHandle
 
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
getProxiedDelegate() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
getRecordLength() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getRecoverer() - Static method in class bitronix.tm.TransactionManagerServices
Create the transaction recoverer.
getReference() - Method in class bitronix.tm.BitronixTransactionManager
BitronixTransactionManager can only have a single instance per JVM so this method always returns a reference with no special information to find back the sole instance.
getReference() - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
getReference() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
getReference() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
PoolingDataSource must alway have a unique name so this method builds a reference to this object using the unique name as RefAddr.
getReference() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
PoolingConnectionFactory must alway have a unique name so this method builds a reference to this object using the unique name as RefAddr.
getResource(Object) - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
getResource() - Method in class bitronix.tm.twopc.executor.Job
 
getResourceAsStream(String) - Static method in class bitronix.tm.utils.ClassLoaderUtils
Load a resource from the classpath.
getResourceBean() - Method in class bitronix.tm.resource.common.RecoveryXAResourceHolder
 
getResourceBean() - Method in interface bitronix.tm.resource.common.XAResourceHolder
Get the ResourceBean which created this XAResourceHolder.
getResourceBean() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
Get the ResourceBean which created this XAResourceHolder.
getResourceBean() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getResourceBean() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getResourceConfigurationFilename() - Method in class bitronix.tm.Configuration
ResourceLoader configuration file name.
getResourceLoader() - Static method in class bitronix.tm.TransactionManagerServices
Create the resource loader.
getResourceManager() - Method in class bitronix.tm.BitronixTransaction
 
getResources() - Method in class bitronix.tm.internal.ThreadContext
Get this context's resources, in the JTA 1.1 TransactionSynchronizationRegistry sense.
getResources() - Method in class bitronix.tm.resource.ResourceLoader
Get a Map with the configured uniqueName as key and XAResourceProducer as value.
getResourceStates() - Method in exception bitronix.tm.internal.BitronixMultiSystemException
Get the list of XAResourceHolderStates which threw an exception during execution.
getResourceStates() - Method in exception bitronix.tm.twopc.PhaseException
Get the list of resource which threw an exception during a phase execution.
getResourcesUniqueNames() - Static method in class bitronix.tm.resource.ResourceRegistrar
Get all XAResourceProducers unique names.
getResultSet() - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
getResultSet() - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
getReverseOrderPositions() - Method in class bitronix.tm.internal.XAResourceManager
 
getReverseOrderPositions() - Method in class bitronix.tm.utils.Scheduler
 
getReverseOrderResourcesForPosition(Integer) - Method in class bitronix.tm.internal.XAResourceManager
 
getRollbackOnly() - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
getRolledbackCount() - Method in class bitronix.tm.recovery.Recoverer
Get the amount of transactions rolled back during the last recovery run.
getRolledbackCount() - Method in interface bitronix.tm.recovery.RecovererMBean
 
getRoot() - Method in class bitronix.tm.gui.ResourcesTreeModel
 
getRow(int) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
getRow(int) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
getRow(int) - Method in class bitronix.tm.gui.TransactionTableModel
 
getRowCount() - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
getRowCount() - Method in class bitronix.tm.gui.RawTransactionTableModel
 
getRuntimeException() - Method in class bitronix.tm.twopc.executor.Job
 
getSecurityCredentials() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
The Context.SECURITY_CREDENTIALS of the JNDI Context used to fetch the XAConnectionFactory.
getSecurityPrincipal() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
The Context.SECURITY_PRINCIPAL of the JNDI Context used to fetch the XAConnectionFactory.
getSequenceNumber() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getServerId() - Method in class bitronix.tm.Configuration
ASCII ID that must uniquely identify this TM instance.
getSession() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getSession(boolean) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getSession() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
getShareTransactionConnections() - Method in class bitronix.tm.resource.common.ResourceBean
 
getStackTrace(Throwable) - Static method in class bitronix.tm.utils.ExceptionUtils
Returns the stack trace of the specified Throwable.
getStartDate() - Method in class bitronix.tm.BitronixTransaction
 
getStartDate() - Method in interface bitronix.tm.BitronixTransactionMBean
 
getState() - Method in class bitronix.tm.journal.TransactionLogHeader
Get STATE_HEADER.
getState() - Method in class bitronix.tm.resource.common.AbstractXAStatefulHolder
 
getState() - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Get the current resource state.
getState() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
getState() - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
getStateDescription() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getStateDescription() - Method in interface bitronix.tm.resource.jdbc.JdbcPooledConnectionMBean
 
getStateDescription() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getStateDescription() - Method in interface bitronix.tm.resource.jms.JmsPooledConnectionMBean
 
getStatement() - Method in class bitronix.tm.resource.jdbc.JdbcResultSetHandle
 
getStatus() - Method in class bitronix.tm.BitronixTransaction
 
getStatus() - Method in class bitronix.tm.BitronixTransactionManager
 
getStatus() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getStatusDescription() - Method in class bitronix.tm.BitronixTransaction
 
getStatusDescription() - Method in interface bitronix.tm.BitronixTransactionMBean
 
getSynchronizationScheduler() - Method in class bitronix.tm.BitronixTransaction
 
getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int) - Method in class bitronix.tm.gui.TransactionTableCellRenderer
 
getTaskScheduler() - Method in class bitronix.tm.timer.Task
 
getTaskScheduler() - Static method in class bitronix.tm.TransactionManagerServices
Create the task scheduler.
getTestConnections() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
getTestQuery() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getThreadName() - Method in class bitronix.tm.BitronixTransaction
 
getThreadName() - Method in interface bitronix.tm.BitronixTransactionMBean
 
getTime() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getTimeout() - Method in class bitronix.tm.internal.ThreadContext
Return this context's default timeout.
getTimestamp() - Method in class bitronix.tm.journal.TransactionLogHeader
Get TIMESTAMP_HEADER.
getTimeToLive() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
getTopic() - Method in class bitronix.tm.resource.jms.TopicSubscriberWrapper
 
getTotalPoolSize() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
getTotalPoolSize() - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
getTotalPoolSize() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
getTotalPoolSize() - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
getTransacted() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getTransacted() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
getTransaction() - Method in class bitronix.tm.BitronixTransactionManager
 
getTransaction() - Method in class bitronix.tm.internal.ThreadContext
Return the transaction linked with this thread context.
getTransactionGtridsCurrentlyHoldingThis() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getTransactionGtridsCurrentlyHoldingThis() - Method in interface bitronix.tm.resource.jdbc.JdbcPooledConnectionMBean
 
getTransactionGtridsCurrentlyHoldingThis() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getTransactionGtridsCurrentlyHoldingThis() - Method in interface bitronix.tm.resource.jms.JmsPooledConnectionMBean
 
getTransactionKey() - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
getTransactionManager() - Static method in class bitronix.tm.TransactionManagerServices
Create an initialized transaction manager.
getTransactionStatus() - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
getTransactionSynchronizationRegistry() - Static method in class bitronix.tm.TransactionManagerServices
Create the JTA 1.1 TransactionSynchronizationRegistry.
getTransactionTimeout() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
getTransactionTimeout() - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
getTransactionTimeoutDate() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getTwoPcOrderingPosition() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getTwoPcOrderingPosition() - Method in class bitronix.tm.resource.common.ResourceBean
 
getUniqueName() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getUniqueName() - Method in class bitronix.tm.recovery.DanglingTransaction
 
getUniqueName() - Method in class bitronix.tm.resource.common.ResourceBean
 
getUniqueName() - Method in interface bitronix.tm.resource.common.XAResourceProducer
Get the resource name as registered in the transactions journal.
getUniqueNames() - Method in class bitronix.tm.journal.TransactionLogRecord
 
getUrl() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getUrlPkgPrefixes() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
The Context.URL_PKG_PREFIXES of the JNDI Context used to fetch the XAConnectionFactory.
getUser() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getUser() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
getUseTmJoin() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getUseTmJoin() - Method in class bitronix.tm.resource.common.ResourceBean
 
getValueAt(int, int) - Method in class bitronix.tm.gui.DuplicatedGtridTableModel
 
getValueAt(int, int) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
getValueAt(int, int) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
getVersion() - Static method in class bitronix.tm.Version
 
getXAConnection() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getXAConnection(String, String) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
getXAConnection() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
getXAConnection() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getXAException() - Method in class bitronix.tm.twopc.executor.Job
 
getXAFactory() - Method in class bitronix.tm.resource.common.XAPool
 
getXAResource() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getXAResource() - Method in class bitronix.tm.resource.common.RecoveryXAResourceHolder
 
getXAResource() - Method in interface bitronix.tm.resource.common.XAResourceHolder
Get the vendor's XAResource implementation of the wrapped resource.
getXAResource() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
Get the vendor's XAResource implementation of the wrapped resource.
getXAResource() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getXAResource() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
getXAResource() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getXAResource() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
getXAResourceHolder() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getXAResourceHolders() - Method in class bitronix.tm.resource.common.RecoveryXAResourceHolder
 
getXAResourceHolders() - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
getXAResourceHolders() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
getXAResourceHolders() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
getXAResourceHolders() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
getXAResourceHolders() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
getXAResourceHolderStateGtrids() - Method in class bitronix.tm.resource.common.AbstractXAResourceHolder
Simple helper method which returns a set of GTRIDs of transactions in which this resource is enlisted.
getXAResourceHolderStatesForGtrid(Uid) - Method in class bitronix.tm.resource.common.AbstractXAResourceHolder
 
getXAResourceHolderStatesForGtrid(Uid) - Method in interface bitronix.tm.resource.common.XAResourceHolder
Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.
getXAStatefulHolder() - Method in class bitronix.tm.resource.common.DeferredReleaseSynchronization
 
getXid() - Method in class bitronix.tm.internal.XAResourceHolderState
 
getXid() - Method in class bitronix.tm.recovery.DanglingTransaction
 
goAhead(long) - Method in class bitronix.tm.journal.TransactionLogHeader
Advance CURRENT_POSITION_HEADER.
GTRID_COL - Static variable in class bitronix.tm.gui.RawTransactionTableModel
 

H

hashCode() - Method in class bitronix.tm.BitronixTransaction
 
hashCode() - Method in class bitronix.tm.BitronixXid
Get an integer hash for the XID.
hashCode() - Method in class bitronix.tm.internal.XAResourceHolderState
 
hashCode() - Method in class bitronix.tm.recovery.DanglingTransaction
 
hashCode() - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
hashCode() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
hashCode() - Method in class bitronix.tm.resource.jms.MessageProducerConsumerKey
 
hashCode() - Method in class bitronix.tm.utils.Uid
 
hasStateForXAResource(XAResourceHolder) - Method in class bitronix.tm.resource.common.AbstractXAResourceHolder
 
hasStateForXAResource(XAResourceHolder) - Method in interface bitronix.tm.resource.common.XAResourceHolder
Check if this XAResourceHolder contains a state for a specific XAResourceHolder.
head() - Method in class bitronix.tm.journal.DiskForceWaitQueue
 
HEADER_LENGTH - Static variable in class bitronix.tm.journal.TransactionLogHeader
Total length of the header.

I

incCreatedResourcesCounter() - Method in class bitronix.tm.resource.common.ResourceBean
Increment a transient counter.
IncrementalRecoverer - Class in bitronix.tm.recovery
Incremental resource recoverer.
IncrementalRecoverer() - Constructor for class bitronix.tm.recovery.IncrementalRecoverer
 
init() - Method in interface bitronix.tm.resource.common.XAResourceProducer
Initialize this XAResourceProducer's internal resources.
init() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Initialize this XAResourceProducer's internal resources.
init() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
Initializes the pool by creating the initial amount of connections.
init() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
 
init() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
Initialize the pool by creating the initial amount of connections.
init() - Method in class bitronix.tm.resource.ResourceLoader
Initialize the ResourceLoader and load the resources configuration file specified in bitronix.tm.resource.configuration property.
InitializationException - Exception in bitronix.tm.utils
Thrown at transaction manager startup when an error occurs.
InitializationException(String) - Constructor for exception bitronix.tm.utils.InitializationException
 
InitializationException(String, Throwable) - Constructor for exception bitronix.tm.utils.InitializationException
 
inPoolSize() - Method in class bitronix.tm.resource.common.XAPool
 
intToBytes(int) - Static method in class bitronix.tm.utils.Encoder
 
invoke(Object, Method, Object[]) - Method in class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
Implementation of the InvocationHandler interface.
isAllowMultipleLrc() - Method in class bitronix.tm.Configuration
Should the transaction manager allow enlistment of multiple LRC resources in a single transaction? This is highly unsafe but could be useful for testing.
isAsynchronous2Pc() - Method in class bitronix.tm.Configuration
Should two phase commit be executed asynchronously? Asynchronous two phase commit can improve performance when there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread spawning requirements.
isCellEditable(int, int) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
isCellEditable(int, int) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
isClosed() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
isClosed() - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
isClosed() - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
isCrc32Correct() - Method in class bitronix.tm.journal.TransactionLogRecord
Recalculate the CRC32 value of this record (using TransactionLogRecord.calculateCrc32()) and compare it with the stored value.
isCurrentNodeOnlyRecovery() - Method in class bitronix.tm.Configuration
Should the recovery process not recover XIDs generated with another JVM unique ID? Setting this property to true is useful in clustered environments where multiple instances of BTM are running on different nodes.
isDebugZeroResourceTransaction() - Method in class bitronix.tm.Configuration
Should creation and commit call stacks of transactions executed without a single enlisted tracked and logged or not?
isDisabled() - Method in class bitronix.tm.resource.common.ResourceBean
 
isDisabled() - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
isDisabled() - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
isDisableJmx() - Method in class bitronix.tm.Configuration
Should JMX Mbeans not be registered even if a JMX MBean server is detected?
isDone(Object) - Method in class bitronix.tm.twopc.executor.AsyncExecutor
 
isDone(Object) - Method in interface bitronix.tm.twopc.executor.Executor
Check if the thread pool has terminated the execution of the job represented by a future.
isDone(Object) - Method in class bitronix.tm.twopc.executor.SyncExecutor
 
isEmpty() - Method in class bitronix.tm.journal.DiskForceWaitQueue
 
isEnableJdbc4ConnectionTest() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
isEnded() - Method in class bitronix.tm.internal.XAResourceHolderState
 
isFailed() - Method in class bitronix.tm.internal.XAResourceHolderState
 
isFailed() - Method in class bitronix.tm.resource.common.XAPool
 
isFailed() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
isFailed() - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
isFailed() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
isFailed() - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
isFilterLogStatus() - Method in class bitronix.tm.Configuration
Should only mandatory logs be written? Enabling this parameter lowers space usage of the fragments but makes debugging more complex.
isForceBatchingEnabled() - Method in class bitronix.tm.Configuration
Are disk forces batched? Disabling batching can seriously lower the transaction manager's throughput.
isForcedWriteEnabled() - Method in class bitronix.tm.Configuration
Are logs forced to disk? Do not set to false in production since without disk force, integrity is not guaranteed.
isLeaf(Object) - Method in class bitronix.tm.gui.ResourcesTreeModel
 
isNarrowJndiObject() - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Should PortableRemoteObject.narrow(Object, Class) be applied on the object looked up from JNDI before trying to cast it to XAConnectionFactory ?
isParticipating(XAResourceHolderState) - Method in class bitronix.tm.twopc.AbstractPhaseEngine
Determine if a resource is participating in the phase or not.
isParticipating(XAResourceHolderState) - Method in class bitronix.tm.twopc.Committer
 
isParticipating(XAResourceHolderState) - Method in class bitronix.tm.twopc.Preparer
 
isParticipating(XAResourceHolderState) - Method in class bitronix.tm.twopc.Rollbacker
 
isParticipatingInActiveGlobalTransaction() - Method in class bitronix.tm.resource.common.AbstractXAResourceHolder
If this method returns false, then local transaction calls like Connection.commit() can be made.
isRunning() - Method in class bitronix.tm.recovery.Recoverer
Check if the recoverer currently is running.
isRunning() - Method in interface bitronix.tm.recovery.RecovererMBean
 
isSameRM(XAResource) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
isSameRM(XAResource) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
isSkipCorruptedLogs() - Method in class bitronix.tm.Configuration
Should corrupted logs be skipped?
isStarted() - Method in class bitronix.tm.internal.XAResourceHolderState
 
isSuspended() - Method in class bitronix.tm.internal.XAResourceHolderState
 
isTaskSchedulerRunning() - Static method in class bitronix.tm.TransactionManagerServices
Check if the task scheduler has started.
isTransactionManagerRunning() - Static method in class bitronix.tm.TransactionManagerServices
Check if the transaction manager has started.
isUnilateralRollback() - Method in exception bitronix.tm.internal.BitronixMultiSystemException
 
isUnilateralRollback(XAException) - Static method in exception bitronix.tm.internal.BitronixXAException
 
isWarnAboutZeroResourceTransaction() - Method in class bitronix.tm.Configuration
Should transactions executed without a single enlisted resource result in a warning or not? Most of the time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere.
isWrapperFor(Class<?>) - Method in class bitronix.tm.resource.jdbc.JdbcCallableStatementHandle
 
isWrapperFor(Class<?>) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
isWrapperFor(Class<?>) - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
isWrapperFor(Class<?>) - Method in class bitronix.tm.resource.jdbc.JdbcResultSetHandle
 
isWrapperFor(Class<?>) - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
isWrapperFor(Class<?>) - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
isWrapperFor(Class<?>) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
iterator() - Method in class bitronix.tm.utils.Scheduler
 

J

JdbcCallableStatementHandle - Class in bitronix.tm.resource.jdbc
CallableStatement Statement wrapper.
JdbcCallableStatementHandle(CallableStatement, JdbcPooledConnection) - Constructor for class bitronix.tm.resource.jdbc.JdbcCallableStatementHandle
 
JdbcConnectionHandle - Class in bitronix.tm.resource.jdbc
Disposable Connection handle.
JdbcConnectionHandle(JdbcPooledConnection, Connection) - Constructor for class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
JdbcPooledConnection - Class in bitronix.tm.resource.jdbc
Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
JdbcPooledConnection(PoolingDataSource, XAConnection) - Constructor for class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
JdbcPooledConnectionMBean - Interface in bitronix.tm.resource.jdbc
JdbcPooledConnection Management interface.
JdbcPreparedStatementHandle - Class in bitronix.tm.resource.jdbc
Caching PreparedStatement wrapper.
JdbcPreparedStatementHandle(String) - Constructor for class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
JdbcPreparedStatementHandle(String, int) - Constructor for class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
JdbcPreparedStatementHandle(String, int, int) - Constructor for class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
JdbcPreparedStatementHandle(String, int, int, int) - Constructor for class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
JdbcPreparedStatementHandle(String, int[]) - Constructor for class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
JdbcPreparedStatementHandle(String, String[]) - Constructor for class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
JdbcResultSetHandle - Class in bitronix.tm.resource.jdbc
ResultSet ResultSet wrapper.
JdbcResultSetHandle(ResultSet, BaseProxyHandlerClass) - Constructor for class bitronix.tm.resource.jdbc.JdbcResultSetHandle
 
JdbcStatementHandle - Class in bitronix.tm.resource.jdbc
Statement Statement wrapper.
JdbcStatementHandle(Statement, JdbcPooledConnection) - Constructor for class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
JdbcUncachedPreparedStatementHandle - Class in bitronix.tm.resource.jdbc
 
JdbcUncachedPreparedStatementHandle(PreparedStatement, JdbcPooledConnection) - Constructor for class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
JmsConnectionHandle - Class in bitronix.tm.resource.jms
Disposable Connection handle.
JmsConnectionHandle(JmsPooledConnection, XAConnection) - Constructor for class bitronix.tm.resource.jms.JmsConnectionHandle
 
JmsPooledConnection - Class in bitronix.tm.resource.jms
Implementation of a JMS pooled connection wrapping vendor's XAConnection implementation.
JmsPooledConnection(PoolingConnectionFactory, XAConnection) - Constructor for class bitronix.tm.resource.jms.JmsPooledConnection
 
JmsPooledConnectionMBean - Interface in bitronix.tm.resource.jms
JmsPooledConnection Management interface.
JndiXAConnectionFactory - Class in bitronix.tm.resource.jms
XAConnectionFactory implementation that wraps another XAConnectionFactory implementation available in some JNDI tree.
JndiXAConnectionFactory() - Constructor for class bitronix.tm.resource.jms.JndiXAConnectionFactory
 
Job - Class in bitronix.tm.twopc.executor
Abstract job definition executable by the 2PC thread pools.
Job(XAResourceHolderState) - Constructor for class bitronix.tm.twopc.executor.Job
 
Journal - Interface in bitronix.tm.journal
Transaction logs journal implementations must implement this interface to provide functionality required by the transaction manager.

L

list(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
list(String) - Method in class bitronix.tm.jndi.BitronixContext
 
listBindings(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
listBindings(String) - Method in class bitronix.tm.jndi.BitronixContext
 
loadClass(String) - Static method in class bitronix.tm.utils.ClassLoaderUtils
Load a class by name.
log(int, Uid, Set<String>) - Method in class bitronix.tm.journal.DiskJournal
Log a new transaction status to journal.
log(int, Uid, Set<String>) - Method in interface bitronix.tm.journal.Journal
Log a new transaction status to journal.
log(int, Uid, Set<String>) - Method in class bitronix.tm.journal.NullJournal
 
logFailedResources(PhaseException) - Method in class bitronix.tm.twopc.AbstractPhaseEngine
Log exceptions that happened during a phase failure.
longToBytes(long) - Static method in class bitronix.tm.utils.Encoder
 
lookup(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
lookup(String) - Method in class bitronix.tm.jndi.BitronixContext
 
lookupLink(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
lookupLink(String) - Method in class bitronix.tm.jndi.BitronixContext
 
LrcConnectionHandle - Class in bitronix.tm.resource.jdbc.lrc
Connection handle implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
LrcConnectionHandle(LrcXAResource, Connection) - Constructor for class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
LrcXAConnection - Class in bitronix.tm.resource.jdbc.lrc
XAConnection implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
LrcXAConnection(Connection) - Constructor for class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
LrcXAConnection - Class in bitronix.tm.resource.jms.lrc
XAConnection implementation for a non-XA JMS resource emulating XA with Last Resource Commit.
LrcXAConnection(Connection) - Constructor for class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
LrcXAConnectionFactory - Class in bitronix.tm.resource.jms.lrc
XAConnectionFactory implementation for a non-XA JMS resource emulating XA with Last Resource Commit.
LrcXAConnectionFactory() - Constructor for class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
LrcXADataSource - Class in bitronix.tm.resource.jdbc.lrc
XADataSource implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
LrcXADataSource() - Constructor for class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
LrcXAResource - Class in bitronix.tm.resource.jdbc.lrc
XAResource implementation for a non-XA JDBC connection emulating XA with Last Resource Commit.
LrcXAResource(Connection) - Constructor for class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
LrcXAResource - Class in bitronix.tm.resource.jms.lrc
XAResource implementation for a non-XA JMS connection emulating XA with Last Resource Commit.
LrcXAResource(Session) - Constructor for class bitronix.tm.resource.jms.lrc.LrcXAResource
 
LrcXASession - Class in bitronix.tm.resource.jms.lrc
XASession implementation for a non-XA JMS resource emulating XA with Last Resource Commit.
LrcXASession(Session) - Constructor for class bitronix.tm.resource.jms.lrc.LrcXASession
 
LruEvictionListener - Interface in bitronix.tm.resource.jdbc
Eviction listener interface for LruStatementCache.
LruStatementCache - Class in bitronix.tm.resource.jdbc
Last Recently Used PreparedStatement cache with eviction listeners support implementation.
LruStatementCache(int) - Constructor for class bitronix.tm.resource.jdbc.LruStatementCache
 

M

main(String[]) - Static method in class bitronix.tm.gui.Console
 
main(String[]) - Static method in class bitronix.tm.utils.CryptoEngine
Main method of this class to be used as a command-line tool to get a crypted version of a resource password.
makeValidName(String) - Static method in class bitronix.tm.utils.ManagementRegistrar
Replace characters considered illegal in a management object's name.
ManagementRegistrar - Class in bitronix.tm.utils
Simple JMX facade.
MessageConsumerWrapper - Class in bitronix.tm.resource.jms
MessageConsumer wrapper that adds XA enlistment semantics.
MessageConsumerWrapper(MessageConsumer, DualSessionWrapper, PoolingConnectionFactory) - Constructor for class bitronix.tm.resource.jms.MessageConsumerWrapper
 
MessageProducerConsumerKey - Class in bitronix.tm.resource.jms
JMS destination wrapper optimized for use with hashed collections where it is the key and a MessageProducer or a MessageConsumer is the value.
MessageProducerConsumerKey(Destination) - Constructor for class bitronix.tm.resource.jms.MessageProducerConsumerKey
 
MessageProducerConsumerKey(Destination, String) - Constructor for class bitronix.tm.resource.jms.MessageProducerConsumerKey
 
MessageProducerConsumerKey(Destination, String, boolean) - Constructor for class bitronix.tm.resource.jms.MessageProducerConsumerKey
 
MessageProducerWrapper - Class in bitronix.tm.resource.jms
MessageProducer wrapper that adds XA enlistment semantics.
MessageProducerWrapper(MessageProducer, DualSessionWrapper, PoolingConnectionFactory) - Constructor for class bitronix.tm.resource.jms.MessageProducerWrapper
 
MonotonicClock - Class in bitronix.tm.utils
A System.currentTimeMillis() replacement which guarantees monotonic time increment.
MonotonicClock() - Constructor for class bitronix.tm.utils.MonotonicClock
 
mouseClicked(MouseEvent) - Method in class bitronix.tm.gui.TransactionTableMouseListener
 

N

NO_TX - Static variable in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
NO_TX - Static variable in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
NullJournal - Class in bitronix.tm.journal
No-op journal.
NullJournal() - Constructor for class bitronix.tm.journal.NullJournal
 

O

onAcquire(Connection, String) - Method in interface bitronix.tm.resource.jdbc.ConnectionCustomizer
Called when the physical connection is created.
onDestroy(Connection, String) - Method in interface bitronix.tm.resource.jdbc.ConnectionCustomizer
Called when the physical connection is destroyed.
onEviction(Object) - Method in interface bitronix.tm.resource.jdbc.LruEvictionListener
 
open() - Method in class bitronix.tm.journal.DiskJournal
Open the disk journal.
open() - Method in interface bitronix.tm.journal.Journal
Open the journal.
open() - Method in class bitronix.tm.journal.NullJournal
 

P

PendingTransactionTableModel - Class in bitronix.tm.gui
PendingTransactionTableModel(File) - Constructor for class bitronix.tm.gui.PendingTransactionTableModel
 
PhaseException - Exception in bitronix.tm.twopc
Thrown when a phase exection has thrown one or more exception(s).
PhaseException(List<Exception>, List<XAResourceHolderState>) - Constructor for exception bitronix.tm.twopc.PhaseException
 
pickCurrentLogFile(File, File) - Static method in class bitronix.tm.gui.Console
 
PoolingConnectionFactory - Class in bitronix.tm.resource.jms
Implementation of a JMS ConnectionFactory wrapping vendor's XAConnectionFactory implementation.
PoolingConnectionFactory() - Constructor for class bitronix.tm.resource.jms.PoolingConnectionFactory
 
PoolingConnectionFactoryMBean - Interface in bitronix.tm.resource.jms
 
PoolingDataSource - Class in bitronix.tm.resource.jdbc
Implementation of a JDBC DataSource wrapping vendor's XADataSource implementation.
PoolingDataSource() - Constructor for class bitronix.tm.resource.jdbc.PoolingDataSource
 
PoolingDataSourceMBean - Interface in bitronix.tm.resource.jdbc
 
PoolShrinkingTask - Class in bitronix.tm.timer
This task is used to notify a XA pool to close idle connections.
PoolShrinkingTask(XAPool, Date, TaskScheduler) - Constructor for class bitronix.tm.timer.PoolShrinkingTask
 
prepare(Xid) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
prepare(Xid) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
prepare(BitronixTransaction) - Method in class bitronix.tm.twopc.Preparer
Execute phase 1 prepare.
prepareCall(String) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
prepareCall(String, int, int) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
prepareCall(String, int, int, int) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
PREPARED - Static variable in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
PREPARED - Static variable in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
Preparer - Class in bitronix.tm.twopc
Phase 1 Prepare logic engine.
Preparer(Executor) - Constructor for class bitronix.tm.twopc.Preparer
 
prepareStatement(String) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
prepareStatement(String, int) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
prepareStatement(String, int, int) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
prepareStatement(String, int, int, int) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
prepareStatement(String, int[]) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
prepareStatement(String, String[]) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
propertiesToString(Object) - Static method in class bitronix.tm.utils.PropertyUtils
Return a comma-separated String of r/w properties of the specified object.
PropertyException - Exception in bitronix.tm.utils
Thrown by PropertyUtils when some reflection error occurs.
PropertyException(String, Throwable) - Constructor for exception bitronix.tm.utils.PropertyException
 
PropertyException(String) - Constructor for exception bitronix.tm.utils.PropertyException
 
PropertyUtils - Class in bitronix.tm.utils
Smart reflection helper.
PropertyUtils() - Constructor for class bitronix.tm.utils.PropertyUtils
 
put(JdbcPreparedStatementHandle) - Method in class bitronix.tm.resource.jdbc.LruStatementCache
A statement is put into the cache.
putCachedStatement(JdbcPreparedStatementHandle) - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
Put a PreparedStatement in the cache.
putResource(Object, Object) - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
putXAResourceHolderState(BitronixXid, XAResourceHolderState) - Method in class bitronix.tm.resource.common.AbstractXAResourceHolder
 
putXAResourceHolderState(BitronixXid, XAResourceHolderState) - Method in interface bitronix.tm.resource.common.XAResourceHolder
Add a XAResourceHolderState of this wrapped resource.

R

RawTransactionTableModel - Class in bitronix.tm.gui
RawTransactionTableModel(File) - Constructor for class bitronix.tm.gui.RawTransactionTableModel
 
read(File, boolean) - Method in class bitronix.tm.gui.TransactionLogHeaderPanel
 
readFullTransactionLog(File) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
readFullTransactionLog(File) - Method in class bitronix.tm.gui.TransactionTableModel
 
readLog() - Method in class bitronix.tm.journal.TransactionLogCursor
Fetch the next TransactionLogRecord from log, recalculating the CRC and checking it against the stored one.
readLog(boolean) - Method in class bitronix.tm.journal.TransactionLogCursor
Fetch the next TransactionLogRecord from log.
rebind(Name, Object) - Method in class bitronix.tm.jndi.BitronixContext
 
rebind(String, Object) - Method in class bitronix.tm.jndi.BitronixContext
 
receive() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
receive(long) - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
receiveNoWait() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
recover(XAResourceProducer) - Static method in class bitronix.tm.recovery.IncrementalRecoverer
Run incremental recovery on the specified resource.
recover(XAResourceHolderState) - Static method in class bitronix.tm.recovery.RecoveryHelper
Run the recovery process on the target resource.
recover(int) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
recover() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
recover(int) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
recover() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
Recoverer - Class in bitronix.tm.recovery
Recovery process implementation.
Recoverer() - Constructor for class bitronix.tm.recovery.Recoverer
 
RecovererMBean - Interface in bitronix.tm.recovery
Recoverer Management interface.
RecoveryException - Exception in bitronix.tm.recovery
Thrown when an error occurs during recovery.
RecoveryException(String, Throwable) - Constructor for exception bitronix.tm.recovery.RecoveryException
 
RecoveryException(String) - Constructor for exception bitronix.tm.recovery.RecoveryException
 
RecoveryHelper - Class in bitronix.tm.recovery
Reovery helper methods.
RecoveryHelper() - Constructor for class bitronix.tm.recovery.RecoveryHelper
 
RecoveryTask - Class in bitronix.tm.timer
This task is used to run the background recovery.
RecoveryTask(Recoverer, Date, TaskScheduler) - Constructor for class bitronix.tm.timer.RecoveryTask
 
RecoveryXAResourceHolder - Class in bitronix.tm.resource.common
XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
RecoveryXAResourceHolder(XAResourceHolder) - Constructor for class bitronix.tm.resource.common.RecoveryXAResourceHolder
 
recycle(XAStatefulHolder) - Static method in class bitronix.tm.resource.common.TransactionContextHelper
Ensure the XAStatefulHolder's release won't be deferred anymore (when appropriate) as it has been recycled.
register(XAResourceProducer) - Static method in class bitronix.tm.resource.ResourceRegistrar
Register a XAResourceProducer.
register(String, Object) - Static method in class bitronix.tm.utils.ManagementRegistrar
Register the specified management object.
registerInterposedSynchronization(Synchronization) - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
registerSynchronization(Synchronization) - Method in class bitronix.tm.BitronixTransaction
 
registerUncachedStatement(Statement) - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
Register uncached statement so that it can be closed when the connection is put back in the pool.
registerXAResource(String, XAResource) - Static method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Register an XAResource of a cache with BTM.
release() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
release() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
releaseSavepoint(Savepoint) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
remove(T) - Method in class bitronix.tm.utils.Scheduler
 
removeConnectionCustomizer(ConnectionCustomizer) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
removeConnectionEventListener(ConnectionEventListener) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
removeEvictionListener(LruEvictionListener) - Method in class bitronix.tm.resource.jdbc.LruStatementCache
 
removeFromEnvironment(String) - Method in class bitronix.tm.jndi.BitronixContext
 
removeStateChangeEventListener(StateChangeListener) - Method in class bitronix.tm.resource.common.AbstractXAStatefulHolder
 
removeStateChangeEventListener(StateChangeListener) - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Unregister an implementation of StateChangeListener.
removeTableModelListener(TableModelListener) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
removeTableModelListener(TableModelListener) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
removeTreeModelListener(TreeModelListener) - Method in class bitronix.tm.gui.ResourcesTreeModel
 
removeXAResourceHolderState(BitronixXid) - Method in class bitronix.tm.resource.common.AbstractXAResourceHolder
 
removeXAResourceHolderState(BitronixXid) - Method in interface bitronix.tm.resource.common.XAResourceHolder
Remove all states related to a specific Xid from this wrapped resource.
rename(Name, Name) - Method in class bitronix.tm.jndi.BitronixContext
 
rename(String, String) - Method in class bitronix.tm.jndi.BitronixContext
 
requeue(XAStatefulHolder, ResourceBean) - Static method in class bitronix.tm.resource.common.TransactionContextHelper
Switch the XAStatefulHolder's state appropriately after the acquired resource handle has been closed.
reset() - Method in class bitronix.tm.resource.common.XAPool
 
reset() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
reset() - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
reset() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
reset() - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
ResourceBean - Class in bitronix.tm.resource.common
Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.
ResourceBean() - Constructor for class bitronix.tm.resource.common.ResourceBean
Initialize all properties with their default values.
ResourceConfigurationException - Exception in bitronix.tm.resource
Thrown when a resource cannot be created due to a configuration error.
ResourceConfigurationException(String, Throwable) - Constructor for exception bitronix.tm.resource.ResourceConfigurationException
 
ResourceConfigurationException(String) - Constructor for exception bitronix.tm.resource.ResourceConfigurationException
 
ResourceLoader - Class in bitronix.tm.resource
XA resources pools configurator & loader.
ResourceLoader() - Constructor for class bitronix.tm.resource.ResourceLoader
 
ResourceObjectFactory - Class in bitronix.tm.resource
XAResourceProducer object factory for JNDI references.
ResourceObjectFactory() - Constructor for class bitronix.tm.resource.ResourceObjectFactory
 
ResourceRegistrar - Class in bitronix.tm.resource
Collection of initialized XAResourceProducers.
ResourceRegistrar() - Constructor for class bitronix.tm.resource.ResourceRegistrar
 
ResourcesPanel - Class in bitronix.tm.gui
 
ResourcesPanel() - Constructor for class bitronix.tm.gui.ResourcesPanel
 
ResourcesTreeModel - Class in bitronix.tm.gui
 
ResourcesTreeModel() - Constructor for class bitronix.tm.gui.ResourcesTreeModel
 
resume(Transaction) - Method in class bitronix.tm.BitronixTransactionManager
 
resume() - Method in class bitronix.tm.internal.XAResourceManager
Resume all enlisted resources in the current transaction context.
reverseIterator() - Method in class bitronix.tm.utils.Scheduler
 
rewind() - Method in class bitronix.tm.journal.TransactionLogHeader
Rewind CURRENT_POSITION_HEADER back to the beginning of the file.
rollback() - Method in class bitronix.tm.BitronixTransaction
 
rollback() - Method in class bitronix.tm.BitronixTransactionManager
 
rollback(XAResourceHolderState, Xid) - Static method in class bitronix.tm.recovery.RecoveryHelper
Rollback the specified branch of a dangling transaction.
rollback() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
rollback(Savepoint) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
rollback() - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
rollback(Savepoint) - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
rollback(Xid) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
rollback() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
rollback(Xid) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
rollback() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
rollback(BitronixTransaction, List<XAResourceHolderState>) - Method in class bitronix.tm.twopc.Rollbacker
Rollback the current XA transaction.
Rollbacker - Class in bitronix.tm.twopc
Phase 1 & 2 Rollback logic engine.
Rollbacker(Executor) - Constructor for class bitronix.tm.twopc.Rollbacker
 
run() - Method in class bitronix.tm.journal.DiskForceBatcherThread
 
run() - Method in class bitronix.tm.recovery.Recoverer
Run the recovery process.
run() - Method in interface bitronix.tm.recovery.RecovererMBean
 
run() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
run() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
run() - Method in class bitronix.tm.timer.TaskScheduler
 
run() - Method in class bitronix.tm.twopc.executor.Job
 
runtimeException - Variable in class bitronix.tm.twopc.executor.Job
 

S

schedulePoolShrinking(XAPool) - Method in class bitronix.tm.timer.TaskScheduler
Schedule a task that will tell a XA pool to close idle connections.
Scheduler<T> - Class in bitronix.tm.utils
Positional object container.
Scheduler() - Constructor for class bitronix.tm.utils.Scheduler
 
scheduleRecovery(Recoverer, Date) - Method in class bitronix.tm.timer.TaskScheduler
Schedule a task that will run background recovery at the specified date.
scheduleTransactionTimeout(BitronixTransaction, Date) - Method in class bitronix.tm.timer.TaskScheduler
Schedule a task that will mark the transaction as timed out at the specified date.
send(Message) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
send(Message, int, int, long) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
send(Destination, Message) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
send(Destination, Message, int, int, long) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
Service - Interface in bitronix.tm.utils
All internal services implement this interface.
session - Variable in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
session - Variable in class bitronix.tm.resource.jms.MessageProducerWrapper
 
setAcquireIncrement(int) - Method in class bitronix.tm.resource.common.ResourceBean
Define the amount of connections to be created at once when the pool needs to grow.
setAcquisitionInterval(int) - Method in class bitronix.tm.resource.common.ResourceBean
Set the amount of time in seconds the pool will wait before trying to acquire a connection again after an invalid connection has been attempted to be acquired.
setAcquisitionTimeout(int) - Method in class bitronix.tm.resource.common.ResourceBean
Define the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty.
setActive(int) - Method in class bitronix.tm.BitronixTransaction
 
setAlive(boolean) - Method in class bitronix.tm.journal.DiskForceBatcherThread
Thread will run for as long as this flag is not false.
setAllowLocalTransactions(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Set if the transaction manager should allow mixing XA and non-XA transactions.
setAllowMultipleLrc(boolean) - Method in class bitronix.tm.Configuration
Set to true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction.
setApplyTransactionTimeout(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Set if the transaction-timeout should be set on the XAResource when the XAResource is enlisted.
setAsynchronous2Pc(boolean) - Method in class bitronix.tm.Configuration
Set if two phase commit should be executed asynchronously.
setAutoCommit(boolean) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
setAutoCommit(boolean) - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
setAutomaticEnlistingEnabled(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Specify if the XA resource wrapper should enlist/delist this resource automatically in global transactions.
setBackgroundRecoveryInterval(int) - Method in class bitronix.tm.Configuration
Deprecated. superceded by #setBackgroundRecoveryIntervalSeconds(int).
setBackgroundRecoveryIntervalSeconds(int) - Method in class bitronix.tm.Configuration
Set the interval in seconds at which to run the recovery process in the background.
setCacheProducersConsumers(boolean) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
setClassName(String) - Method in class bitronix.tm.resource.common.ResourceBean
Specify the underlying implementation class name of the XA resource described by this bean.
setClientID(String) - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
setClientID(String) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
setConnectionFactoryClassName(String) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
setCurrentNodeOnlyRecovery(boolean) - Method in class bitronix.tm.Configuration
Set to true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
setCursorHoldability(String) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
Set the default cursor holdability for connections.
setDebugZeroResourceTransaction(boolean) - Method in class bitronix.tm.Configuration
Set if creation and commit call stacks of transactions executed without a single enlisted resource should be tracked and logged.
setDefaultTransactionTimeout(int) - Method in class bitronix.tm.Configuration
Set the default transaction timeout in seconds.
setDeferConnectionRelease(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Define the transaction interleaving capability of the database.
setDelegate(PreparedStatement) - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
setDeliveryMode(int) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
setDisabled(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Set whether this resource is disabled, meaning it's temporarily forbidden to acquire a connection from its pool.
setDisabled(boolean) - Method in interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
 
setDisabled(boolean) - Method in interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
 
setDisableJmx(boolean) - Method in class bitronix.tm.Configuration
Set to true if JMX Mbeans should not be registered even if a JMX MBean server is detected.
setDisableMessageID(boolean) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
setDisableMessageTimestamp(boolean) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
setDriverClassName(String) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
setDriverProperties(Properties) - Method in class bitronix.tm.resource.common.ResourceBean
Set the properties that should be set on the underlying implementation.
setEnableJdbc4ConnectionTest(boolean) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
When set and the underlying JDBC driver supports JDBC 4 isValid(), a Connection.isValid() call is performed to test the connection before handing it to the caller.
setExceptionAnalyzer(String) - Method in class bitronix.tm.Configuration
Set the exception analyzer implementation.
setExceptionListener(ExceptionListener) - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
setExceptionListener(ExceptionListener) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
setExtraJndiProperties(Properties) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set the extra JNDI environment properties added the the InitialContext's environment upon creation.
setFailed(boolean) - Method in class bitronix.tm.resource.common.XAPool
 
setFailed(boolean) - Method in interface bitronix.tm.resource.common.XAResourceProducer
Mark this resource producer as failed or not.
setFailed(boolean) - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Mark this resource producer as failed or not.
setFailed(boolean) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
setFailed(boolean) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
setFilterLogStatus(boolean) - Method in class bitronix.tm.Configuration
Set if only mandatory logs should be written.
setForceBatchingEnabled(boolean) - Method in class bitronix.tm.Configuration
Set if disk forces are batched.
setForcedWriteEnabled(boolean) - Method in class bitronix.tm.Configuration
Set if logs are forced to disk.
setFormatId(int) - Method in class bitronix.tm.journal.TransactionLogHeader
Set FORMAT_ID_HEADER.
setFuture(Object) - Method in class bitronix.tm.twopc.executor.Job
 
setGracefulShutdownInterval(int) - Method in class bitronix.tm.Configuration
Set the maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
setIgnoreRecoveryFailures(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Set whether XA recovery errors should quarantine the resource or be ignored.
setInitialContextFactory(String) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set the Context.INITIAL_CONTEXT_FACTORY of the JNDI Context used to fetch the XAConnectionFactory.
setIsolationLevel(String) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
Set the default isolation level for connections.
setJndiTransactionSynchronizationRegistryName(String) - Method in class bitronix.tm.Configuration
Set the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
setJndiUserTransactionName(String) - Method in class bitronix.tm.Configuration
Set the name the UserTransaction should be bound under in the BitronixContext.
setJournal(String) - Method in class bitronix.tm.Configuration
Set the journal name.
setLocalAutoCommit(String) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
Set the default local transactions autocommit mode.
setLogFile(File) - Method in class bitronix.tm.gui.TransactionLogHeaderPanel
 
setLoginTimeout(int) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
setLoginTimeout(int) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
setLogPart1Filename(String) - Method in class bitronix.tm.Configuration
Set the journal fragment file 1 name.
setLogPart2Filename(String) - Method in class bitronix.tm.Configuration
Set the journal fragment file 2 name.
setLogWriter(PrintWriter) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
setLogWriter(PrintWriter) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
setMaxIdleTime(int) - Method in class bitronix.tm.resource.common.ResourceBean
Define the amount of seconds and idle connection can stay in the pool before getting closed.
setMaxLogSizeInMb(int) - Method in class bitronix.tm.Configuration
Set the Maximum size in megabytes of the journal fragments.
setMaxPoolSize(int) - Method in class bitronix.tm.resource.common.ResourceBean
Define the maximum amount of connections that can be in the pool.
setMessageListener(MessageListener) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
setMessageListener(MessageListener) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
setMessageListener(MessageListener) - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
setMinPoolSize(int) - Method in class bitronix.tm.resource.common.ResourceBean
Define the minimal amount of connections that can be in the pool.
setName(String) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set the JNDI name under which the XAConnectionFactory is available.
setNarrowJndiObject(boolean) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set if PortableRemoteObject.narrow(Object, Class) should be applied on the object looked up from JNDI before trying to cast it to XAConnectionFactory ?
setPassword(String) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
setPassword(String) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
setPooledConnection(JdbcPooledConnection) - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
Set the parent connection that created this statement.
setPosition(long) - Method in class bitronix.tm.gui.TransactionLogHeaderPanel
 
setPosition(long) - Method in class bitronix.tm.journal.TransactionLogHeader
Set CURRENT_POSITION_HEADER.
setPreparedStatementCacheSize(int) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
Set the target maximum size of the prepared statement cache.
setPriority(int) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
setProperties(Properties) - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
setProperties(Object, Map) - Static method in class bitronix.tm.utils.PropertyUtils
Set a Map of direct or indirect properties on the target object.
setProperty(Object, String, Object) - Static method in class bitronix.tm.utils.PropertyUtils
Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
setProviderUrl(String) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set the Context.PROVIDER_URL of the JNDI Context used to fetch the XAConnectionFactory.
setResourceConfigurationFilename(String) - Method in class bitronix.tm.Configuration
Set the ResourceLoader configuration file name.
setRollbackOnly() - Method in class bitronix.tm.BitronixTransaction
 
setRollbackOnly() - Method in class bitronix.tm.BitronixTransactionManager
 
setRollbackOnly() - Method in class bitronix.tm.BitronixTransactionSynchronizationRegistry
 
setSavepoint() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
setSavepoint(String) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
setSecurityCredentials(String) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set the Context.SECURITY_CREDENTIALS of the JNDI Context used to fetch the XAConnectionFactory.
setSecurityPrincipal(String) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set the Context.SECURITY_PRINCIPAL of the JNDI Context used to fetch the XAConnectionFactory.
setServerId(String) - Method in class bitronix.tm.Configuration
Set the ASCII ID that must uniquely identify this TM instance.
setShareTransactionConnections(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Set whether connections in the ACCESSIBLE state can be shared within the context of a transaction.
setSkipCorruptedLogs(boolean) - Method in class bitronix.tm.Configuration
Set if corrupted logs should be skipped.
setState(byte) - Method in class bitronix.tm.gui.TransactionLogHeaderPanel
 
setState(byte) - Method in class bitronix.tm.journal.TransactionLogHeader
Set STATE_HEADER.
setState(int) - Method in class bitronix.tm.resource.common.AbstractXAStatefulHolder
 
setState(int) - Method in interface bitronix.tm.resource.common.XAStatefulHolder
Set the current resource state.
setStatus(int) - Method in class bitronix.tm.BitronixTransaction
 
setStatus(int, Set<String>) - Method in class bitronix.tm.BitronixTransaction
 
setTestConnections(boolean) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
setTestQuery(String) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
When set, the specified query will be executed on the connection acquired from the pool before being handed to the caller.
setTimeout(int) - Method in class bitronix.tm.internal.ThreadContext
Set this context's default timeout.
setTimestamp(long) - Method in class bitronix.tm.gui.TransactionLogHeaderPanel
 
setTimestamp(long) - Method in class bitronix.tm.journal.TransactionLogHeader
Set TIMESTAMP_HEADER.
setTimeToLive(long) - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
setTransaction(BitronixTransaction) - Method in class bitronix.tm.internal.ThreadContext
Link a transaction with this thead context.
setTransactionTimeout(int) - Method in class bitronix.tm.BitronixTransactionManager
 
setTransactionTimeout(int) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
setTransactionTimeout(int) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
setTransactionTimeoutDate(Date) - Method in class bitronix.tm.internal.XAResourceHolderState
 
setTwoPcOrderingPosition(int) - Method in class bitronix.tm.resource.common.ResourceBean
Set the position at which this resource should stand during 2PC commit.
setUniqueName(String) - Method in class bitronix.tm.resource.common.ResourceBean
Specify the resource unique name to be used to identify this resource during recovery.
setUrl(String) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
setUrlPkgPrefixes(String) - Method in class bitronix.tm.resource.jms.JndiXAConnectionFactory
Set the Context.URL_PKG_PREFIXES of the JNDI Context used to fetch the XAConnectionFactory.
setUser(String) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
setUser(String) - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
setUseTmJoin(boolean) - Method in class bitronix.tm.resource.common.ResourceBean
Specify if the transaction manager should try to join resources by calling XAResource.start(javax.transaction.xa.Xid, int) with XAResource.TMJOIN.
setValueAt(Object, int, int) - Method in class bitronix.tm.gui.PendingTransactionTableModel
 
setValueAt(Object, int, int) - Method in class bitronix.tm.gui.RawTransactionTableModel
 
setWarnAboutZeroResourceTransaction(boolean) - Method in class bitronix.tm.Configuration
Set if transactions executed without a single enlisted resource should result in a warning or not.
setXid(BitronixXid) - Method in class bitronix.tm.internal.XAResourceHolderState
 
shortToBytes(short) - Static method in class bitronix.tm.utils.Encoder
 
shrink() - Method in class bitronix.tm.resource.common.XAPool
 
shutdown() - Method in class bitronix.tm.BitronixTransactionManager
Shut down the transaction manager and release all resources held by it.
shutdown() - Method in class bitronix.tm.Configuration
 
shutdown() - Method in class bitronix.tm.journal.DiskJournal
 
shutdown() - Method in class bitronix.tm.journal.NullJournal
 
shutdown() - Method in class bitronix.tm.recovery.Recoverer
 
shutdown() - Method in class bitronix.tm.resource.ResourceLoader
 
shutdown() - Method in class bitronix.tm.timer.TaskScheduler
 
shutdown() - Method in class bitronix.tm.twopc.executor.AsyncExecutor
 
shutdown() - Method in interface bitronix.tm.twopc.executor.Executor
Shutdown the thead pool.
shutdown() - Method in class bitronix.tm.twopc.executor.SyncExecutor
 
shutdown() - Method in class bitronix.tm.utils.DefaultExceptionAnalyzer
 
shutdown() - Method in interface bitronix.tm.utils.Service
Shutdown the service and free all held resources.
size() - Method in class bitronix.tm.internal.XAResourceManager
Get the enlisted resources count.
size() - Method in class bitronix.tm.journal.DiskForceWaitQueue
 
size() - Method in class bitronix.tm.utils.Scheduler
 
StackTrace - Class in bitronix.tm.utils
A dummy Throwable used to build a call stack.
StackTrace() - Constructor for class bitronix.tm.utils.StackTrace
 
start(int) - Method in class bitronix.tm.internal.XAResourceHolderState
 
start(Xid, int) - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
start() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
start() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
start(Xid, int) - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
STARTED - Static variable in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
STARTED - Static variable in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
startRecovery() - Method in interface bitronix.tm.resource.common.XAResourceProducer
Prepare the recoverable XAResource producer for recovery.
startRecovery() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Prepare the recoverable XAResource producer for recovery.
startRecovery() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
startRecovery() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
STATE_ACCESSIBLE - Static variable in interface bitronix.tm.resource.common.XAStatefulHolder
The state in which the resource is when it out of the pool but accessible by the application.
STATE_CLOSED - Static variable in interface bitronix.tm.resource.common.XAStatefulHolder
The state in which the resource is when it is closed and unusable.
STATE_HEADER - Static variable in class bitronix.tm.journal.TransactionLogHeader
Position of the log file state in the header.
STATE_IN_POOL - Static variable in interface bitronix.tm.resource.common.XAStatefulHolder
The state in which the resource is when it is available in the pool.
STATE_NOT_ACCESSIBLE - Static variable in interface bitronix.tm.resource.common.XAStatefulHolder
The state in which the resource is when it out of the pool but not accessible by the application.
stateChanged(XAStatefulHolder, int, int) - Method in interface bitronix.tm.resource.common.StateChangeListener
Fired when the internal state of a XAStatefulHolder has changed.
stateChanged(XAStatefulHolder, int, int) - Method in class bitronix.tm.resource.common.XAPool
 
stateChanged(XAStatefulHolder, int, int) - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
stateChanged(XAStatefulHolder, int, int) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
StateChangeListener - Interface in bitronix.tm.resource.common
XAStatefulHolder state change listener interface.
stateChanging(XAStatefulHolder, int, int) - Method in interface bitronix.tm.resource.common.StateChangeListener
Fired before the internal state of a XAStatefulHolder has changed.
stateChanging(XAStatefulHolder, int, int) - Method in class bitronix.tm.resource.common.XAPool
 
stateChanging(XAStatefulHolder, int, int) - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
stateChanging(XAStatefulHolder, int, int) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
statusChanged(int, int) - Method in interface bitronix.tm.internal.TransactionStatusChangeListener
Fired when the status of a BitronixTransaction has changed.
stop() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
stop() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
submit(Job) - Method in class bitronix.tm.twopc.executor.AsyncExecutor
 
submit(Job) - Method in interface bitronix.tm.twopc.executor.Executor
Submit a job to be executed by the thread pool.
submit(Job) - Method in class bitronix.tm.twopc.executor.SyncExecutor
 
suspend() - Method in class bitronix.tm.BitronixTransactionManager
 
suspend() - Method in class bitronix.tm.internal.XAResourceManager
Suspend all enlisted resources from the current transaction context.
SyncExecutor - Class in bitronix.tm.twopc.executor
This implementation executes submitted jobs synchronously.
SyncExecutor() - Constructor for class bitronix.tm.twopc.executor.SyncExecutor
 

T

Task - Class in bitronix.tm.timer
Asbtract superclass of all timed tasks.
Task(Date, TaskScheduler) - Constructor for class bitronix.tm.timer.Task
 
TaskException - Exception in bitronix.tm.timer
Thrown when an error occurs during the execution of a task.
TaskException(String, Throwable) - Constructor for exception bitronix.tm.timer.TaskException
 
TaskScheduler - Class in bitronix.tm.timer
Timed tasks service.
TaskScheduler() - Constructor for class bitronix.tm.timer.TaskScheduler
 
ThreadContext - Class in bitronix.tm.internal
Transactional context of a thread.
ThreadContext() - Constructor for class bitronix.tm.internal.ThreadContext
 
timedOut() - Method in class bitronix.tm.BitronixTransaction
 
timeout() - Method in class bitronix.tm.BitronixTransaction
 
TIMESTAMP_HEADER - Static variable in class bitronix.tm.journal.TransactionLogHeader
Position of the timestamp in the header.
tLogs - Variable in class bitronix.tm.gui.TransactionTableModel
 
TopicSubscriberWrapper - Class in bitronix.tm.resource.jms
TopicSubscriber wrapper that adds XA enlistment semantics.
TopicSubscriberWrapper(TopicSubscriber, DualSessionWrapper, PoolingConnectionFactory) - Constructor for class bitronix.tm.resource.jms.TopicSubscriberWrapper
 
toString() - Method in class bitronix.tm.BitronixTransaction
 
toString() - Method in class bitronix.tm.BitronixTransactionManager
 
toString() - Method in class bitronix.tm.BitronixXid
Get a human-readable string representation of the XID.
toString() - Method in class bitronix.tm.Configuration
 
toString() - Method in class bitronix.tm.internal.ThreadContext
Return a human-readable representation.
toString() - Method in class bitronix.tm.internal.XAResourceHolderState
 
toString() - Method in class bitronix.tm.internal.XAResourceManager
Return a human-readable representation of this object.
toString() - Method in class bitronix.tm.jndi.BitronixContext
 
toString() - Method in class bitronix.tm.jndi.BitronixInitialContextFactory
 
toString() - Method in class bitronix.tm.journal.DiskForceBatcherThread
 
toString() - Method in class bitronix.tm.journal.NullJournal
 
toString() - Method in class bitronix.tm.journal.TransactionLogAppender
 
toString() - Method in class bitronix.tm.journal.TransactionLogHeader
Create human-readable String representation.
toString() - Method in class bitronix.tm.journal.TransactionLogRecord
 
toString() - Method in class bitronix.tm.resource.common.DeferredReleaseSynchronization
 
toString() - Method in class bitronix.tm.resource.common.XAPool
 
toString() - Method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
 
toString() - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
toString() - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
toString() - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
toString() - Method in class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
 
toString() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAConnection
 
toString() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXADataSource
 
toString() - Method in class bitronix.tm.resource.jdbc.lrc.LrcXAResource
 
toString() - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 
toString() - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
toString() - Method in class bitronix.tm.resource.jms.JmsConnectionHandle
 
toString() - Method in class bitronix.tm.resource.jms.JmsPooledConnection
 
toString() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnection
 
toString() - Method in class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
 
toString() - Method in class bitronix.tm.resource.jms.lrc.LrcXAResource
 
toString() - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
toString() - Method in class bitronix.tm.resource.jms.MessageConsumerWrapper
 
toString() - Method in class bitronix.tm.resource.jms.MessageProducerConsumerKey
 
toString() - Method in class bitronix.tm.resource.jms.MessageProducerWrapper
 
toString() - Method in class bitronix.tm.resource.jms.PoolingConnectionFactory
 
toString() - Method in class bitronix.tm.resource.jms.TopicSubscriberWrapper
 
toString() - Method in class bitronix.tm.timer.PoolShrinkingTask
 
toString() - Method in class bitronix.tm.timer.RecoveryTask
 
toString() - Method in class bitronix.tm.timer.TransactionTimeoutTask
 
toString() - Method in class bitronix.tm.utils.Scheduler
 
toString() - Method in class bitronix.tm.utils.Uid
 
totalPoolSize() - Method in class bitronix.tm.resource.common.XAPool
 
TransactionContextHelper - Class in bitronix.tm.resource.common
Helper class that contains static logic common accross all resource types.
TransactionContextHelper() - Constructor for class bitronix.tm.resource.common.TransactionContextHelper
 
TransactionLogAppender - Class in bitronix.tm.journal
Used to write TransactionLogRecord objects to a log file.
TransactionLogAppender(File, long) - Constructor for class bitronix.tm.journal.TransactionLogAppender
Create an appender that will write to specified file up to the specified maximum length.
TransactionLogCursor - Class in bitronix.tm.journal
Used to read TransactionLogRecord objects from a log file.
TransactionLogCursor(File) - Constructor for class bitronix.tm.journal.TransactionLogCursor
Create a TransactionLogCursor that will read from the specified file.
TransactionLogDialog - Class in bitronix.tm.gui
TransactionLogDialog(JFrame, TransactionLogRecord) - Constructor for class bitronix.tm.gui.TransactionLogDialog
 
TransactionLogHeader - Class in bitronix.tm.journal
Used to control a log file's header.
TransactionLogHeader(FileChannel, long) - Constructor for class bitronix.tm.journal.TransactionLogHeader
TransactionLogHeader are used to control headers of the specified RandomAccessFile.
TransactionLogHeaderPanel - Class in bitronix.tm.gui
TransactionLogHeaderPanel() - Constructor for class bitronix.tm.gui.TransactionLogHeaderPanel
 
TransactionLogRecord - Class in bitronix.tm.journal
Representation of a transaction log record on disk.
TransactionLogRecord(int, int, int, long, int, int, Uid, Set<String>, int) - Constructor for class bitronix.tm.journal.TransactionLogRecord
Use this constructor when restoring a log from the disk.
TransactionLogRecord(int, Uid, Set<String>) - Constructor for class bitronix.tm.journal.TransactionLogRecord
Create a new transaction log ready to be stored.
TransactionManagerServices - Class in bitronix.tm
Container for all BTM services.
TransactionManagerServices() - Constructor for class bitronix.tm.TransactionManagerServices
 
TransactionStatusChangeListener - Interface in bitronix.tm.internal
BitronixTransaction status change listener interface.
TransactionTableCellRenderer - Class in bitronix.tm.gui
TransactionTableCellRenderer() - Constructor for class bitronix.tm.gui.TransactionTableCellRenderer
 
TransactionTableModel - Class in bitronix.tm.gui
TransactionTableModel() - Constructor for class bitronix.tm.gui.TransactionTableModel
 
TransactionTableMouseListener - Class in bitronix.tm.gui
TransactionTableMouseListener(JFrame, JTable) - Constructor for class bitronix.tm.gui.TransactionTableMouseListener
 
TransactionTimeoutTask - Class in bitronix.tm.timer
This task is used to mark a transaction as timed-out.
TransactionTimeoutTask(BitronixTransaction, Date, TaskScheduler) - Constructor for class bitronix.tm.timer.TransactionTimeoutTask
 

U

Uid - Class in bitronix.tm.utils
A constant UID byte array container optimized for use with hashed collections.
Uid(byte[]) - Constructor for class bitronix.tm.utils.Uid
 
UidGenerator - Class in bitronix.tm.utils
Helper that offers UID generation (GTRID, XID, sequences) needed by the transaction manager.
UidGenerator() - Constructor for class bitronix.tm.utils.UidGenerator
 
unbind(Name) - Method in class bitronix.tm.jndi.BitronixContext
 
unbind(String) - Method in class bitronix.tm.jndi.BitronixContext
 
UNCLEAN_LOG_STATE - Static variable in class bitronix.tm.journal.TransactionLogHeader
State of the log file when it hasn't been closed properly or it is still open.
unregister(XAResourceProducer) - Static method in class bitronix.tm.resource.ResourceRegistrar
Unregister a previously registered XAResourceProducer.
unregister(String) - Static method in class bitronix.tm.utils.ManagementRegistrar
Unregister the management object with the specified name.
unregisterUncachedStatement(Statement) - Method in class bitronix.tm.resource.jdbc.JdbcPooledConnection
 
unregisterXAResource(String, XAResource) - Static method in class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
Unregister an XAResource of a cache from BTM.
unsubscribe(String) - Method in class bitronix.tm.resource.jms.DualSessionWrapper
 
unsubscribe(String) - Method in class bitronix.tm.resource.jms.lrc.LrcXASession
 
unwrap(Class<T>) - Method in class bitronix.tm.resource.jdbc.JdbcCallableStatementHandle
 
unwrap(Class<T>) - Method in class bitronix.tm.resource.jdbc.JdbcConnectionHandle
 
unwrap(Class<T>) - Method in class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
 
unwrap(Class<T>) - Method in class bitronix.tm.resource.jdbc.JdbcResultSetHandle
 
unwrap(Class<T>) - Method in class bitronix.tm.resource.jdbc.JdbcStatementHandle
 
unwrap(Class<T>) - Method in class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
 
unwrap(Class<T>) - Method in class bitronix.tm.resource.jdbc.PoolingDataSource
 

V

valueForPathChanged(TreePath, Object) - Method in class bitronix.tm.gui.ResourcesTreeModel
 
Version - Class in bitronix.tm
 
Version() - Constructor for class bitronix.tm.Version
 

W

waitFor(Object, long) - Method in class bitronix.tm.twopc.executor.AsyncExecutor
 
waitFor(Object, long) - Method in interface bitronix.tm.twopc.executor.Executor
Wait for the job represented by the future to terminate.
waitFor(Object, long) - Method in class bitronix.tm.twopc.executor.SyncExecutor
 
waitUntilNotContains(TransactionLogAppender) - Method in class bitronix.tm.journal.DiskForceWaitQueue
 
waitUntilNotEmpty() - Method in class bitronix.tm.journal.DiskForceWaitQueue
 
writeLog(TransactionLogRecord) - Method in class bitronix.tm.journal.TransactionLogAppender
Write a TransactionLogRecord to disk.

X

xaException - Variable in class bitronix.tm.twopc.executor.Job
 
XAPool - Class in bitronix.tm.resource.common
Generic XA pool.
XAPool(XAResourceProducer, ResourceBean) - Constructor for class bitronix.tm.resource.common.XAPool
 
XAResourceHolder - Interface in bitronix.tm.resource.common
XAResource wrappers must implement this interface.
XAResourceHolderState - Class in bitronix.tm.internal
XAResourceHolder state container.
XAResourceHolderState(XAResourceHolder, ResourceBean) - Constructor for class bitronix.tm.internal.XAResourceHolderState
 
XAResourceHolderState(XAResourceHolderState) - Constructor for class bitronix.tm.internal.XAResourceHolderState
 
XAResourceManager - Class in bitronix.tm.internal
Every BitronixTransaction contains an instance of this class that is used to register and keep track of resources enlisted in a transaction.
XAResourceManager(Uid) - Constructor for class bitronix.tm.internal.XAResourceManager
Create a resource manager for the specified GTRID.
XAResourceProducer - Interface in bitronix.tm.resource.common
A XAResourceProducer is a XAStatefulHolder factory.
XAStatefulHolder - Interface in bitronix.tm.resource.common
Any pooled connection class must implement the XAStatefulHolder interface.

A B C D E F G H I J L M N O P R S T U V W X

Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/constant-values.html0000644000175000017500000004012212215446622017342 0ustar tonytony Constant Field Values (Bitronix Transaction Manager :: Core 2.1.4 API)

Constant Field Values


Contents
bitronix.tm.*

bitronix.tm.BitronixXid
public static final int FORMAT_ID 1114926712

bitronix.tm.gui.RawTransactionTableModel
public static final int GTRID_COL 7

bitronix.tm.journal.TransactionLogAppender
public static final int END_RECORD 2020504642

bitronix.tm.journal.TransactionLogHeader
public static final byte CLEAN_LOG_STATE 0
public static final int CURRENT_POSITION_HEADER 13
public static final int FORMAT_ID_HEADER 0
public static final int HEADER_LENGTH 21
public static final int STATE_HEADER 12
public static final int TIMESTAMP_HEADER 4
public static final byte UNCLEAN_LOG_STATE -1

bitronix.tm.resource.common.XAStatefulHolder
public static final int STATE_ACCESSIBLE 2
public static final int STATE_CLOSED 0
public static final int STATE_IN_POOL 1
public static final int STATE_NOT_ACCESSIBLE 3

bitronix.tm.resource.jdbc.lrc.LrcXAResource
public static final int ENDED 2
public static final int NO_TX 0
public static final int PREPARED 3
public static final int STARTED 1

bitronix.tm.resource.jms.lrc.LrcXAResource
public static final int ENDED 2
public static final int NO_TX 0
public static final int PREPARED 3
public static final int STARTED 1



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/stylesheet.css0000644000175000017500000000255712215446622016243 0ustar tonytony/* Javadoc style sheet */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background-color: #FFFFFF; color:#000000 } /* Headings */ h1 { font-size: 145% } /* Table colors */ .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} btm-dist-2.1.4/doc/api/allclasses-frame.html0000644000175000017500000005004212215446622017434 0ustar tonytony All Classes (Bitronix Transaction Manager :: Core 2.1.4 API) All Classes
AbstractPhaseEngine
AbstractXAResourceHolder
AbstractXAStatefulHolder
AsyncExecutor
BaseProxyHandlerClass
BitronixContext
BitronixHeuristicCommitException
BitronixHeuristicMixedException
BitronixHeuristicRollbackException
BitronixInitialContextFactory
BitronixMultiSystemException
BitronixRollbackException
BitronixRollbackSystemException
BitronixRuntimeException
BitronixSystemException
BitronixTransaction
BitronixTransactionManager
BitronixTransactionManagerObjectFactory
BitronixTransactionMBean
BitronixTransactionSynchronizationRegistry
BitronixTransactionSynchronizationRegistryObjectFactory
BitronixUserTransactionObjectFactory
BitronixXAException
BitronixXid
ClassLoaderUtils
CollectionUtils
Committer
Configuration
ConnectionCustomizer
Console
CorruptedTransactionLogException
CryptoEngine
DanglingTransaction
Decoder
DefaultExceptionAnalyzer
DeferredReleaseSynchronization
DiskForceBatcherThread
DiskForceWaitQueue
DiskJournal
DualSessionWrapper
DuplicatedGtridTableModel
EhCacheXAResourceHolder
EhCacheXAResourceProducer
Encoder
ExceptionAnalyzer
ExceptionUtils
Executor
IncrementalRecoverer
InitializationException
JdbcCallableStatementHandle
JdbcConnectionHandle
JdbcPooledConnection
JdbcPooledConnectionMBean
JdbcPreparedStatementHandle
JdbcResultSetHandle
JdbcStatementHandle
JdbcUncachedPreparedStatementHandle
JmsConnectionHandle
JmsPooledConnection
JmsPooledConnectionMBean
JndiXAConnectionFactory
Job
Journal
LrcConnectionHandle
LrcXAConnection
LrcXAConnection
LrcXAConnectionFactory
LrcXADataSource
LrcXAResource
LrcXAResource
LrcXASession
LruEvictionListener
LruStatementCache
ManagementRegistrar
MessageConsumerWrapper
MessageProducerConsumerKey
MessageProducerWrapper
MonotonicClock
NullJournal
PendingTransactionTableModel
PhaseException
PoolingConnectionFactory
PoolingConnectionFactoryMBean
PoolingDataSource
PoolingDataSourceMBean
PoolShrinkingTask
Preparer
PropertyException
PropertyUtils
RawTransactionTableModel
Recoverer
RecovererMBean
RecoveryException
RecoveryHelper
RecoveryTask
RecoveryXAResourceHolder
ResourceBean
ResourceConfigurationException
ResourceLoader
ResourceObjectFactory
ResourceRegistrar
ResourcesPanel
ResourcesTreeModel
Rollbacker
Scheduler
Service
StackTrace
StateChangeListener
SyncExecutor
Task
TaskException
TaskScheduler
ThreadContext
TopicSubscriberWrapper
TransactionContextHelper
TransactionLogAppender
TransactionLogCursor
TransactionLogDialog
TransactionLogHeader
TransactionLogHeaderPanel
TransactionLogRecord
TransactionManagerServices
TransactionStatusChangeListener
TransactionTableCellRenderer
TransactionTableModel
TransactionTableMouseListener
TransactionTimeoutTask
Uid
UidGenerator
Version
XAPool
XAResourceHolder
XAResourceHolderState
XAResourceManager
XAResourceProducer
XAStatefulHolder
btm-dist-2.1.4/doc/api/bitronix/0000755000175000017500000000000012215446620015163 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/0000755000175000017500000000000012215446622015605 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/TransactionManagerServices.html0000644000175000017500000005401112215446620023756 0ustar tonytony TransactionManagerServices (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class TransactionManagerServices

java.lang.Object
  extended by bitronix.tm.TransactionManagerServices

public class TransactionManagerServices
extends Object

Container for all BTM services.

The different services available are: BitronixTransactionManager, BitronixTransactionSynchronizationRegistry Configuration, Journal, TaskScheduler, ResourceLoader, Recoverer and Executor. They are used in all places of the TM so they must be globally reachable.

Author:
lorban

Constructor Summary
TransactionManagerServices()
           
 
Method Summary
protected static void clear()
          Clear services references.
static Configuration getConfiguration()
          Create the configuration of all the components of the transaction manager.
static ExceptionAnalyzer getExceptionAnalyzer()
          Create the exception analyzer.
static Executor getExecutor()
          Create the 2PC executor.
static Journal getJournal()
          Create the transactions journal.
static Recoverer getRecoverer()
          Create the transaction recoverer.
static ResourceLoader getResourceLoader()
          Create the resource loader.
static TaskScheduler getTaskScheduler()
          Create the task scheduler.
static BitronixTransactionManager getTransactionManager()
          Create an initialized transaction manager.
static BitronixTransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
          Create the JTA 1.1 TransactionSynchronizationRegistry.
static boolean isTaskSchedulerRunning()
          Check if the task scheduler has started.
static boolean isTransactionManagerRunning()
          Check if the transaction manager has started.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionManagerServices

public TransactionManagerServices()
Method Detail

getTransactionManager

public static BitronixTransactionManager getTransactionManager()
Create an initialized transaction manager.

Returns:
the transaction manager.

getTransactionSynchronizationRegistry

public static BitronixTransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
Create the JTA 1.1 TransactionSynchronizationRegistry.

Returns:
the TransactionSynchronizationRegistry.

getConfiguration

public static Configuration getConfiguration()
Create the configuration of all the components of the transaction manager.

Returns:
the global configuration.

getJournal

public static Journal getJournal()
Create the transactions journal.

Returns:
the transactions journal.

getTaskScheduler

public static TaskScheduler getTaskScheduler()
Create the task scheduler.

Returns:
the task scheduler.

getResourceLoader

public static ResourceLoader getResourceLoader()
Create the resource loader.

Returns:
the resource loader.

getRecoverer

public static Recoverer getRecoverer()
Create the transaction recoverer.

Returns:
the transaction recoverer.

getExecutor

public static Executor getExecutor()
Create the 2PC executor.

Returns:
the 2PC executor.

getExceptionAnalyzer

public static ExceptionAnalyzer getExceptionAnalyzer()
Create the exception analyzer.

Returns:
the exception analyzer.

isTransactionManagerRunning

public static boolean isTransactionManagerRunning()
Check if the transaction manager has started.

Returns:
true if the transaction manager has started.

isTaskSchedulerRunning

public static boolean isTaskSchedulerRunning()
Check if the task scheduler has started.

Returns:
true if the task scheduler has started.

clear

protected static void clear()
Clear services references. Called at the end of the shutdown procedure.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/0000755000175000017500000000000012215446622016725 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/timer/package-frame.html0000644000175000017500000000324412215446622022301 0ustar tonytony bitronix.tm.timer (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.timer
Classes 
PoolShrinkingTask
RecoveryTask
Task
TaskScheduler
TransactionTimeoutTask
Exceptions 
TaskException
btm-dist-2.1.4/doc/api/bitronix/tm/timer/TaskScheduler.html0000644000175000017500000007743112215446622022370 0ustar tonytony TaskScheduler (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.timer
Class TaskScheduler

java.lang.Object
  extended by java.lang.Thread
      extended by bitronix.tm.timer.TaskScheduler
All Implemented Interfaces:
Service, Runnable

public class TaskScheduler
extends Thread
implements Service

Timed tasks service.

Author:
lorban

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TaskScheduler()
           
 
Method Summary
 void cancelPoolShrinking(XAPool xaPool)
          Cancel the task that will tell a XA pool to close idle connections.
 void cancelRecovery(Recoverer recoverer)
          Cancel the task that will run background recovery at the specified date.
 void cancelTransactionTimeout(BitronixTransaction transaction)
          Cancel the task that will mark the transaction as timed out at the specified date.
 int countTasksQueued()
          Get the amount of tasks currently queued.
 void run()
           
 void schedulePoolShrinking(XAPool xaPool)
          Schedule a task that will tell a XA pool to close idle connections.
 void scheduleRecovery(Recoverer recoverer, Date executionTime)
          Schedule a task that will run background recovery at the specified date.
 void scheduleTransactionTimeout(BitronixTransaction transaction, Date executionTime)
          Schedule a task that will mark the transaction as timed out at the specified date.
 void shutdown()
          Shutdown the service and free all held resources.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskScheduler

public TaskScheduler()
Method Detail

countTasksQueued

public int countTasksQueued()
Get the amount of tasks currently queued.

Returns:
the amount of tasks currently queued.

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service

scheduleTransactionTimeout

public void scheduleTransactionTimeout(BitronixTransaction transaction,
                                       Date executionTime)
Schedule a task that will mark the transaction as timed out at the specified date. If this method is called with the same transaction multiple times, the previous timeout date is dropped and replaced by the new one.

Parameters:
transaction - the transaction to mark as timeout.
executionTime - the date at which the transaction must be marked.

cancelTransactionTimeout

public void cancelTransactionTimeout(BitronixTransaction transaction)
Cancel the task that will mark the transaction as timed out at the specified date.

Parameters:
transaction - the transaction to mark as timeout.

scheduleRecovery

public void scheduleRecovery(Recoverer recoverer,
                             Date executionTime)
Schedule a task that will run background recovery at the specified date.

Parameters:
recoverer - the recovery implementation to use.
executionTime - the date at which the transaction must be marked.

cancelRecovery

public void cancelRecovery(Recoverer recoverer)
Cancel the task that will run background recovery at the specified date.

Parameters:
recoverer - the recovery implementation to use.

schedulePoolShrinking

public void schedulePoolShrinking(XAPool xaPool)
Schedule a task that will tell a XA pool to close idle connections. The execution time will be provided by the XA pool itself via the XAPool.getNextShrinkDate().

Parameters:
xaPool - the XA pool to notify.

cancelPoolShrinking

public void cancelPoolShrinking(XAPool xaPool)
Cancel the task that will tell a XA pool to close idle connections.

Parameters:
xaPool - the XA pool to notify.

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/TransactionTimeoutTask.html0000644000175000017500000004034112215446622024274 0ustar tonytony TransactionTimeoutTask (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.timer
Class TransactionTimeoutTask

java.lang.Object
  extended by bitronix.tm.timer.Task
      extended by bitronix.tm.timer.TransactionTimeoutTask
All Implemented Interfaces:
Comparable<Task>

public class TransactionTimeoutTask
extends Task

This task is used to mark a transaction as timed-out.

Author:
lorban

Constructor Summary
TransactionTimeoutTask(BitronixTransaction transaction, Date executionTime, TaskScheduler scheduler)
           
 
Method Summary
 void execute()
           
 Object getObject()
           
 String toString()
           
 
Methods inherited from class bitronix.tm.timer.Task
compareTo, getExecutionTime, getTaskScheduler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionTimeoutTask

public TransactionTimeoutTask(BitronixTransaction transaction,
                              Date executionTime,
                              TaskScheduler scheduler)
Method Detail

getObject

public Object getObject()
Specified by:
getObject in class Task

execute

public void execute()
             throws TaskException
Specified by:
execute in class Task
Throws:
TaskException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/package-tree.html0000644000175000017500000002023612215446622022146 0ustar tonytony bitronix.tm.timer Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.timer

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/package-use.html0000644000175000017500000002005712215446622022004 0ustar tonytony Uses of Package bitronix.tm.timer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.timer

Packages that use bitronix.tm.timer
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.timer Timed tasks scheduler. 
 

Classes in bitronix.tm.timer used by bitronix.tm
TaskScheduler
          Timed tasks service.
 

Classes in bitronix.tm.timer used by bitronix.tm.timer
Task
          Asbtract superclass of all timed tasks.
TaskException
          Thrown when an error occurs during the execution of a task.
TaskScheduler
          Timed tasks service.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/RecoveryTask.html0000644000175000017500000004024512215446622022241 0ustar tonytony RecoveryTask (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.timer
Class RecoveryTask

java.lang.Object
  extended by bitronix.tm.timer.Task
      extended by bitronix.tm.timer.RecoveryTask
All Implemented Interfaces:
Comparable<Task>

public class RecoveryTask
extends Task

This task is used to run the background recovery.

Author:
lorban

Constructor Summary
RecoveryTask(Recoverer recoverer, Date executionTime, TaskScheduler scheduler)
           
 
Method Summary
 void execute()
           
 Object getObject()
           
 String toString()
           
 
Methods inherited from class bitronix.tm.timer.Task
compareTo, getExecutionTime, getTaskScheduler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecoveryTask

public RecoveryTask(Recoverer recoverer,
                    Date executionTime,
                    TaskScheduler scheduler)
Method Detail

getObject

public Object getObject()
Specified by:
getObject in class Task

execute

public void execute()
             throws TaskException
Specified by:
execute in class Task
Throws:
TaskException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/class-use/0000755000175000017500000000000012215446622020624 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/timer/class-use/TaskScheduler.html0000644000175000017500000003066012215446622024260 0ustar tonytony Uses of Class bitronix.tm.timer.TaskScheduler (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.timer.TaskScheduler

Packages that use TaskScheduler
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.timer Timed tasks scheduler. 
 

Uses of TaskScheduler in bitronix.tm
 

Methods in bitronix.tm that return TaskScheduler
static TaskScheduler TransactionManagerServices.getTaskScheduler()
          Create the task scheduler.
 

Uses of TaskScheduler in bitronix.tm.timer
 

Methods in bitronix.tm.timer that return TaskScheduler
protected  TaskScheduler Task.getTaskScheduler()
           
 

Constructors in bitronix.tm.timer with parameters of type TaskScheduler
PoolShrinkingTask(XAPool xaPool, Date executionTime, TaskScheduler scheduler)
           
RecoveryTask(Recoverer recoverer, Date executionTime, TaskScheduler scheduler)
           
Task(Date executionTime, TaskScheduler scheduler)
           
TransactionTimeoutTask(BitronixTransaction transaction, Date executionTime, TaskScheduler scheduler)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/class-use/TransactionTimeoutTask.html0000644000175000017500000001377412215446622026205 0ustar tonytony Uses of Class bitronix.tm.timer.TransactionTimeoutTask (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.timer.TransactionTimeoutTask

No usage of bitronix.tm.timer.TransactionTimeoutTask



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/class-use/RecoveryTask.html0000644000175000017500000001363012215446622024136 0ustar tonytony Uses of Class bitronix.tm.timer.RecoveryTask (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.timer.RecoveryTask

No usage of bitronix.tm.timer.RecoveryTask



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/class-use/Task.html0000644000175000017500000002221112215446622022412 0ustar tonytony Uses of Class bitronix.tm.timer.Task (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.timer.Task

Packages that use Task
bitronix.tm.timer Timed tasks scheduler. 
 

Uses of Task in bitronix.tm.timer
 

Subclasses of Task in bitronix.tm.timer
 class PoolShrinkingTask
          This task is used to notify a XA pool to close idle connections.
 class RecoveryTask
          This task is used to run the background recovery.
 class TransactionTimeoutTask
          This task is used to mark a transaction as timed-out.
 

Methods in bitronix.tm.timer with parameters of type Task
 int Task.compareTo(Task otherTask)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/class-use/TaskException.html0000644000175000017500000002112312215446622024272 0ustar tonytony Uses of Class bitronix.tm.timer.TaskException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.timer.TaskException

Packages that use TaskException
bitronix.tm.timer Timed tasks scheduler. 
 

Uses of TaskException in bitronix.tm.timer
 

Methods in bitronix.tm.timer that throw TaskException
 void TransactionTimeoutTask.execute()
           
abstract  void Task.execute()
           
 void RecoveryTask.execute()
           
 void PoolShrinkingTask.execute()
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/class-use/PoolShrinkingTask.html0000644000175000017500000001371212215446622025127 0ustar tonytony Uses of Class bitronix.tm.timer.PoolShrinkingTask (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.timer.PoolShrinkingTask

No usage of bitronix.tm.timer.PoolShrinkingTask



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/package-summary.html0000644000175000017500000002001712215446622022701 0ustar tonytony bitronix.tm.timer (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.timer

Timed tasks scheduler.

See:
          Description

Class Summary
PoolShrinkingTask This task is used to notify a XA pool to close idle connections.
RecoveryTask This task is used to run the background recovery.
Task Asbtract superclass of all timed tasks.
TaskScheduler Timed tasks service.
TransactionTimeoutTask This task is used to mark a transaction as timed-out.
 

Exception Summary
TaskException Thrown when an error occurs during the execution of a task.
 

Package bitronix.tm.timer Description

Timed tasks scheduler.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/Task.html0000644000175000017500000004164112215446622020523 0ustar tonytony Task (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.timer
Class Task

java.lang.Object
  extended by bitronix.tm.timer.Task
All Implemented Interfaces:
Comparable<Task>
Direct Known Subclasses:
PoolShrinkingTask, RecoveryTask, TransactionTimeoutTask

public abstract class Task
extends Object
implements Comparable<Task>

Asbtract superclass of all timed tasks.

Author:
lorban

Constructor Summary
protected Task(Date executionTime, TaskScheduler scheduler)
           
 
Method Summary
 int compareTo(Task otherTask)
           
abstract  void execute()
           
 Date getExecutionTime()
           
abstract  Object getObject()
           
protected  TaskScheduler getTaskScheduler()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Task

protected Task(Date executionTime,
               TaskScheduler scheduler)
Method Detail

getExecutionTime

public Date getExecutionTime()

getTaskScheduler

protected TaskScheduler getTaskScheduler()

compareTo

public int compareTo(Task otherTask)
Specified by:
compareTo in interface Comparable<Task>

getObject

public abstract Object getObject()

execute

public abstract void execute()
                      throws TaskException
Throws:
TaskException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/TaskException.html0000644000175000017500000003516312215446622022404 0ustar tonytony TaskException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.timer
Class TaskException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by bitronix.tm.timer.TaskException
All Implemented Interfaces:
Serializable

public class TaskException
extends Exception

Thrown when an error occurs during the execution of a task.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
TaskException(String message, Throwable cause)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskException

public TaskException(String message,
                     Throwable cause)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/timer/PoolShrinkingTask.html0000644000175000017500000004017212215446622023230 0ustar tonytony PoolShrinkingTask (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.timer
Class PoolShrinkingTask

java.lang.Object
  extended by bitronix.tm.timer.Task
      extended by bitronix.tm.timer.PoolShrinkingTask
All Implemented Interfaces:
Comparable<Task>

public class PoolShrinkingTask
extends Task

This task is used to notify a XA pool to close idle connections.

Author:
lorban

Constructor Summary
PoolShrinkingTask(XAPool xaPool, Date executionTime, TaskScheduler scheduler)
           
 
Method Summary
 void execute()
           
 Object getObject()
           
 String toString()
           
 
Methods inherited from class bitronix.tm.timer.Task
compareTo, getExecutionTime, getTaskScheduler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PoolShrinkingTask

public PoolShrinkingTask(XAPool xaPool,
                         Date executionTime,
                         TaskScheduler scheduler)
Method Detail

getObject

public Object getObject()
Specified by:
getObject in class Task

execute

public void execute()
             throws TaskException
Specified by:
execute in class Task
Throws:
TaskException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/package-frame.html0000644000175000017500000000463412215446622021165 0ustar tonytony bitronix.tm (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm
Interfaces 
BitronixTransactionMBean
Classes 
BitronixTransaction
BitronixTransactionManager
BitronixTransactionManagerObjectFactory
BitronixTransactionSynchronizationRegistry
BitronixTransactionSynchronizationRegistryObjectFactory
BitronixUserTransactionObjectFactory
BitronixXid
Configuration
TransactionManagerServices
Version
btm-dist-2.1.4/doc/api/bitronix/tm/BitronixUserTransactionObjectFactory.html0000644000175000017500000003147112215446620026021 0ustar tonytony BitronixUserTransactionObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class BitronixUserTransactionObjectFactory

java.lang.Object
  extended by bitronix.tm.BitronixTransactionManagerObjectFactory
      extended by bitronix.tm.BitronixUserTransactionObjectFactory
All Implemented Interfaces:
ObjectFactory

public class BitronixUserTransactionObjectFactory
extends BitronixTransactionManagerObjectFactory

BitronixTransactionManager object factory for JNDI references. This class does no more than BitronixTransactionManagerObjectFactory, it only exists for clarity.

Author:
lorban

Constructor Summary
BitronixUserTransactionObjectFactory()
           
 
Method Summary
 
Methods inherited from class bitronix.tm.BitronixTransactionManagerObjectFactory
getObjectInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitronixUserTransactionObjectFactory

public BitronixUserTransactionObjectFactory()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/BitronixTransactionSynchronizationRegistryObjectFactory.html0000644000175000017500000004033412215446620032033 0ustar tonytony BitronixTransactionSynchronizationRegistryObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class BitronixTransactionSynchronizationRegistryObjectFactory

java.lang.Object
  extended by bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory
All Implemented Interfaces:
ObjectFactory

public class BitronixTransactionSynchronizationRegistryObjectFactory
extends Object
implements ObjectFactory

BitronixTransactionSynchronizationRegistry object factory for JNDI references.

Author:
lorban

Constructor Summary
BitronixTransactionSynchronizationRegistryObjectFactory()
           
 
Method Summary
 Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
          Since there can be only one synchronization registry per VM instance, this method always returns a reference to the unique BitronixTransactionSynchronizationRegistry object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitronixTransactionSynchronizationRegistryObjectFactory

public BitronixTransactionSynchronizationRegistryObjectFactory()
Method Detail

getObjectInstance

public Object getObjectInstance(Object obj,
                                Name name,
                                Context nameCtx,
                                Hashtable<?,?> environment)
                         throws Exception
Since there can be only one synchronization registry per VM instance, this method always returns a reference to the unique BitronixTransactionSynchronizationRegistry object.

Specified by:
getObjectInstance in interface ObjectFactory
Returns:
the unique synchronization registry instance.
Throws:
Exception
See Also:
BitronixTransactionSynchronizationRegistry


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/0000755000175000017500000000000012215446622017421 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/internal/TransactionStatusChangeListener.html0000644000175000017500000002262612215446620026622 0ustar tonytony TransactionStatusChangeListener (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Interface TransactionStatusChangeListener


public interface TransactionStatusChangeListener

BitronixTransaction status change listener interface.

Author:
lorban

Method Summary
 void statusChanged(int oldStatus, int newStatus)
          Fired when the status of a BitronixTransaction has changed.
 

Method Detail

statusChanged

void statusChanged(int oldStatus,
                   int newStatus)
Fired when the status of a BitronixTransaction has changed.

Parameters:
oldStatus - the old status of the BitronixTransaction.
newStatus - the new status of the BitronixTransaction.
See Also:
Status constant values.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixRollbackException.html0000644000175000017500000004051512215446620025441 0ustar tonytony BitronixRollbackException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixRollbackException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.RollbackException
              extended by bitronix.tm.internal.BitronixRollbackException
All Implemented Interfaces:
Serializable

public class BitronixRollbackException
extends RollbackException

Subclass of RollbackException supporting nested Throwables.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
BitronixRollbackException(String string)
           
BitronixRollbackException(String string, Throwable t)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixRollbackException

public BitronixRollbackException(String string)

BitronixRollbackException

public BitronixRollbackException(String string,
                                 Throwable t)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/package-frame.html0000644000175000017500000000567512215446622023007 0ustar tonytony bitronix.tm.internal (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.internal
Interfaces 
TransactionStatusChangeListener
Classes 
ThreadContext
XAResourceHolderState
XAResourceManager
Exceptions 
BitronixHeuristicCommitException
BitronixHeuristicMixedException
BitronixHeuristicRollbackException
BitronixMultiSystemException
BitronixRollbackException
BitronixRollbackSystemException
BitronixRuntimeException
BitronixSystemException
BitronixXAException
btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixHeuristicMixedException.html0000644000175000017500000004103312215446620026632 0ustar tonytony BitronixHeuristicMixedException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixHeuristicMixedException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.HeuristicMixedException
              extended by bitronix.tm.internal.BitronixHeuristicMixedException
All Implemented Interfaces:
Serializable

public class BitronixHeuristicMixedException
extends HeuristicMixedException

Subclass of HeuristicMixedException supporting nested Throwables.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
BitronixHeuristicMixedException(String string)
           
BitronixHeuristicMixedException(String string, Throwable t)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixHeuristicMixedException

public BitronixHeuristicMixedException(String string)

BitronixHeuristicMixedException

public BitronixHeuristicMixedException(String string,
                                       Throwable t)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixHeuristicCommitException.html0000644000175000017500000004046712215446620027026 0ustar tonytony BitronixHeuristicCommitException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixHeuristicCommitException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.HeuristicCommitException
              extended by bitronix.tm.internal.BitronixHeuristicCommitException
All Implemented Interfaces:
Serializable

public class BitronixHeuristicCommitException
extends HeuristicCommitException

Subclass of HeuristicCommitException supporting nested Throwables.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
BitronixHeuristicCommitException(String string)
           
BitronixHeuristicCommitException(String string, Throwable t)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixHeuristicCommitException

public BitronixHeuristicCommitException(String string)

BitronixHeuristicCommitException

public BitronixHeuristicCommitException(String string,
                                        Throwable t)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixSystemException.html0000644000175000017500000004431512215446620025176 0ustar tonytony BitronixSystemException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixSystemException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.SystemException
              extended by bitronix.tm.internal.BitronixSystemException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BitronixMultiSystemException, BitronixRollbackSystemException

public class BitronixSystemException
extends SystemException

Subclass of SystemException supporting nested Throwables.

Author:
lorban
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.transaction.SystemException
errorCode
 
Constructor Summary
BitronixSystemException(int errorCode)
           
BitronixSystemException(String string)
           
BitronixSystemException(String string, Throwable t)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixSystemException

public BitronixSystemException(int errorCode)

BitronixSystemException

public BitronixSystemException(String string)

BitronixSystemException

public BitronixSystemException(String string,
                               Throwable t)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/package-tree.html0000644000175000017500000002512012215446622022637 0ustar tonytony bitronix.tm.internal Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.internal

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/package-use.html0000644000175000017500000005062612215446622022505 0ustar tonytony Uses of Package bitronix.tm.internal (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.internal

Packages that use bitronix.tm.internal
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.internal Internal implementation details. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
bitronix.tm.twopc Two-phase commit logic. 
bitronix.tm.twopc.executor Two-phase commit commands executors. 
bitronix.tm.utils Misc utility classes. 
 

Classes in bitronix.tm.internal used by bitronix.tm
BitronixSystemException
          Subclass of SystemException supporting nested Throwables.
TransactionStatusChangeListener
          BitronixTransaction status change listener interface.
XAResourceManager
          Every BitronixTransaction contains an instance of this class that is used to register and keep track of resources enlisted in a transaction.
 

Classes in bitronix.tm.internal used by bitronix.tm.internal
BitronixSystemException
          Subclass of SystemException supporting nested Throwables.
XAResourceHolderState
          XAResourceHolder state container.
 

Classes in bitronix.tm.internal used by bitronix.tm.recovery
XAResourceHolderState
          XAResourceHolder state container.
 

Classes in bitronix.tm.internal used by bitronix.tm.resource.common
BitronixSystemException
          Subclass of SystemException supporting nested Throwables.
XAResourceHolderState
          XAResourceHolder state container.
 

Classes in bitronix.tm.internal used by bitronix.tm.resource.ehcache
XAResourceHolderState
          XAResourceHolder state container.
 

Classes in bitronix.tm.internal used by bitronix.tm.resource.jdbc
XAResourceHolderState
          XAResourceHolder state container.
 

Classes in bitronix.tm.internal used by bitronix.tm.resource.jms
XAResourceHolderState
          XAResourceHolder state container.
 

Classes in bitronix.tm.internal used by bitronix.tm.twopc
BitronixRollbackException
          Subclass of RollbackException supporting nested Throwables.
BitronixSystemException
          Subclass of SystemException supporting nested Throwables.
XAResourceHolderState
          XAResourceHolder state container.
XAResourceManager
          Every BitronixTransaction contains an instance of this class that is used to register and keep track of resources enlisted in a transaction.
 

Classes in bitronix.tm.internal used by bitronix.tm.twopc.executor
XAResourceHolderState
          XAResourceHolder state container.
 

Classes in bitronix.tm.internal used by bitronix.tm.utils
XAResourceHolderState
          XAResourceHolder state container.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixRollbackSystemException.html0000644000175000017500000004173312215446620026651 0ustar tonytony BitronixRollbackSystemException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixRollbackSystemException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.SystemException
              extended by bitronix.tm.internal.BitronixSystemException
                  extended by bitronix.tm.internal.BitronixRollbackSystemException
All Implemented Interfaces:
Serializable

public class BitronixRollbackSystemException
extends BitronixSystemException

Subclass of SystemException indicating a rollback must be performed. This exception is used to handle unilateral rollback of resources during delistement.

Author:
lorban
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.transaction.SystemException
errorCode
 
Constructor Summary
BitronixRollbackSystemException(String string, Throwable t)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixRollbackSystemException

public BitronixRollbackSystemException(String string,
                                       Throwable t)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixHeuristicRollbackException.html0000644000175000017500000004115512215446620027322 0ustar tonytony BitronixHeuristicRollbackException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixHeuristicRollbackException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.HeuristicRollbackException
              extended by bitronix.tm.internal.BitronixHeuristicRollbackException
All Implemented Interfaces:
Serializable

public class BitronixHeuristicRollbackException
extends HeuristicRollbackException

Subclass of HeuristicRollbackException supporting nested Throwables.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
BitronixHeuristicRollbackException(String string)
           
BitronixHeuristicRollbackException(String string, Throwable t)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixHeuristicRollbackException

public BitronixHeuristicRollbackException(String string)

BitronixHeuristicRollbackException

public BitronixHeuristicRollbackException(String string,
                                          Throwable t)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/0000755000175000017500000000000012215446622021320 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/TransactionStatusChangeListener.html0000644000175000017500000002024012215446622030511 0ustar tonytony Uses of Interface bitronix.tm.internal.TransactionStatusChangeListener (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.internal.TransactionStatusChangeListener

Packages that use TransactionStatusChangeListener
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of TransactionStatusChangeListener in bitronix.tm
 

Methods in bitronix.tm with parameters of type TransactionStatusChangeListener
 void BitronixTransaction.addTransactionStatusChangeListener(TransactionStatusChangeListener listener)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixRollbackException.html0000644000175000017500000002037012215446622027337 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixRollbackException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixRollbackException

Packages that use BitronixRollbackException
bitronix.tm.twopc Two-phase commit logic. 
 

Uses of BitronixRollbackException in bitronix.tm.twopc
 

Methods in bitronix.tm.twopc that throw BitronixRollbackException
 void Committer.commit(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Execute phase 2 commit.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixHeuristicMixedException.html0000644000175000017500000001416412215446622030540 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixHeuristicMixedException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixHeuristicMixedException

No usage of bitronix.tm.internal.BitronixHeuristicMixedException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixHeuristicCommitException.html0000644000175000017500000001417612215446622030725 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixHeuristicCommitException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixHeuristicCommitException

No usage of bitronix.tm.internal.BitronixHeuristicCommitException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixSystemException.html0000644000175000017500000005025712215446622027101 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixSystemException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixSystemException

Packages that use BitronixSystemException
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.internal Internal implementation details. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.twopc Two-phase commit logic. 
 

Uses of BitronixSystemException in bitronix.tm
 

Methods in bitronix.tm that throw BitronixSystemException
 void BitronixTransaction.setStatus(int status)
           
 void BitronixTransaction.setStatus(int status, Set<String> uniqueNames)
           
 void BitronixTransaction.timeout()
           
 

Uses of BitronixSystemException in bitronix.tm.internal
 

Subclasses of BitronixSystemException in bitronix.tm.internal
 class BitronixMultiSystemException
          Subclass of SystemException supporting nested Throwables.
 class BitronixRollbackSystemException
          Subclass of SystemException indicating a rollback must be performed.
 

Methods in bitronix.tm.internal that throw BitronixSystemException
 boolean XAResourceManager.delist(XAResourceHolderState xaResourceHolderState, int flag)
          Delist the specified XAResourceHolderState.
 void XAResourceManager.enlist(XAResourceHolderState xaResourceHolderState)
          Enlist the specified XAResourceHolderState.
 XAResourceHolderState XAResourceManager.findXAResourceHolderState(XAResource xaResource)
          Look if an XAResource has already been enlisted.
 void XAResourceHolderState.setXid(BitronixXid xid)
           
 

Uses of BitronixSystemException in bitronix.tm.resource.common
 

Methods in bitronix.tm.resource.common that throw BitronixSystemException
static void TransactionContextHelper.requeue(XAStatefulHolder xaStatefulHolder, ResourceBean bean)
          Switch the XAStatefulHolder's state appropriately after the acquired resource handle has been closed.
 

Uses of BitronixSystemException in bitronix.tm.twopc
 

Methods in bitronix.tm.twopc that throw BitronixSystemException
 void Committer.commit(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Execute phase 2 commit.
 List<XAResourceHolderState> Preparer.prepare(BitronixTransaction transaction)
          Execute phase 1 prepare.
 void Rollbacker.rollback(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Rollback the current XA transaction.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixRollbackSystemException.html0000644000175000017500000001416412215446622030550 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixRollbackSystemException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixRollbackSystemException

No usage of bitronix.tm.internal.BitronixRollbackSystemException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixHeuristicRollbackException.html0000644000175000017500000001422212215446622031216 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixHeuristicRollbackException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixHeuristicRollbackException

No usage of bitronix.tm.internal.BitronixHeuristicRollbackException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixMultiSystemException.html0000644000175000017500000001412612215446622030107 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixMultiSystemException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixMultiSystemException

No usage of bitronix.tm.internal.BitronixMultiSystemException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/ThreadContext.html0000644000175000017500000001370012215446622024763 0ustar tonytony Uses of Class bitronix.tm.internal.ThreadContext (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.ThreadContext

No usage of bitronix.tm.internal.ThreadContext



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/XAResourceManager.html0000644000175000017500000002267312215446622025533 0ustar tonytony Uses of Class bitronix.tm.internal.XAResourceManager (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.XAResourceManager

Packages that use XAResourceManager
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.twopc Two-phase commit logic. 
 

Uses of XAResourceManager in bitronix.tm
 

Methods in bitronix.tm that return XAResourceManager
 XAResourceManager BitronixTransaction.getResourceManager()
           
 

Uses of XAResourceManager in bitronix.tm.twopc
 

Methods in bitronix.tm.twopc with parameters of type XAResourceManager
protected  void AbstractPhaseEngine.executePhase(XAResourceManager resourceManager, boolean reverse)
          Execute the phase.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/XAResourceHolderState.html0000644000175000017500000014371712215446622026402 0ustar tonytony Uses of Class bitronix.tm.internal.XAResourceHolderState (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.XAResourceHolderState

Packages that use XAResourceHolderState
bitronix.tm.internal Internal implementation details. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
bitronix.tm.twopc Two-phase commit logic. 
bitronix.tm.twopc.executor Two-phase commit commands executors. 
bitronix.tm.utils Misc utility classes. 
 

Uses of XAResourceHolderState in bitronix.tm.internal
 

Methods in bitronix.tm.internal that return XAResourceHolderState
 XAResourceHolderState XAResourceManager.findXAResourceHolderState(XAResource xaResource)
          Look if an XAResource has already been enlisted.
 

Methods in bitronix.tm.internal that return types with arguments of type XAResourceHolderState
 List<XAResourceHolderState> XAResourceManager.getAllResources()
           
 List<XAResourceHolderState> XAResourceManager.getNaturalOrderResourcesForPosition(Integer position)
           
 List<XAResourceHolderState> XAResourceManager.getReverseOrderResourcesForPosition(Integer position)
           
 

Methods in bitronix.tm.internal with parameters of type XAResourceHolderState
 boolean XAResourceManager.delist(XAResourceHolderState xaResourceHolderState, int flag)
          Delist the specified XAResourceHolderState.
 void XAResourceManager.enlist(XAResourceHolderState xaResourceHolderState)
          Enlist the specified XAResourceHolderState.
 

Constructors in bitronix.tm.internal with parameters of type XAResourceHolderState
XAResourceHolderState(XAResourceHolderState resourceHolderState)
           
 

Uses of XAResourceHolderState in bitronix.tm.recovery
 

Methods in bitronix.tm.recovery with parameters of type XAResourceHolderState
static boolean RecoveryHelper.commit(XAResourceHolderState xaResourceHolderState, Xid xid)
          Commit the specified branch of a dangling transaction.
static Set<BitronixXid> RecoveryHelper.recover(XAResourceHolderState xaResourceHolderState)
          Run the recovery process on the target resource.
static boolean RecoveryHelper.rollback(XAResourceHolderState xaResourceHolderState, Xid xid)
          Rollback the specified branch of a dangling transaction.
 

Uses of XAResourceHolderState in bitronix.tm.resource.common
 

Methods in bitronix.tm.resource.common that return XAResourceHolderState
 XAResourceHolderState XAResourceProducer.startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 

Methods in bitronix.tm.resource.common that return types with arguments of type XAResourceHolderState
 Map<Uid,XAResourceHolderState> XAResourceHolder.getXAResourceHolderStatesForGtrid(Uid gtrid)
          Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.
 Map<Uid,XAResourceHolderState> AbstractXAResourceHolder.getXAResourceHolderStatesForGtrid(Uid gtrid)
           
 

Methods in bitronix.tm.resource.common with parameters of type XAResourceHolderState
 void XAResourceHolder.putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState)
          Add a XAResourceHolderState of this wrapped resource.
 void AbstractXAResourceHolder.putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState)
           
 

Uses of XAResourceHolderState in bitronix.tm.resource.ehcache
 

Methods in bitronix.tm.resource.ehcache that return XAResourceHolderState
 XAResourceHolderState EhCacheXAResourceProducer.startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 

Uses of XAResourceHolderState in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc that return XAResourceHolderState
 XAResourceHolderState PoolingDataSource.startRecovery()
           
 

Uses of XAResourceHolderState in bitronix.tm.resource.jms
 

Methods in bitronix.tm.resource.jms that return XAResourceHolderState
 XAResourceHolderState PoolingConnectionFactory.startRecovery()
           
 

Uses of XAResourceHolderState in bitronix.tm.twopc
 

Methods in bitronix.tm.twopc that return types with arguments of type XAResourceHolderState
protected static List<XAResourceHolderState> AbstractPhaseEngine.collectNotInterestedResources(List<XAResourceHolderState> allResources, List<XAResourceHolderState> interestedResources)
           
 List<XAResourceHolderState> PhaseException.getResourceStates()
          Get the list of resource which threw an exception during a phase execution.
 List<XAResourceHolderState> Preparer.prepare(BitronixTransaction transaction)
          Execute phase 1 prepare.
 

Methods in bitronix.tm.twopc with parameters of type XAResourceHolderState
protected  Job Rollbacker.createJob(XAResourceHolderState resourceHolder)
           
protected  Job Preparer.createJob(XAResourceHolderState xaResourceHolderState)
           
protected  Job Committer.createJob(XAResourceHolderState resourceHolder)
           
protected abstract  Job AbstractPhaseEngine.createJob(XAResourceHolderState xaResourceHolderState)
          Create a Job that is going to execute the phase command on the given resource.
protected  boolean Rollbacker.isParticipating(XAResourceHolderState xaResourceHolderState)
           
protected  boolean Preparer.isParticipating(XAResourceHolderState xaResourceHolderState)
           
protected  boolean Committer.isParticipating(XAResourceHolderState xaResourceHolderState)
           
protected abstract  boolean AbstractPhaseEngine.isParticipating(XAResourceHolderState xaResourceHolderState)
          Determine if a resource is participating in the phase or not.
 

Method parameters in bitronix.tm.twopc with type arguments of type XAResourceHolderState
protected static List<XAResourceHolderState> AbstractPhaseEngine.collectNotInterestedResources(List<XAResourceHolderState> allResources, List<XAResourceHolderState> interestedResources)
           
protected static List<XAResourceHolderState> AbstractPhaseEngine.collectNotInterestedResources(List<XAResourceHolderState> allResources, List<XAResourceHolderState> interestedResources)
           
protected static Set<String> AbstractPhaseEngine.collectResourcesUniqueNames(List<XAResourceHolderState> resources)
           
 void Committer.commit(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Execute phase 2 commit.
 void Rollbacker.rollback(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Rollback the current XA transaction.
 

Constructor parameters in bitronix.tm.twopc with type arguments of type XAResourceHolderState
PhaseException(List<Exception> exceptions, List<XAResourceHolderState> resourceStates)
           
 

Uses of XAResourceHolderState in bitronix.tm.twopc.executor
 

Methods in bitronix.tm.twopc.executor that return XAResourceHolderState
 XAResourceHolderState Job.getResource()
           
 

Constructors in bitronix.tm.twopc.executor with parameters of type XAResourceHolderState
Job(XAResourceHolderState resourceHolder)
           
 

Uses of XAResourceHolderState in bitronix.tm.utils
 

Method parameters in bitronix.tm.utils with type arguments of type XAResourceHolderState
static String Decoder.collectResourcesNames(Collection<XAResourceHolderState> resources)
          Create a String representation of a list of XAResourceHolders.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixXAException.html0000644000175000017500000001377412215446622026130 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixXAException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixXAException

No usage of bitronix.tm.internal.BitronixXAException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/class-use/BitronixRuntimeException.html0000644000175000017500000001405612215446622027235 0ustar tonytony Uses of Class bitronix.tm.internal.BitronixRuntimeException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.internal.BitronixRuntimeException

No usage of bitronix.tm.internal.BitronixRuntimeException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixMultiSystemException.html0000644000175000017500000005261412215446620026212 0ustar tonytony BitronixMultiSystemException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixMultiSystemException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.SystemException
              extended by bitronix.tm.internal.BitronixSystemException
                  extended by bitronix.tm.internal.BitronixMultiSystemException
All Implemented Interfaces:
Serializable

public class BitronixMultiSystemException
extends BitronixSystemException

Subclass of SystemException supporting nested Throwables.

Author:
lorban
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.transaction.SystemException
errorCode
 
Constructor Summary
BitronixMultiSystemException(String string, List exceptions, List resourceStates)
           
 
Method Summary
 List getExceptions()
          Get the list of exceptions that have been thrown during execution.
 String getMessage()
           
 List getResourceStates()
          Get the list of XAResourceHolderStates which threw an exception during execution.
 boolean isUnilateralRollback()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixMultiSystemException

public BitronixMultiSystemException(String string,
                                    List exceptions,
                                    List resourceStates)
Method Detail

getMessage

public String getMessage()
Overrides:
getMessage in class Throwable

isUnilateralRollback

public boolean isUnilateralRollback()

getExceptions

public List getExceptions()
Get the list of exceptions that have been thrown during execution.

Returns:
the list of exceptions that have been thrown during execution.

getResourceStates

public List getResourceStates()
Get the list of XAResourceHolderStates which threw an exception during execution. This list always contains exactly one resource per exception present in getExceptions() list. Indices of both list always match a resource against the exception it threw.

Returns:
the list of resource which threw an exception during execution.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/package-summary.html0000644000175000017500000003231012215446622023374 0ustar tonytony bitronix.tm.internal (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.internal

Internal implementation details.

See:
          Description

Interface Summary
TransactionStatusChangeListener BitronixTransaction status change listener interface.
 

Class Summary
ThreadContext Transactional context of a thread.
XAResourceHolderState XAResourceHolder state container.
XAResourceManager Every BitronixTransaction contains an instance of this class that is used to register and keep track of resources enlisted in a transaction.
 

Exception Summary
BitronixHeuristicCommitException Subclass of HeuristicCommitException supporting nested Throwables.
BitronixHeuristicMixedException Subclass of HeuristicMixedException supporting nested Throwables.
BitronixHeuristicRollbackException Subclass of HeuristicRollbackException supporting nested Throwables.
BitronixMultiSystemException Subclass of SystemException supporting nested Throwables.
BitronixRollbackException Subclass of RollbackException supporting nested Throwables.
BitronixRollbackSystemException Subclass of SystemException indicating a rollback must be performed.
BitronixRuntimeException Thrown when a runtime exception happens.
BitronixSystemException Subclass of SystemException supporting nested Throwables.
BitronixXAException Subclass of XAException supporting nested Throwables.
 

Package bitronix.tm.internal Description

Internal implementation details.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/ThreadContext.html0000644000175000017500000004226612215446620023073 0ustar tonytony ThreadContext (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class ThreadContext

java.lang.Object
  extended by bitronix.tm.internal.ThreadContext

public class ThreadContext
extends Object

Transactional context of a thread. It contains both the active transaction (if any) and all default parameters that a transaction running on a thread must inherit.

Author:
lorban

Constructor Summary
ThreadContext()
           
 
Method Summary
 Map<Object,Object> getResources()
          Get this context's resources, in the JTA 1.1 TransactionSynchronizationRegistry sense.
 int getTimeout()
          Return this context's default timeout.
 BitronixTransaction getTransaction()
          Return the transaction linked with this thread context.
 void setTimeout(int timeout)
          Set this context's default timeout.
 void setTransaction(BitronixTransaction transaction)
          Link a transaction with this thead context.
 String toString()
          Return a human-readable representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadContext

public ThreadContext()
Method Detail

getTransaction

public BitronixTransaction getTransaction()
Return the transaction linked with this thread context.

Returns:
the transaction linked to this thread context or null if there is none.

setTransaction

public void setTransaction(BitronixTransaction transaction)
Link a transaction with this thead context.

Parameters:
transaction - the transaction to link.

getTimeout

public int getTimeout()
Return this context's default timeout.

Returns:
this context's default timeout.

setTimeout

public void setTimeout(int timeout)
Set this context's default timeout. All transactions started by the thread linked to this context will get this value as their default timeout.

Parameters:
timeout - the new default timeout value in seconds.

getResources

public Map<Object,Object> getResources()
Get this context's resources, in the JTA 1.1 TransactionSynchronizationRegistry sense.

Returns:
this context's resources.

toString

public String toString()
Return a human-readable representation.

Overrides:
toString in class Object
Returns:
a human-readable representation.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/XAResourceManager.html0000644000175000017500000010463112215446620023625 0ustar tonytony XAResourceManager (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class XAResourceManager

java.lang.Object
  extended by bitronix.tm.internal.XAResourceManager

public class XAResourceManager
extends Object

Every BitronixTransaction contains an instance of this class that is used to register and keep track of resources enlisted in a transaction.

Author:
lorban

Constructor Summary
XAResourceManager(Uid gtrid)
          Create a resource manager for the specified GTRID.
 
Method Summary
 void clearXAResourceHolderStates()
          Remove this transaction's XAResourceHolderState from all enlisted XAResourceHolders.
 Set<String> collectUniqueNames()
          Get a Set of unique names of all the enlisted XAResourceHolderStates.
 boolean delist(XAResourceHolderState xaResourceHolderState, int flag)
          Delist the specified XAResourceHolderState.
 void enlist(XAResourceHolderState xaResourceHolderState)
          Enlist the specified XAResourceHolderState.
 XAResourceHolderState findXAResourceHolderState(XAResource xaResource)
          Look if an XAResource has already been enlisted.
 List<XAResourceHolderState> getAllResources()
           
 Uid getGtrid()
          Get the GTRID of the transaction the XAResourceManager instance is attached to.
 SortedSet<Integer> getNaturalOrderPositions()
           
 List<XAResourceHolderState> getNaturalOrderResourcesForPosition(Integer position)
           
 SortedSet<Integer> getReverseOrderPositions()
           
 List<XAResourceHolderState> getReverseOrderResourcesForPosition(Integer position)
           
 void resume()
          Resume all enlisted resources in the current transaction context.
 int size()
          Get the enlisted resources count.
 void suspend()
          Suspend all enlisted resources from the current transaction context.
 String toString()
          Return a human-readable representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XAResourceManager

public XAResourceManager(Uid gtrid)
Create a resource manager for the specified GTRID.

Parameters:
gtrid - the transaction's GTRID this XAResourceManager will be assigned to.
Method Detail

enlist

public void enlist(XAResourceHolderState xaResourceHolderState)
            throws XAException,
                   BitronixSystemException
Enlist the specified XAResourceHolderState. A XID is generated and the resource is started with XAResource.TMNOFLAGS or XAResource.TMJOIN if it could be joined with another previously enlisted one.
There are 3 different cases that can happen when a XAResourceHolderState is enlisted:
  • already enlisted and not ended: do nothing
  • already enlisted and ended: try to join. if you can join, keep a reference on the passed-in XAResourceHolderState and drop the previous one. if you cannot join, it's the same as case 3
  • not enlisted: create a new branch and keep a reference on the passed-in XAResourceHolderState

Parameters:
xaResourceHolderState - the XAResourceHolderState to be enlisted.
Throws:
XAException - if a resource error occured.
BitronixSystemException - if an internal error occured.

delist

public boolean delist(XAResourceHolderState xaResourceHolderState,
                      int flag)
               throws XAException,
                      BitronixSystemException
Delist the specified XAResourceHolderState. A reference to the resource is kept anyway.

Parameters:
xaResourceHolderState - the XAResourceHolderState to be delisted.
flag - the delistment flag.
Returns:
true if the resource could be delisted, false otherwise.
Throws:
XAException - if the resource threw an exception during delistment.
BitronixSystemException - if an internal error occured.

suspend

public void suspend()
             throws XAException
Suspend all enlisted resources from the current transaction context.

Throws:
XAException - if the resource threw an exception during suspend.

resume

public void resume()
            throws XAException
Resume all enlisted resources in the current transaction context.

Throws:
XAException - if the resource threw an exception during resume.

findXAResourceHolderState

public XAResourceHolderState findXAResourceHolderState(XAResource xaResource)
                                                throws BitronixSystemException
Look if an XAResource has already been enlisted.

Parameters:
xaResource - the XAResource to look for.
Returns:
the XAResourceHolderState of the enlisted resource or null if the XAResource has not been enlisted in this XAResourceManager.
Throws:
BitronixSystemException - if an internal error happens.

clearXAResourceHolderStates

public void clearXAResourceHolderStates()
Remove this transaction's XAResourceHolderState from all enlisted XAResourceHolders.


collectUniqueNames

public Set<String> collectUniqueNames()
Get a Set of unique names of all the enlisted XAResourceHolderStates.

Returns:
a Set of unique names of all the enlisted XAResourceHolderStates.

getNaturalOrderPositions

public SortedSet<Integer> getNaturalOrderPositions()

getReverseOrderPositions

public SortedSet<Integer> getReverseOrderPositions()

getNaturalOrderResourcesForPosition

public List<XAResourceHolderState> getNaturalOrderResourcesForPosition(Integer position)

getReverseOrderResourcesForPosition

public List<XAResourceHolderState> getReverseOrderResourcesForPosition(Integer position)

getAllResources

public List<XAResourceHolderState> getAllResources()

size

public int size()
Get the enlisted resources count.

Returns:
the enlisted resources count.

getGtrid

public Uid getGtrid()
Get the GTRID of the transaction the XAResourceManager instance is attached to.

Returns:
the GTRID of the transaction the XAResourceManager instance is attached to.

toString

public String toString()
Return a human-readable representation of this object.

Overrides:
toString in class Object
Returns:
a human-readable representation of this object.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/XAResourceHolderState.html0000644000175000017500000007037212215446620024475 0ustar tonytony XAResourceHolderState (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class XAResourceHolderState

java.lang.Object
  extended by bitronix.tm.internal.XAResourceHolderState

public class XAResourceHolderState
extends Object

XAResourceHolder state container. Instances are kept in the transaction and bound to / unbound from the XAResourceHolder as the resource participates in different transactions. A XAResourceHolder without XAResourceHolderState is considered to be in local transaction mode.

Objects of this class also expose resource specific configuration like the unique resource name.

The XAResource state during a transaction participation is also contained: assigned XID, transaction start / end state...

There is exactly one XAResourceHolderState object per XAResourceHolder per Transaction.

Author:
lorban
See Also:
ResourceBean

Constructor Summary
XAResourceHolderState(XAResourceHolder resourceHolder, ResourceBean bean)
           
XAResourceHolderState(XAResourceHolderState resourceHolderState)
           
 
Method Summary
 void end(int flags)
           
 boolean equals(Object obj)
           
 boolean getIgnoreRecoveryFailures()
           
 Date getTransactionTimeoutDate()
           
 int getTwoPcOrderingPosition()
           
 String getUniqueName()
           
 boolean getUseTmJoin()
           
 XAResource getXAResource()
           
 XAResourceHolder getXAResourceHolder()
           
 BitronixXid getXid()
           
 int hashCode()
           
 boolean isEnded()
           
 boolean isFailed()
           
 boolean isStarted()
           
 boolean isSuspended()
           
 void setTransactionTimeoutDate(Date transactionTimeoutDate)
           
 void setXid(BitronixXid xid)
           
 void start(int flags)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XAResourceHolderState

public XAResourceHolderState(XAResourceHolder resourceHolder,
                             ResourceBean bean)

XAResourceHolderState

public XAResourceHolderState(XAResourceHolderState resourceHolderState)
Method Detail

getXid

public BitronixXid getXid()

setXid

public void setXid(BitronixXid xid)
            throws BitronixSystemException
Throws:
BitronixSystemException

getXAResource

public XAResource getXAResource()

getXAResourceHolder

public XAResourceHolder getXAResourceHolder()

getTransactionTimeoutDate

public Date getTransactionTimeoutDate()

setTransactionTimeoutDate

public void setTransactionTimeoutDate(Date transactionTimeoutDate)

getUniqueName

public String getUniqueName()

getUseTmJoin

public boolean getUseTmJoin()

getTwoPcOrderingPosition

public int getTwoPcOrderingPosition()

getIgnoreRecoveryFailures

public boolean getIgnoreRecoveryFailures()

isEnded

public boolean isEnded()

isStarted

public boolean isStarted()

isSuspended

public boolean isSuspended()

isFailed

public boolean isFailed()

end

public void end(int flags)
         throws XAException
Throws:
XAException

start

public void start(int flags)
           throws XAException
Throws:
XAException

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixXAException.html0000644000175000017500000005631612215446620024226 0ustar tonytony BitronixXAException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixXAException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.transaction.xa.XAException
              extended by bitronix.tm.internal.BitronixXAException
All Implemented Interfaces:
Serializable

public class BitronixXAException
extends XAException

Subclass of XAException supporting nested Throwables.

Author:
lorban
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.transaction.xa.XAException
errorCode, XA_HEURCOM, XA_HEURHAZ, XA_HEURMIX, XA_HEURRB, XA_NOMIGRATE, XA_RBBASE, XA_RBCOMMFAIL, XA_RBDEADLOCK, XA_RBEND, XA_RBINTEGRITY, XA_RBOTHER, XA_RBPROTO, XA_RBROLLBACK, XA_RBTIMEOUT, XA_RBTRANSIENT, XA_RDONLY, XA_RETRY, XAER_ASYNC, XAER_DUPID, XAER_INVAL, XAER_NOTA, XAER_OUTSIDE, XAER_PROTO, XAER_RMERR, XAER_RMFAIL
 
Constructor Summary
BitronixXAException(String message, int errorCode)
           
BitronixXAException(String message, int errorCode, Throwable t)
           
 
Method Summary
static boolean isUnilateralRollback(XAException ex)
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixXAException

public BitronixXAException(String message,
                           int errorCode)

BitronixXAException

public BitronixXAException(String message,
                           int errorCode,
                           Throwable t)
Method Detail

isUnilateralRollback

public static boolean isUnilateralRollback(XAException ex)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/internal/BitronixRuntimeException.html0000644000175000017500000003766412215446620025346 0ustar tonytony BitronixRuntimeException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.internal
Class BitronixRuntimeException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by bitronix.tm.internal.BitronixRuntimeException
All Implemented Interfaces:
Serializable

public class BitronixRuntimeException
extends RuntimeException

Thrown when a runtime exception happens.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
BitronixRuntimeException(String message)
           
BitronixRuntimeException(String message, Throwable cause)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixRuntimeException

public BitronixRuntimeException(String message,
                                Throwable cause)

BitronixRuntimeException

public BitronixRuntimeException(String message)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/0000755000175000017500000000000012215446622016745 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/utils/PropertyUtils.html0000644000175000017500000005261012215446622022504 0ustar tonytony PropertyUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class PropertyUtils

java.lang.Object
  extended by bitronix.tm.utils.PropertyUtils

public class PropertyUtils
extends Object

Smart reflection helper.

Author:
lorban

Constructor Summary
PropertyUtils()
           
 
Method Summary
static Map getProperties(Object target)
          Build a map of direct javabeans properties of the target object.
static Object getProperty(Object target, String propertyName)
          Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
static String propertiesToString(Object obj)
          Return a comma-separated String of r/w properties of the specified object.
static void setProperties(Object target, Map properties)
          Set a Map of direct or indirect properties on the target object.
static void setProperty(Object target, String propertyName, Object propertyValue)
          Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyUtils

public PropertyUtils()
Method Detail

setProperty

public static void setProperty(Object target,
                               String propertyName,
                               Object propertyValue)
                        throws PropertyException
Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object. This method tries to be smart in the way that intermediate properties currently set to null are set if it is possible to create and set an object. Conversions from propertyValue to the proper destination type are performed when possible.

Parameters:
target - the target object on which to set the property.
propertyName - the name of the property to set.
propertyValue - the value of the property to set.
Throws:
PropertyException - if an error happened while trying to set the property.

getProperties

public static Map getProperties(Object target)
                         throws PropertyException
Build a map of direct javabeans properties of the target object. Only read/write properties (ie: those who have both a getter and a setter) are returned.

Parameters:
target - the target object from which to get properties names.
Returns:
a Map of String with properties names as key and their values
Throws:
PropertyException - if an error happened while trying to get a property.

getProperty

public static Object getProperty(Object target,
                                 String propertyName)
                          throws PropertyException
Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.

Parameters:
target - the target object from which to get the property.
propertyName - the name of the property to get.
Returns:
the value of the specified property.
Throws:
PropertyException - if an error happened while trying to get the property.

setProperties

public static void setProperties(Object target,
                                 Map properties)
                          throws PropertyException
Set a Map of direct or indirect properties on the target object.

Parameters:
target - the target object on which to set the properties.
properties - a Map of String/Object pairs.
Throws:
PropertyException - if an error happened while trying to set a property.

propertiesToString

public static String propertiesToString(Object obj)
Return a comma-separated String of r/w properties of the specified object.

Parameters:
obj - the object to introspect.
Returns:
a a comma-separated String of r/w properties.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/ExceptionUtils.html0000644000175000017500000002737612215446622022631 0ustar tonytony ExceptionUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class ExceptionUtils

java.lang.Object
  extended by bitronix.tm.utils.ExceptionUtils

public final class ExceptionUtils
extends Object

Exception related utilities.

Author:
Stephane Nicoll

Method Summary
static String getStackTrace(Throwable t)
          Returns the stack trace of the specified Throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getStackTrace

public static String getStackTrace(Throwable t)
Returns the stack trace of the specified Throwable.

Parameters:
t - the throwable
Returns:
the string representation of the stack trace


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/package-frame.html0000644000175000017500000000617112215446622022323 0ustar tonytony bitronix.tm.utils (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.utils
Interfaces 
ExceptionAnalyzer
Service
Classes 
ClassLoaderUtils
CollectionUtils
CryptoEngine
Decoder
DefaultExceptionAnalyzer
Encoder
ExceptionUtils
ManagementRegistrar
MonotonicClock
PropertyUtils
Scheduler
StackTrace
Uid
UidGenerator
Exceptions 
InitializationException
PropertyException
btm-dist-2.1.4/doc/api/bitronix/tm/utils/Decoder.html0000644000175000017500000004474712215446622021220 0ustar tonytony Decoder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class Decoder

java.lang.Object
  extended by bitronix.tm.utils.Decoder

public class Decoder
extends Object

Constant to string decoder.

Author:
lorban

Constructor Summary
Decoder()
           
 
Method Summary
static String collectResourcesNames(Collection<XAResourceHolderState> resources)
          Create a String representation of a list of XAResourceHolders.
static String decodeHeaderState(byte state)
           
static String decodePrepareVote(int vote)
           
static String decodeStatus(int status)
           
static String decodeXAExceptionErrorCode(XAException ex)
           
static String decodeXAResourceFlag(int flag)
           
static String decodeXAStatefulHolderState(int state)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Decoder

public Decoder()
Method Detail

decodeXAExceptionErrorCode

public static String decodeXAExceptionErrorCode(XAException ex)

decodeStatus

public static String decodeStatus(int status)

decodeXAResourceFlag

public static String decodeXAResourceFlag(int flag)

decodePrepareVote

public static String decodePrepareVote(int vote)

decodeHeaderState

public static String decodeHeaderState(byte state)

decodeXAStatefulHolderState

public static String decodeXAStatefulHolderState(int state)

collectResourcesNames

public static String collectResourcesNames(Collection<XAResourceHolderState> resources)
Create a String representation of a list of XAResourceHolders. This String will contain each resource's unique name.

Parameters:
resources - a list of XAResourceHolders.
Returns:
a String representation of the list.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/MonotonicClock.html0000644000175000017500000003000412215446622022551 0ustar tonytony MonotonicClock (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class MonotonicClock

java.lang.Object
  extended by bitronix.tm.utils.MonotonicClock

public class MonotonicClock
extends Object

A System.currentTimeMillis() replacement which guarantees monotonic time increment.

Author:
lorban

Constructor Summary
MonotonicClock()
           
 
Method Summary
static long currentTimeMillis()
          Return the current time in milliseconds, guaranteeing monotonic time increment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MonotonicClock

public MonotonicClock()
Method Detail

currentTimeMillis

public static long currentTimeMillis()
Return the current time in milliseconds, guaranteeing monotonic time increment.

Returns:
the current time in milliseconds.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/package-tree.html0000644000175000017500000002334512215446622022172 0ustar tonytony bitronix.tm.utils Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.utils

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/CollectionUtils.html0000644000175000017500000003217612215446622022760 0ustar tonytony CollectionUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class CollectionUtils

java.lang.Object
  extended by bitronix.tm.utils.CollectionUtils

public class CollectionUtils
extends Object

Collection helper functions.

Author:
lorban

Constructor Summary
CollectionUtils()
           
 
Method Summary
static boolean containsByIdentity(Collection<?> collection, Object toBeFound)
          Check if a collection contains a specific object by searching for it by identity instead of by using equals/hashcode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionUtils

public CollectionUtils()
Method Detail

containsByIdentity

public static boolean containsByIdentity(Collection<?> collection,
                                         Object toBeFound)
Check if a collection contains a specific object by searching for it by identity instead of by using equals/hashcode.

Parameters:
collection - the collection to search in.
toBeFound - the object to search for.
Returns:
true if the collection contains the object, false otherwise.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/package-use.html0000644000175000017500000003770512215446622022034 0ustar tonytony Uses of Package bitronix.tm.utils (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.utils

Packages that use bitronix.tm.utils
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.internal Internal implementation details. 
bitronix.tm.journal Transactions disk journal. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource Transaction Manager's resource management services. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.timer Timed tasks scheduler. 
bitronix.tm.twopc.executor Two-phase commit commands executors. 
bitronix.tm.utils Misc utility classes. 
 

Classes in bitronix.tm.utils used by bitronix.tm
ExceptionAnalyzer
          Exception analyzers are used to extract non-standard information from vendor exceptions.
Scheduler
          Positional object container.
Service
          All internal services implement this interface.
Uid
          A constant UID byte array container optimized for use with hashed collections.
 

Classes in bitronix.tm.utils used by bitronix.tm.internal
Uid
          A constant UID byte array container optimized for use with hashed collections.
 

Classes in bitronix.tm.utils used by bitronix.tm.journal
Service
          All internal services implement this interface.
Uid
          A constant UID byte array container optimized for use with hashed collections.
 

Classes in bitronix.tm.utils used by bitronix.tm.recovery
Service
          All internal services implement this interface.
 

Classes in bitronix.tm.utils used by bitronix.tm.resource
Service
          All internal services implement this interface.
 

Classes in bitronix.tm.utils used by bitronix.tm.resource.common
Uid
          A constant UID byte array container optimized for use with hashed collections.
 

Classes in bitronix.tm.utils used by bitronix.tm.timer
Service
          All internal services implement this interface.
 

Classes in bitronix.tm.utils used by bitronix.tm.twopc.executor
Service
          All internal services implement this interface.
 

Classes in bitronix.tm.utils used by bitronix.tm.utils
ExceptionAnalyzer
          Exception analyzers are used to extract non-standard information from vendor exceptions.
PropertyException
          Thrown by PropertyUtils when some reflection error occurs.
Service
          All internal services implement this interface.
Uid
          A constant UID byte array container optimized for use with hashed collections.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/ManagementRegistrar.html0000644000175000017500000003371012215446622023576 0ustar tonytony ManagementRegistrar (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class ManagementRegistrar

java.lang.Object
  extended by bitronix.tm.utils.ManagementRegistrar

public final class ManagementRegistrar
extends Object

Simple JMX facade. In case JMX is disabled, calling methods of this class have no effect.

Author:
lorban

Method Summary
static String makeValidName(String name)
          Replace characters considered illegal in a management object's name.
static void register(String name, Object obj)
          Register the specified management object.
static void unregister(String name)
          Unregister the management object with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeValidName

public static String makeValidName(String name)
Replace characters considered illegal in a management object's name.

Parameters:
name - the name to work on.
Returns:
a fully valid name where all invalid characters have been replaced with '_'.

register

public static void register(String name,
                            Object obj)
Register the specified management object.

Parameters:
name - the name of the object.
obj - the management object.

unregister

public static void unregister(String name)
Unregister the management object with the specified name.

Parameters:
name - the name of the object.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/UidGenerator.html0000644000175000017500000003267012215446622022233 0ustar tonytony UidGenerator (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class UidGenerator

java.lang.Object
  extended by bitronix.tm.utils.UidGenerator

public class UidGenerator
extends Object

Helper that offers UID generation (GTRID, XID, sequences) needed by the transaction manager.

Generated UIDs are at most 64 bytes long and are made of 3 subparts: the current time in milliseconds since Epoch, a JVM transient atomic sequence number and the configured bitronix.tm.serverId.

The reliance on the system clock is critical to the uniqueness of the UID in the network so you have to make sure all servers of the network running this transaction manager have their clock reasonably in sync. An order of 1 second synchronicity is generally fine.

Author:
lorban

Constructor Summary
UidGenerator()
           
 
Method Summary
static Uid generateUid()
          Generate a UID, globally unique.
static BitronixXid generateXid(Uid gtrid)
          Generate a XID with the specified globalTransactionId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UidGenerator

public UidGenerator()
Method Detail

generateUid

public static Uid generateUid()
Generate a UID, globally unique. This method relies on the configured serverId for network uniqueness.

Returns:
the generated UID.

generateXid

public static BitronixXid generateXid(Uid gtrid)
Generate a XID with the specified globalTransactionId.

Parameters:
gtrid - the GTRID to use to generate the Xid.
Returns:
the generated Xid.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/0000755000175000017500000000000012215446622020644 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/PropertyUtils.html0000644000175000017500000001364212215446622024405 0ustar tonytony Uses of Class bitronix.tm.utils.PropertyUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.PropertyUtils

No usage of bitronix.tm.utils.PropertyUtils



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/ExceptionUtils.html0000644000175000017500000001365412215446622024522 0ustar tonytony Uses of Class bitronix.tm.utils.ExceptionUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.ExceptionUtils

No usage of bitronix.tm.utils.ExceptionUtils



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/Decoder.html0000644000175000017500000001354612215446622023110 0ustar tonytony Uses of Class bitronix.tm.utils.Decoder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.Decoder

No usage of bitronix.tm.utils.Decoder



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/MonotonicClock.html0000644000175000017500000001365412215446622024464 0ustar tonytony Uses of Class bitronix.tm.utils.MonotonicClock (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.MonotonicClock

No usage of bitronix.tm.utils.MonotonicClock



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/CollectionUtils.html0000644000175000017500000001366612215446622024662 0ustar tonytony Uses of Class bitronix.tm.utils.CollectionUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.CollectionUtils

No usage of bitronix.tm.utils.CollectionUtils



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/ManagementRegistrar.html0000644000175000017500000001373612215446622025503 0ustar tonytony Uses of Class bitronix.tm.utils.ManagementRegistrar (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.ManagementRegistrar

No usage of bitronix.tm.utils.ManagementRegistrar



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/UidGenerator.html0000644000175000017500000001363012215446622024125 0ustar tonytony Uses of Class bitronix.tm.utils.UidGenerator (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.UidGenerator

No usage of bitronix.tm.utils.UidGenerator



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/Service.html0000644000175000017500000005037212215446622023141 0ustar tonytony Uses of Interface bitronix.tm.utils.Service (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.utils.Service

Packages that use Service
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.journal Transactions disk journal. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource Transaction Manager's resource management services. 
bitronix.tm.timer Timed tasks scheduler. 
bitronix.tm.twopc.executor Two-phase commit commands executors. 
bitronix.tm.utils Misc utility classes. 
 

Uses of Service in bitronix.tm
 

Classes in bitronix.tm that implement Service
 class BitronixTransactionManager
          Implementation of TransactionManager and UserTransaction.
 class Configuration
          Configuration repository of the transaction manager.
 

Uses of Service in bitronix.tm.journal
 

Subinterfaces of Service in bitronix.tm.journal
 interface Journal
          Transaction logs journal implementations must implement this interface to provide functionality required by the transaction manager.
 

Classes in bitronix.tm.journal that implement Service
 class DiskJournal
          Simple implementation of a journal that writes on a two-files disk log.
 class NullJournal
          No-op journal.
 

Uses of Service in bitronix.tm.recovery
 

Classes in bitronix.tm.recovery that implement Service
 class Recoverer
          Recovery process implementation.
 

Uses of Service in bitronix.tm.resource
 

Classes in bitronix.tm.resource that implement Service
 class ResourceLoader
          XA resources pools configurator & loader.
 

Uses of Service in bitronix.tm.timer
 

Classes in bitronix.tm.timer that implement Service
 class TaskScheduler
          Timed tasks service.
 

Uses of Service in bitronix.tm.twopc.executor
 

Subinterfaces of Service in bitronix.tm.twopc.executor
 interface Executor
          Thread pool interface required by the two-phase commit logic.
 

Classes in bitronix.tm.twopc.executor that implement Service
 class AsyncExecutor
          This implementation executes submitted jobs using a java.util.concurrent cached thread pool.
 class SyncExecutor
          This implementation executes submitted jobs synchronously.
 

Uses of Service in bitronix.tm.utils
 

Subinterfaces of Service in bitronix.tm.utils
 interface ExceptionAnalyzer
          Exception analyzers are used to extract non-standard information from vendor exceptions.
 

Classes in bitronix.tm.utils that implement Service
 class DefaultExceptionAnalyzer
          Default implementation of ExceptionAnalyzer.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/StackTrace.html0000644000175000017500000001360412215446622023562 0ustar tonytony Uses of Class bitronix.tm.utils.StackTrace (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.StackTrace

No usage of bitronix.tm.utils.StackTrace



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/Uid.html0000644000175000017500000007073512215446622022267 0ustar tonytony Uses of Class bitronix.tm.utils.Uid (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.Uid

Packages that use Uid
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.internal Internal implementation details. 
bitronix.tm.journal Transactions disk journal. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.utils Misc utility classes. 
 

Uses of Uid in bitronix.tm
 

Methods in bitronix.tm that return Uid
 Uid BitronixXid.getBranchQualifierUid()
           
 Uid BitronixXid.getGlobalTransactionIdUid()
           
 

Constructors in bitronix.tm with parameters of type Uid
BitronixXid(Uid globalTransactionId, Uid branchQualifier)
          Create a new XID using the specified GTRID and BQUAL.
 

Uses of Uid in bitronix.tm.internal
 

Methods in bitronix.tm.internal that return Uid
 Uid XAResourceManager.getGtrid()
          Get the GTRID of the transaction the XAResourceManager instance is attached to.
 

Constructors in bitronix.tm.internal with parameters of type Uid
XAResourceManager(Uid gtrid)
          Create a resource manager for the specified GTRID.
 

Uses of Uid in bitronix.tm.journal
 

Methods in bitronix.tm.journal that return Uid
 Uid TransactionLogRecord.getGtrid()
           
 

Methods in bitronix.tm.journal that return types with arguments of type Uid
 Map<Uid,TransactionLogRecord> NullJournal.collectDanglingRecords()
           
 Map<Uid,TransactionLogRecord> Journal.collectDanglingRecords()
          Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record.
 Map<Uid,TransactionLogRecord> DiskJournal.collectDanglingRecords()
          Collect all dangling records of the active log file.
 

Methods in bitronix.tm.journal with parameters of type Uid
 void NullJournal.log(int status, Uid gtrid, Set<String> uniqueNames)
           
 void Journal.log(int status, Uid gtrid, Set<String> uniqueNames)
          Log a new transaction status to journal.
 void DiskJournal.log(int status, Uid gtrid, Set<String> uniqueNames)
          Log a new transaction status to journal.
 

Constructors in bitronix.tm.journal with parameters of type Uid
TransactionLogRecord(int status, int recordLength, int headerLength, long time, int sequenceNumber, int crc32, Uid gtrid, Set<String> uniqueNames, int endRecord)
          Use this constructor when restoring a log from the disk.
TransactionLogRecord(int status, Uid gtrid, Set<String> uniqueNames)
          Create a new transaction log ready to be stored.
 

Uses of Uid in bitronix.tm.resource.common
 

Methods in bitronix.tm.resource.common that return types with arguments of type Uid
 Map<Uid,XAResourceHolderState> XAResourceHolder.getXAResourceHolderStatesForGtrid(Uid gtrid)
          Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.
 Map<Uid,XAResourceHolderState> AbstractXAResourceHolder.getXAResourceHolderStatesForGtrid(Uid gtrid)
           
 

Methods in bitronix.tm.resource.common with parameters of type Uid
 Map<Uid,XAResourceHolderState> XAResourceHolder.getXAResourceHolderStatesForGtrid(Uid gtrid)
          Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.
 Map<Uid,XAResourceHolderState> AbstractXAResourceHolder.getXAResourceHolderStatesForGtrid(Uid gtrid)
           
 

Uses of Uid in bitronix.tm.utils
 

Methods in bitronix.tm.utils that return Uid
static Uid UidGenerator.generateUid()
          Generate a UID, globally unique.
 

Methods in bitronix.tm.utils with parameters of type Uid
static BitronixXid UidGenerator.generateXid(Uid gtrid)
          Generate a XID with the specified globalTransactionId.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/DefaultExceptionAnalyzer.html0000644000175000017500000001402012215446622026500 0ustar tonytony Uses of Class bitronix.tm.utils.DefaultExceptionAnalyzer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.DefaultExceptionAnalyzer

No usage of bitronix.tm.utils.DefaultExceptionAnalyzer



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/ExceptionAnalyzer.html0000644000175000017500000002257112215446622025205 0ustar tonytony Uses of Interface bitronix.tm.utils.ExceptionAnalyzer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.utils.ExceptionAnalyzer

Packages that use ExceptionAnalyzer
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.utils Misc utility classes. 
 

Uses of ExceptionAnalyzer in bitronix.tm
 

Methods in bitronix.tm that return ExceptionAnalyzer
static ExceptionAnalyzer TransactionManagerServices.getExceptionAnalyzer()
          Create the exception analyzer.
 

Uses of ExceptionAnalyzer in bitronix.tm.utils
 

Classes in bitronix.tm.utils that implement ExceptionAnalyzer
 class DefaultExceptionAnalyzer
          Default implementation of ExceptionAnalyzer.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/ClassLoaderUtils.html0000644000175000017500000001370012215446622024750 0ustar tonytony Uses of Class bitronix.tm.utils.ClassLoaderUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.ClassLoaderUtils

No usage of bitronix.tm.utils.ClassLoaderUtils



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/Scheduler.html0000644000175000017500000001745012215446622023457 0ustar tonytony Uses of Class bitronix.tm.utils.Scheduler (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.Scheduler

Packages that use Scheduler
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of Scheduler in bitronix.tm
 

Methods in bitronix.tm that return Scheduler
 Scheduler<Synchronization> BitronixTransaction.getSynchronizationScheduler()
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/Encoder.html0000644000175000017500000001354612215446622023122 0ustar tonytony Uses of Class bitronix.tm.utils.Encoder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.Encoder

No usage of bitronix.tm.utils.Encoder



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/CryptoEngine.html0000644000175000017500000001363012215446622024143 0ustar tonytony Uses of Class bitronix.tm.utils.CryptoEngine (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.CryptoEngine

No usage of bitronix.tm.utils.CryptoEngine



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/PropertyException.html0000644000175000017500000002537612215446622025252 0ustar tonytony Uses of Class bitronix.tm.utils.PropertyException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.PropertyException

Packages that use PropertyException
bitronix.tm.utils Misc utility classes. 
 

Uses of PropertyException in bitronix.tm.utils
 

Methods in bitronix.tm.utils that throw PropertyException
static Map PropertyUtils.getProperties(Object target)
          Build a map of direct javabeans properties of the target object.
static Object PropertyUtils.getProperty(Object target, String propertyName)
          Get a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
static void PropertyUtils.setProperties(Object target, Map properties)
          Set a Map of direct or indirect properties on the target object.
static void PropertyUtils.setProperty(Object target, String propertyName, Object propertyValue)
          Set a direct or indirect property (dotted property: prop1.prop2.prop3) on the target object.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/class-use/InitializationException.html0000644000175000017500000001400612215446622026401 0ustar tonytony Uses of Class bitronix.tm.utils.InitializationException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.utils.InitializationException

No usage of bitronix.tm.utils.InitializationException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/Service.html0000644000175000017500000002344712215446622021245 0ustar tonytony Service (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Interface Service

All Known Subinterfaces:
ExceptionAnalyzer, Executor, Journal
All Known Implementing Classes:
AsyncExecutor, BitronixTransactionManager, Configuration, DefaultExceptionAnalyzer, DiskJournal, NullJournal, Recoverer, ResourceLoader, SyncExecutor, TaskScheduler

public interface Service

All internal services implement this interface.

Author:
lorban
See Also:
TransactionManagerServices

Method Summary
 void shutdown()
          Shutdown the service and free all held resources.
 

Method Detail

shutdown

void shutdown()
Shutdown the service and free all held resources.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/StackTrace.html0000644000175000017500000003341112215446622021661 0ustar tonytony StackTrace (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class StackTrace

java.lang.Object
  extended by java.lang.Throwable
      extended by bitronix.tm.utils.StackTrace
All Implemented Interfaces:
Serializable

public class StackTrace
extends Throwable

A dummy Throwable used to build a call stack.

Author:
Ludovic Orban
See Also:
Serialized Form

Constructor Summary
StackTrace()
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StackTrace

public StackTrace()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/package-summary.html0000644000175000017500000002711612215446622022730 0ustar tonytony bitronix.tm.utils (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.utils

Misc utility classes.

See:
          Description

Interface Summary
ExceptionAnalyzer Exception analyzers are used to extract non-standard information from vendor exceptions.
Service All internal services implement this interface.
 

Class Summary
ClassLoaderUtils Static utility methods for loading classes and resources.
CollectionUtils Collection helper functions.
CryptoEngine Simple crypto helper that uses symetric keys to crypt and decrypt resources passwords.
Decoder Constant to string decoder.
DefaultExceptionAnalyzer Default implementation of ExceptionAnalyzer.
Encoder Number to byte array and byte array to number encoder.
ExceptionUtils Exception related utilities.
ManagementRegistrar Simple JMX facade.
MonotonicClock A System.currentTimeMillis() replacement which guarantees monotonic time increment.
PropertyUtils Smart reflection helper.
Scheduler<T> Positional object container.
StackTrace A dummy Throwable used to build a call stack.
Uid A constant UID byte array container optimized for use with hashed collections.
UidGenerator Helper that offers UID generation (GTRID, XID, sequences) needed by the transaction manager.
 

Exception Summary
InitializationException Thrown at transaction manager startup when an error occurs.
PropertyException Thrown by PropertyUtils when some reflection error occurs.
 

Package bitronix.tm.utils Description

Misc utility classes.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/Uid.html0000644000175000017500000003704512215446622020365 0ustar tonytony Uid (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class Uid

java.lang.Object
  extended by bitronix.tm.utils.Uid

public final class Uid
extends Object

A constant UID byte array container optimized for use with hashed collections.

Author:
lorban

Constructor Summary
Uid(byte[] array)
           
 
Method Summary
 boolean equals(Object obj)
           
 int extractSequence()
           
 byte[] extractServerId()
           
 long extractTimestamp()
           
 byte[] getArray()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Uid

public Uid(byte[] array)
Method Detail

getArray

public byte[] getArray()

extractServerId

public byte[] extractServerId()

extractTimestamp

public long extractTimestamp()

extractSequence

public int extractSequence()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/DefaultExceptionAnalyzer.html0000644000175000017500000003625612215446622024620 0ustar tonytony DefaultExceptionAnalyzer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class DefaultExceptionAnalyzer

java.lang.Object
  extended by bitronix.tm.utils.DefaultExceptionAnalyzer
All Implemented Interfaces:
ExceptionAnalyzer, Service

public class DefaultExceptionAnalyzer
extends Object
implements ExceptionAnalyzer

Default implementation of ExceptionAnalyzer.

Author:
lorban

Constructor Summary
DefaultExceptionAnalyzer()
           
 
Method Summary
 String extractExtraXAExceptionDetails(XAException ex)
          Extract information from a vendor's XAException that isn't available through standard APIs.
 void shutdown()
          Shutdown the service and free all held resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultExceptionAnalyzer

public DefaultExceptionAnalyzer()
Method Detail

extractExtraXAExceptionDetails

public String extractExtraXAExceptionDetails(XAException ex)
Description copied from interface: ExceptionAnalyzer
Extract information from a vendor's XAException that isn't available through standard APIs.

Specified by:
extractExtraXAExceptionDetails in interface ExceptionAnalyzer
Parameters:
ex - the XAException to analyze.
Returns:
extra error details as a human-readable string, or null if nothing extra was found.

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/ExceptionAnalyzer.html0000644000175000017500000002464112215446622023306 0ustar tonytony ExceptionAnalyzer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Interface ExceptionAnalyzer

All Superinterfaces:
Service
All Known Implementing Classes:
DefaultExceptionAnalyzer

public interface ExceptionAnalyzer
extends Service

Exception analyzers are used to extract non-standard information from vendor exceptions.

Author:
lorban

Method Summary
 String extractExtraXAExceptionDetails(XAException ex)
          Extract information from a vendor's XAException that isn't available through standard APIs.
 
Methods inherited from interface bitronix.tm.utils.Service
shutdown
 

Method Detail

extractExtraXAExceptionDetails

String extractExtraXAExceptionDetails(XAException ex)
Extract information from a vendor's XAException that isn't available through standard APIs.

Parameters:
ex - the XAException to analyze.
Returns:
extra error details as a human-readable string, or null if nothing extra was found.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/ClassLoaderUtils.html0000644000175000017500000003747112215446622023064 0ustar tonytony ClassLoaderUtils (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class ClassLoaderUtils

java.lang.Object
  extended by bitronix.tm.utils.ClassLoaderUtils

public class ClassLoaderUtils
extends Object

Static utility methods for loading classes and resources.


Constructor Summary
ClassLoaderUtils()
           
 
Method Summary
static ClassLoader getClassLoader()
          Get the class loader which can be used to generate proxies without leaking memory.
static InputStream getResourceAsStream(String resourceName)
          Load a resource from the classpath.
static Class loadClass(String className)
          Load a class by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassLoaderUtils

public ClassLoaderUtils()
Method Detail

getClassLoader

public static ClassLoader getClassLoader()
Get the class loader which can be used to generate proxies without leaking memory.

Returns:
the class loader which can be used to generate proxies without leaking memory.

loadClass

public static Class loadClass(String className)
                       throws ClassNotFoundException
Load a class by name. Tries the current thread's context loader then falls back to Class.forName(String).

Parameters:
className - name of the class to load.
Returns:
the loaded class.
Throws:
ClassNotFoundException - if the class cannot be found in the classpath.

getResourceAsStream

public static InputStream getResourceAsStream(String resourceName)
Load a resource from the classpath. Tries the current thread's context loader then falls back to ClassLoader.getResourceAsStream(String) using this class' classloader.

Parameters:
resourceName - the resource name to load.
Returns:
a InputStream if the resource could be found, null otherwise.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/Scheduler.html0000644000175000017500000006231312215446622021556 0ustar tonytony Scheduler (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class Scheduler<T>

java.lang.Object
  extended by bitronix.tm.utils.Scheduler<T>
All Implemented Interfaces:
Iterable<T>

public class Scheduler<T>
extends Object
implements Iterable<T>

Positional object container. Objects can be added to a scheduler at a certain position (or priority) and can be retrieved later on in their position + added order. All the objects of a scheduler can be iterated in order or objects of a cetain position can be retrieved for iteration.

Author:
lorban

Field Summary
static Integer ALWAYS_FIRST_POSITION
           
static Integer ALWAYS_LAST_POSITION
           
static Integer DEFAULT_POSITION
           
 
Constructor Summary
Scheduler()
           
 
Method Summary
 void add(T obj, Integer position)
           
 List<T> getByNaturalOrderForPosition(Integer position)
           
 List<T> getByReverseOrderForPosition(Integer position)
           
 SortedSet<Integer> getNaturalOrderPositions()
           
 SortedSet<Integer> getReverseOrderPositions()
           
 Iterator<T> iterator()
           
 void remove(T obj)
           
 Iterator<T> reverseIterator()
           
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_POSITION

public static final Integer DEFAULT_POSITION

ALWAYS_FIRST_POSITION

public static final Integer ALWAYS_FIRST_POSITION

ALWAYS_LAST_POSITION

public static final Integer ALWAYS_LAST_POSITION
Constructor Detail

Scheduler

public Scheduler()
Method Detail

add

public void add(T obj,
                Integer position)

remove

public void remove(T obj)

getNaturalOrderPositions

public SortedSet<Integer> getNaturalOrderPositions()

getReverseOrderPositions

public SortedSet<Integer> getReverseOrderPositions()

getByNaturalOrderForPosition

public List<T> getByNaturalOrderForPosition(Integer position)

getByReverseOrderForPosition

public List<T> getByReverseOrderForPosition(Integer position)

size

public int size()

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>

reverseIterator

public Iterator<T> reverseIterator()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/Encoder.html0000644000175000017500000003357712215446622021231 0ustar tonytony Encoder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class Encoder

java.lang.Object
  extended by bitronix.tm.utils.Encoder

public class Encoder
extends Object

Number to byte array and byte array to number encoder.

Author:
lorban

Constructor Summary
Encoder()
           
 
Method Summary
static int bytesToInt(byte[] bytes, int pos)
           
static long bytesToLong(byte[] bytes, int pos)
           
static byte[] intToBytes(int anInt)
           
static byte[] longToBytes(long aLong)
           
static byte[] shortToBytes(short aShort)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Encoder

public Encoder()
Method Detail

longToBytes

public static byte[] longToBytes(long aLong)

intToBytes

public static byte[] intToBytes(int anInt)

shortToBytes

public static byte[] shortToBytes(short aShort)

bytesToLong

public static long bytesToLong(byte[] bytes,
                               int pos)

bytesToInt

public static int bytesToInt(byte[] bytes,
                             int pos)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/CryptoEngine.html0000644000175000017500000005154612215446622022254 0ustar tonytony CryptoEngine (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class CryptoEngine

java.lang.Object
  extended by bitronix.tm.utils.CryptoEngine

public class CryptoEngine
extends Object

Simple crypto helper that uses symetric keys to crypt and decrypt resources passwords.

Author:
lorban

Constructor Summary
CryptoEngine()
           
 
Method Summary
static String crypt(String cipher, String data)
          Crypt the given data using the given cipher.
static String decrypt(String cipher, String data)
          Decrypt using the given cipher the given base64-encoded, crypted data.
static void main(String[] args)
          Main method of this class to be used as a command-line tool to get a crypted version of a resource password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CryptoEngine

public CryptoEngine()
Method Detail

crypt

public static String crypt(String cipher,
                           String data)
                    throws InvalidKeyException,
                           NoSuchAlgorithmException,
                           NoSuchPaddingException,
                           InvalidKeySpecException,
                           IOException
Crypt the given data using the given cipher. The crypted result is base64-encoded before it is returned.

Parameters:
cipher - the cypther to use.
data - the data to crypt.
Returns:
crypted, base64-encoded data.
Throws:
InvalidKeyException - if the given key material is shorter than 8 bytes.
NoSuchAlgorithmException - if a secret-key factory for the specified algorithm is not available in the default provider package or any of the other provider packages that were searched.
NoSuchPaddingException - if transformation contains a padding scheme that is not available.
InvalidKeySpecException - if the given key specification is inappropriate for this secret-key factory to produce a secret key.
IOException - if an I/O error occurs.

decrypt

public static String decrypt(String cipher,
                             String data)
                      throws InvalidKeyException,
                             NoSuchAlgorithmException,
                             NoSuchPaddingException,
                             InvalidKeySpecException,
                             IOException
Decrypt using the given cipher the given base64-encoded, crypted data.

Parameters:
cipher - the cypther to use.
data - the base64-encoded data to decrypt.
Returns:
decrypted data.
Throws:
InvalidKeyException - if the given key material is shorter than 8 bytes.
NoSuchAlgorithmException - if a secret-key factory for the specified algorithm is not available in the default provider package or any of the other provider packages that were searched.
NoSuchPaddingException - if transformation contains a padding scheme that is not available.
InvalidKeySpecException - if the given key specification is inappropriate for this secret-key factory to produce a secret key.
IOException - if an I/O error occurs.

main

public static void main(String[] args)
                 throws Exception
Main method of this class to be used as a command-line tool to get a crypted version of a resource password.

Parameters:
args - the command-line arguments.
Throws:
Exception - when an error occurs crypting the given resource password.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/PropertyException.html0000644000175000017500000003743112215446622023346 0ustar tonytony PropertyException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class PropertyException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by bitronix.tm.utils.PropertyException
All Implemented Interfaces:
Serializable

public class PropertyException
extends RuntimeException

Thrown by PropertyUtils when some reflection error occurs.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
PropertyException(String message)
           
PropertyException(String message, Throwable cause)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyException

public PropertyException(String message,
                         Throwable cause)

PropertyException

public PropertyException(String message)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/utils/InitializationException.html0000644000175000017500000003752612215446622024516 0ustar tonytony InitializationException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.utils
Class InitializationException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by bitronix.tm.utils.InitializationException
All Implemented Interfaces:
Serializable

public class InitializationException
extends RuntimeException

Thrown at transaction manager startup when an error occurs.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
InitializationException(String message)
           
InitializationException(String message, Throwable cause)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InitializationException

public InitializationException(String message)

InitializationException

public InitializationException(String message,
                               Throwable cause)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/BitronixTransactionMBean.html0000644000175000017500000002730312215446620023405 0ustar tonytony BitronixTransactionMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Interface BitronixTransactionMBean

All Known Implementing Classes:
BitronixTransaction

public interface BitronixTransactionMBean

BitronixTransaction Management interface.

Author:
lorban

Method Summary
 Collection getEnlistedResourcesUniqueNames()
           
 String getGtrid()
           
 Date getStartDate()
           
 String getStatusDescription()
           
 String getThreadName()
           
 

Method Detail

getGtrid

String getGtrid()

getStatusDescription

String getStatusDescription()

getThreadName

String getThreadName()

getStartDate

Date getStartDate()

getEnlistedResourcesUniqueNames

Collection getEnlistedResourcesUniqueNames()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/package-tree.html0000644000175000017500000002330712215446622021030 0ustar tonytony bitronix.tm Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/0000755000175000017500000000000012215446622017443 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/recovery/package-frame.html0000644000175000017500000000363112215446622023017 0ustar tonytony bitronix.tm.recovery (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.recovery
Interfaces 
RecovererMBean
Classes 
DanglingTransaction
IncrementalRecoverer
Recoverer
RecoveryHelper
Exceptions 
RecoveryException
btm-dist-2.1.4/doc/api/bitronix/tm/recovery/DanglingTransaction.html0000644000175000017500000003617312215446620024272 0ustar tonytony DanglingTransaction (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.recovery
Class DanglingTransaction

java.lang.Object
  extended by bitronix.tm.recovery.DanglingTransaction

public final class DanglingTransaction
extends Object

Simple bean containing a unique resource name paired with a XID corresponding to a branch on that resource.

Author:
lorban

Constructor Summary
DanglingTransaction(String uniqueName, Xid xid)
           
 
Method Summary
 boolean equals(Object obj)
           
 String getUniqueName()
           
 Xid getXid()
           
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DanglingTransaction

public DanglingTransaction(String uniqueName,
                           Xid xid)
Method Detail

getUniqueName

public String getUniqueName()

getXid

public Xid getXid()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/RecoveryHelper.html0000644000175000017500000004207412215446620023274 0ustar tonytony RecoveryHelper (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.recovery
Class RecoveryHelper

java.lang.Object
  extended by bitronix.tm.recovery.RecoveryHelper

public class RecoveryHelper
extends Object

Reovery helper methods.

Author:
lorban

Constructor Summary
RecoveryHelper()
           
 
Method Summary
static boolean commit(XAResourceHolderState xaResourceHolderState, Xid xid)
          Commit the specified branch of a dangling transaction.
static Set<BitronixXid> recover(XAResourceHolderState xaResourceHolderState)
          Run the recovery process on the target resource.
static boolean rollback(XAResourceHolderState xaResourceHolderState, Xid xid)
          Rollback the specified branch of a dangling transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecoveryHelper

public RecoveryHelper()
Method Detail

recover

public static Set<BitronixXid> recover(XAResourceHolderState xaResourceHolderState)
                                throws XAException
Run the recovery process on the target resource.

Parameters:
xaResourceHolderState - the XAResourceHolderState to recover.
Returns:
a Set of BitronixXids.
Throws:
XAException - if XAResource.recover(int) calls fail.

commit

public static boolean commit(XAResourceHolderState xaResourceHolderState,
                             Xid xid)
Commit the specified branch of a dangling transaction.

Parameters:
xaResourceHolderState - the XAResourceHolderState to commit the branch on.
xid - the Xid to commit.
Returns:
true when commit was successful.

rollback

public static boolean rollback(XAResourceHolderState xaResourceHolderState,
                               Xid xid)
Rollback the specified branch of a dangling transaction.

Parameters:
xaResourceHolderState - the XAResourceHolderState to rollback the branch on.
xid - the Xid to rollback.
Returns:
true when rollback was successful.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/package-tree.html0000644000175000017500000002004612215446622022663 0ustar tonytony bitronix.tm.recovery Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.recovery

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/Recoverer.html0000644000175000017500000006153312215446620022273 0ustar tonytony Recoverer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.recovery
Class Recoverer

java.lang.Object
  extended by bitronix.tm.recovery.Recoverer
All Implemented Interfaces:
RecovererMBean, Service, Runnable

public class Recoverer
extends Object
implements Runnable, Service, RecovererMBean

Recovery process implementation. Here is Mike Spille's description of XA recovery:

Straight Line Recovery:

  • 1. Find transactions that the TM considers dangling and unresolved
  • 2. Find and reconstitute any XAResources which were being used when chunk blowing occured.
  • 3. Call the recover() method on each of these XAResources.
  • 4. Throw out any Xid's in the XAResource' recover lists which are not owned by this TM.
  • 5. Correlate Xid's that the TM knows about with remaining Xid's that the XAResources reported.
  • 6. For XAResource Xid's that match the global transaction ID which the TM found dangling with a "Committing..." record, call commit() on those XAResources for those Xids.
  • 7. For XAResource Xid's that do not match any dangling "Committing..." records, call rollback() on those XAResources for those Xids.
Exceptional conditions:
  • 1. For any rollback() calls from step 6 which reported a Heuristic Commit, you are in danger or doubt, so run in circles, scream and shout.
  • 2. For any commit() calls from step 7 which reported a Heuristic Rollback, you are in danger or doubt, so run in circles, scream and shout.
  • 3. For any resource you can't reconstitute in in step #2, or who fails on recover in step #3, or who reports anything like an XAER_RMFAILURE in step 6 or step 7, keep trying to contact them in some implementation defined manner.
  • 4. For any heuristic outcome you see reported from an XAResource, call forget() for that XAResource/Xid pair so that the resource can stop holding onto a reference to that transaction

To achieve this, Recoverer must have access to all previously used resources, even if the journal contains no trace of some of them. There are two ways of achieving this: either you use the ResourceLoader to configure all your resources and everything will be working automatically or by making sure resources are re-created and re-registered.

Those are the three steps of the Bitronix implementation:

  • call recover() on all known resources (Mike's steps 1 to 5)
  • commit dangling COMMITTING transactions (Mike's step 6)
  • rollback any remaining recovered transaction (Mike's step 7)

Author:
lorban

Constructor Summary
Recoverer()
           
 
Method Summary
 int getCommittedCount()
          Get the amount of transactions committed during the last recovery run.
 Exception getCompletionException()
          Get the exception reported when recovery failed.
 int getExecutionsCount()
          Get how many times the recoverer has run since the transaction manager started.
 int getRolledbackCount()
          Get the amount of transactions rolled back during the last recovery run.
 boolean isRunning()
          Check if the recoverer currently is running.
 void run()
          Run the recovery process.
 void shutdown()
          Shutdown the service and free all held resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Recoverer

public Recoverer()
Method Detail

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service

run

public void run()
Run the recovery process. This method is automatically called by the transaction manager, you should never call it manually.

Specified by:
run in interface RecovererMBean
Specified by:
run in interface Runnable

getCompletionException

public Exception getCompletionException()
Get the exception reported when recovery failed.

Specified by:
getCompletionException in interface RecovererMBean
Returns:
the exception that made recovery fail or null if last recovery execution was successful.

getCommittedCount

public int getCommittedCount()
Get the amount of transactions committed during the last recovery run.

Specified by:
getCommittedCount in interface RecovererMBean
Returns:
the amount of committed transactions.

getRolledbackCount

public int getRolledbackCount()
Get the amount of transactions rolled back during the last recovery run.

Specified by:
getRolledbackCount in interface RecovererMBean
Returns:
the amount of rolled back transactions.

getExecutionsCount

public int getExecutionsCount()
Get how many times the recoverer has run since the transaction manager started.

Specified by:
getExecutionsCount in interface RecovererMBean
Returns:
how many times the recoverer has run since the transaction manager started.

isRunning

public boolean isRunning()
Check if the recoverer currently is running.

Specified by:
isRunning in interface RecovererMBean
Returns:
true if the recoverer currently is running, false otherwise.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/package-use.html0000644000175000017500000003303412215446622022521 0ustar tonytony Uses of Package bitronix.tm.recovery (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.recovery

Packages that use bitronix.tm.recovery
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource Transaction Manager's resource management services. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
bitronix.tm.timer Timed tasks scheduler. 
 

Classes in bitronix.tm.recovery used by bitronix.tm
Recoverer
          Recovery process implementation.
 

Classes in bitronix.tm.recovery used by bitronix.tm.recovery
RecovererMBean
          Recoverer Management interface.
RecoveryException
          Thrown when an error occurs during recovery.
 

Classes in bitronix.tm.recovery used by bitronix.tm.resource
RecoveryException
          Thrown when an error occurs during recovery.
 

Classes in bitronix.tm.recovery used by bitronix.tm.resource.common
RecoveryException
          Thrown when an error occurs during recovery.
 

Classes in bitronix.tm.recovery used by bitronix.tm.resource.ehcache
RecoveryException
          Thrown when an error occurs during recovery.
 

Classes in bitronix.tm.recovery used by bitronix.tm.resource.jdbc
RecoveryException
          Thrown when an error occurs during recovery.
 

Classes in bitronix.tm.recovery used by bitronix.tm.resource.jms
RecoveryException
          Thrown when an error occurs during recovery.
 

Classes in bitronix.tm.recovery used by bitronix.tm.timer
Recoverer
          Recovery process implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/IncrementalRecoverer.html0000644000175000017500000003142112215446620024446 0ustar tonytony IncrementalRecoverer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.recovery
Class IncrementalRecoverer

java.lang.Object
  extended by bitronix.tm.recovery.IncrementalRecoverer

public class IncrementalRecoverer
extends Object

Incremental resource recoverer.

Author:
lorban

Constructor Summary
IncrementalRecoverer()
           
 
Method Summary
static void recover(XAResourceProducer xaResourceProducer)
          Run incremental recovery on the specified resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IncrementalRecoverer

public IncrementalRecoverer()
Method Detail

recover

public static void recover(XAResourceProducer xaResourceProducer)
                    throws RecoveryException
Run incremental recovery on the specified resource.

Parameters:
xaResourceProducer - the resource to recover.
Throws:
RecoveryException - when an error preventing recovery happens.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/RecoveryException.html0000644000175000017500000003672312215446620024017 0ustar tonytony RecoveryException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.recovery
Class RecoveryException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by bitronix.tm.recovery.RecoveryException
All Implemented Interfaces:
Serializable

public class RecoveryException
extends Exception

Thrown when an error occurs during recovery.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
RecoveryException(String message)
           
RecoveryException(String message, Throwable cause)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecoveryException

public RecoveryException(String message,
                         Throwable cause)

RecoveryException

public RecoveryException(String message)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/class-use/0000755000175000017500000000000012215446622021342 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/recovery/class-use/DanglingTransaction.html0000644000175000017500000001377412215446622026175 0ustar tonytony Uses of Class bitronix.tm.recovery.DanglingTransaction (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.recovery.DanglingTransaction

No usage of bitronix.tm.recovery.DanglingTransaction



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/class-use/RecoveryHelper.html0000644000175000017500000001371212215446622025172 0ustar tonytony Uses of Class bitronix.tm.recovery.RecoveryHelper (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.recovery.RecoveryHelper

No usage of bitronix.tm.recovery.RecoveryHelper



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/class-use/Recoverer.html0000644000175000017500000002627012215446622024173 0ustar tonytony Uses of Class bitronix.tm.recovery.Recoverer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.recovery.Recoverer

Packages that use Recoverer
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.timer Timed tasks scheduler. 
 

Uses of Recoverer in bitronix.tm
 

Methods in bitronix.tm that return Recoverer
static Recoverer TransactionManagerServices.getRecoverer()
          Create the transaction recoverer.
 

Uses of Recoverer in bitronix.tm.timer
 

Methods in bitronix.tm.timer with parameters of type Recoverer
 void TaskScheduler.cancelRecovery(Recoverer recoverer)
          Cancel the task that will run background recovery at the specified date.
 void TaskScheduler.scheduleRecovery(Recoverer recoverer, Date executionTime)
          Schedule a task that will run background recovery at the specified date.
 

Constructors in bitronix.tm.timer with parameters of type Recoverer
RecoveryTask(Recoverer recoverer, Date executionTime, TaskScheduler scheduler)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/class-use/IncrementalRecoverer.html0000644000175000017500000001400612215446622026347 0ustar tonytony Uses of Class bitronix.tm.recovery.IncrementalRecoverer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.recovery.IncrementalRecoverer

No usage of bitronix.tm.recovery.IncrementalRecoverer



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/class-use/RecoveryException.html0000644000175000017500000004446312215446622025720 0ustar tonytony Uses of Class bitronix.tm.recovery.RecoveryException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.recovery.RecoveryException

Packages that use RecoveryException
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource Transaction Manager's resource management services. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of RecoveryException in bitronix.tm.recovery
 

Methods in bitronix.tm.recovery that throw RecoveryException
static void IncrementalRecoverer.recover(XAResourceProducer xaResourceProducer)
          Run incremental recovery on the specified resource.
 

Uses of RecoveryException in bitronix.tm.resource
 

Methods in bitronix.tm.resource that throw RecoveryException
static void ResourceRegistrar.register(XAResourceProducer producer)
          Register a XAResourceProducer.
 

Uses of RecoveryException in bitronix.tm.resource.common
 

Methods in bitronix.tm.resource.common that throw RecoveryException
 void XAResourceProducer.endRecovery()
          Release internal resources held after call to startRecovery().
 XAResourceHolderState XAResourceProducer.startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 

Uses of RecoveryException in bitronix.tm.resource.ehcache
 

Methods in bitronix.tm.resource.ehcache that throw RecoveryException
 void EhCacheXAResourceProducer.endRecovery()
          Release internal resources held after call to startRecovery().
 XAResourceHolderState EhCacheXAResourceProducer.startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 

Uses of RecoveryException in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc that throw RecoveryException
 void PoolingDataSource.endRecovery()
           
 XAResourceHolderState PoolingDataSource.startRecovery()
           
 

Uses of RecoveryException in bitronix.tm.resource.jms
 

Methods in bitronix.tm.resource.jms that throw RecoveryException
 void PoolingConnectionFactory.endRecovery()
           
 XAResourceHolderState PoolingConnectionFactory.startRecovery()
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/class-use/RecovererMBean.html0000644000175000017500000001727112215446622025077 0ustar tonytony Uses of Interface bitronix.tm.recovery.RecovererMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.recovery.RecovererMBean

Packages that use RecovererMBean
bitronix.tm.recovery Recovery logic. 
 

Uses of RecovererMBean in bitronix.tm.recovery
 

Classes in bitronix.tm.recovery that implement RecovererMBean
 class Recoverer
          Recovery process implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/package-summary.html0000644000175000017500000002062012215446622023417 0ustar tonytony bitronix.tm.recovery (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.recovery

Recovery logic.

See:
          Description

Interface Summary
RecovererMBean Recoverer Management interface.
 

Class Summary
DanglingTransaction Simple bean containing a unique resource name paired with a XID corresponding to a branch on that resource.
IncrementalRecoverer Incremental resource recoverer.
Recoverer Recovery process implementation.
RecoveryHelper Reovery helper methods.
 

Exception Summary
RecoveryException Thrown when an error occurs during recovery.
 

Package bitronix.tm.recovery Description

Recovery logic.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/recovery/RecovererMBean.html0000644000175000017500000002602512215446620023173 0ustar tonytony RecovererMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.recovery
Interface RecovererMBean

All Known Implementing Classes:
Recoverer

public interface RecovererMBean

Recoverer Management interface.

Author:
lorban

Method Summary
 int getCommittedCount()
           
 Exception getCompletionException()
           
 int getExecutionsCount()
           
 int getRolledbackCount()
           
 boolean isRunning()
           
 void run()
           
 

Method Detail

run

void run()

getCommittedCount

int getCommittedCount()

getRolledbackCount

int getRolledbackCount()

getCompletionException

Exception getCompletionException()

getExecutionsCount

int getExecutionsCount()

isRunning

boolean isRunning()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/jndi/0000755000175000017500000000000012215446622016531 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/jndi/package-frame.html0000644000175000017500000000213212215446622022100 0ustar tonytony bitronix.tm.jndi (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.jndi
Classes 
BitronixContext
BitronixInitialContextFactory
btm-dist-2.1.4/doc/api/bitronix/tm/jndi/BitronixInitialContextFactory.html0000644000175000017500000003774512215446620025442 0ustar tonytony BitronixInitialContextFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.jndi
Class BitronixInitialContextFactory

java.lang.Object
  extended by bitronix.tm.jndi.BitronixInitialContextFactory
All Implemented Interfaces:
InitialContextFactory

public class BitronixInitialContextFactory
extends Object
implements InitialContextFactory

Implementation of InitialContextFactory that allows lookup of transaction manager and registered resources.

The easiest way to use this provider is to create a jndi.properties file in your classpath with this content:

java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
Alternatively, you can create a InitialContext object with an environment pointing to this class:
 Hashtable env = new Hashtable();
 env.put(Context.INITIAL_CONTEXT_FACTORY, "bitronix.tm.jndi.BitronixInitialContextFactory");
 Context ctx = new InitialContext(env);
 

The transaction manager can be looked up at the standard URL java:comp/UserTransaction while resources can be looked up using their unique name as set in ResourceBean.getUniqueName().

Author:
lorban
See Also:
BitronixContext

Constructor Summary
BitronixInitialContextFactory()
           
 
Method Summary
 Context getInitialContext(Hashtable hashtable)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixInitialContextFactory

public BitronixInitialContextFactory()
Method Detail

getInitialContext

public Context getInitialContext(Hashtable hashtable)
                          throws NamingException
Specified by:
getInitialContext in interface InitialContextFactory
Throws:
NamingException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/jndi/package-tree.html0000644000175000017500000001540112215446622021750 0ustar tonytony bitronix.tm.jndi Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.jndi

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/jndi/BitronixContext.html0000644000175000017500000021523312215446620022566 0ustar tonytony BitronixContext (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.jndi
Class BitronixContext

java.lang.Object
  extended by bitronix.tm.jndi.BitronixContext
All Implemented Interfaces:
Context

public class BitronixContext
extends Object
implements Context

Implementation of Context that allows lookup of transaction manager and registered resources.

This implementation is trivial as only the lookup methods are implemented, all the other ones will throw a OperationNotSupportedException.

Author:
lorban
See Also:
BitronixInitialContextFactory

Field Summary
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
BitronixContext()
           
 
Method Summary
 Object addToEnvironment(String s, Object o)
           
 void bind(Name name, Object o)
           
 void bind(String s, Object o)
           
 void close()
           
 Name composeName(Name name, Name name1)
           
 String composeName(String s, String s1)
           
 Context createSubcontext(Name name)
           
 Context createSubcontext(String s)
           
 void destroySubcontext(Name name)
           
 void destroySubcontext(String s)
           
 Hashtable<?,?> getEnvironment()
           
 String getNameInNamespace()
           
 NameParser getNameParser(Name name)
           
 NameParser getNameParser(String s)
           
 NamingEnumeration<NameClassPair> list(Name name)
           
 NamingEnumeration<NameClassPair> list(String s)
           
 NamingEnumeration<Binding> listBindings(Name name)
           
 NamingEnumeration<Binding> listBindings(String s)
           
 Object lookup(Name name)
           
 Object lookup(String s)
           
 Object lookupLink(Name name)
           
 Object lookupLink(String s)
           
 void rebind(Name name, Object o)
           
 void rebind(String s, Object o)
           
 Object removeFromEnvironment(String s)
           
 void rename(Name name, Name name1)
           
 void rename(String s, String s1)
           
 String toString()
           
 void unbind(Name name)
           
 void unbind(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixContext

public BitronixContext()
Method Detail

close

public void close()
           throws NamingException
Specified by:
close in interface Context
Throws:
NamingException

lookup

public Object lookup(Name name)
              throws NamingException
Specified by:
lookup in interface Context
Throws:
NamingException

lookup

public Object lookup(String s)
              throws NamingException
Specified by:
lookup in interface Context
Throws:
NamingException

toString

public String toString()
Overrides:
toString in class Object

bind

public void bind(Name name,
                 Object o)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException

bind

public void bind(String s,
                 Object o)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException

rebind

public void rebind(Name name,
                   Object o)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException

rebind

public void rebind(String s,
                   Object o)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException

unbind

public void unbind(Name name)
            throws NamingException
Specified by:
unbind in interface Context
Throws:
NamingException

unbind

public void unbind(String s)
            throws NamingException
Specified by:
unbind in interface Context
Throws:
NamingException

rename

public void rename(Name name,
                   Name name1)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException

rename

public void rename(String s,
                   String s1)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException

list

public NamingEnumeration<NameClassPair> list(Name name)
                                      throws NamingException
Specified by:
list in interface Context
Throws:
NamingException

list

public NamingEnumeration<NameClassPair> list(String s)
                                      throws NamingException
Specified by:
list in interface Context
Throws:
NamingException

listBindings

public NamingEnumeration<Binding> listBindings(Name name)
                                        throws NamingException
Specified by:
listBindings in interface Context
Throws:
NamingException

listBindings

public NamingEnumeration<Binding> listBindings(String s)
                                        throws NamingException
Specified by:
listBindings in interface Context
Throws:
NamingException

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
Throws:
NamingException

destroySubcontext

public void destroySubcontext(String s)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
Throws:
NamingException

createSubcontext

public Context createSubcontext(Name name)
                         throws NamingException
Specified by:
createSubcontext in interface Context
Throws:
NamingException

createSubcontext

public Context createSubcontext(String s)
                         throws NamingException
Specified by:
createSubcontext in interface Context
Throws:
NamingException

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException

lookupLink

public Object lookupLink(String s)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException

getNameParser

public NameParser getNameParser(Name name)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException

getNameParser

public NameParser getNameParser(String s)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException

composeName

public Name composeName(Name name,
                        Name name1)
                 throws NamingException
Specified by:
composeName in interface Context
Throws:
NamingException

composeName

public String composeName(String s,
                          String s1)
                   throws NamingException
Specified by:
composeName in interface Context
Throws:
NamingException

addToEnvironment

public Object addToEnvironment(String s,
                               Object o)
                        throws NamingException
Specified by:
addToEnvironment in interface Context
Throws:
NamingException

removeFromEnvironment

public Object removeFromEnvironment(String s)
                             throws NamingException
Specified by:
removeFromEnvironment in interface Context
Throws:
NamingException

getEnvironment

public Hashtable<?,?> getEnvironment()
                              throws NamingException
Specified by:
getEnvironment in interface Context
Throws:
NamingException

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Specified by:
getNameInNamespace in interface Context
Throws:
NamingException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/jndi/package-use.html0000644000175000017500000001310312215446622021602 0ustar tonytony Uses of Package bitronix.tm.jndi (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.jndi

No usage of bitronix.tm.jndi



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/jndi/class-use/0000755000175000017500000000000012215446622020430 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/jndi/class-use/BitronixInitialContextFactory.html0000644000175000017500000001407012215446622027325 0ustar tonytony Uses of Class bitronix.tm.jndi.BitronixInitialContextFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.jndi.BitronixInitialContextFactory

No usage of bitronix.tm.jndi.BitronixInitialContextFactory



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/jndi/class-use/BitronixContext.html0000644000175000017500000001365412215446622024472 0ustar tonytony Uses of Class bitronix.tm.jndi.BitronixContext (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.jndi.BitronixContext

No usage of bitronix.tm.jndi.BitronixContext



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/jndi/package-summary.html0000644000175000017500000001662212215446622022514 0ustar tonytony bitronix.tm.jndi (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.jndi

JNDI provider implementation that allows looking up transaction manager and resources.

See:
          Description

Class Summary
BitronixContext Implementation of Context that allows lookup of transaction manager and registered resources.
BitronixInitialContextFactory Implementation of InitialContextFactory that allows lookup of transaction manager and registered resources.
 

Package bitronix.tm.jndi Description

JNDI provider implementation that allows looking up transaction manager and resources.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/package-use.html0000644000175000017500000003752512215446622020674 0ustar tonytony Uses of Package bitronix.tm (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm

Packages that use bitronix.tm
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.internal Internal implementation details. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.timer Timed tasks scheduler. 
bitronix.tm.twopc Two-phase commit logic. 
bitronix.tm.utils Misc utility classes. 
 

Classes in bitronix.tm used by bitronix.tm
BitronixTransaction
          Implementation of Transaction.
BitronixTransactionManager
          Implementation of TransactionManager and UserTransaction.
BitronixTransactionManagerObjectFactory
          BitronixTransactionManager object factory for JNDI references.
BitronixTransactionMBean
          BitronixTransaction Management interface.
BitronixTransactionSynchronizationRegistry
          Implementation of JTA 1.1 TransactionSynchronizationRegistry.
Configuration
          Configuration repository of the transaction manager.
 

Classes in bitronix.tm used by bitronix.tm.internal
BitronixTransaction
          Implementation of Transaction.
BitronixXid
          Implementation of Xid.
 

Classes in bitronix.tm used by bitronix.tm.recovery
BitronixXid
          Implementation of Xid.
 

Classes in bitronix.tm used by bitronix.tm.resource.common
BitronixTransaction
          Implementation of Transaction.
BitronixXid
          Implementation of Xid.
 

Classes in bitronix.tm used by bitronix.tm.timer
BitronixTransaction
          Implementation of Transaction.
 

Classes in bitronix.tm used by bitronix.tm.twopc
BitronixTransaction
          Implementation of Transaction.
 

Classes in bitronix.tm used by bitronix.tm.utils
BitronixXid
          Implementation of Xid.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/0000755000175000017500000000000012215446622017504 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/class-use/TransactionManagerServices.html0000644000175000017500000001366512215446622025671 0ustar tonytony Uses of Class bitronix.tm.TransactionManagerServices (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.TransactionManagerServices

No usage of bitronix.tm.TransactionManagerServices



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixUserTransactionObjectFactory.html0000644000175000017500000001403112215446622027713 0ustar tonytony Uses of Class bitronix.tm.BitronixUserTransactionObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.BitronixUserTransactionObjectFactory

No usage of bitronix.tm.BitronixUserTransactionObjectFactory



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootbtm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixTransactionSynchronizationRegistryObjectFactory.htmlbtm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixTransactionSynchronizationRegistryObjectFactory0000644000175000017500000001432712215446622032774 0ustar tonytony Uses of Class bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory

No usage of bitronix.tm.BitronixTransactionSynchronizationRegistryObjectFactory



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixTransactionMBean.html0000644000175000017500000001741712215446622025313 0ustar tonytony Uses of Interface bitronix.tm.BitronixTransactionMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.BitronixTransactionMBean

Packages that use BitronixTransactionMBean
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of BitronixTransactionMBean in bitronix.tm
 

Classes in bitronix.tm that implement BitronixTransactionMBean
 class BitronixTransaction
          Implementation of Transaction.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/Configuration.html0000644000175000017500000005413712215446622023213 0ustar tonytony Uses of Class bitronix.tm.Configuration (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.Configuration

Packages that use Configuration
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of Configuration in bitronix.tm
 

Methods in bitronix.tm that return Configuration
static Configuration TransactionManagerServices.getConfiguration()
          Create the configuration of all the components of the transaction manager.
 Configuration Configuration.setAllowMultipleLrc(boolean allowMultipleLrc)
          Set to true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction.
 Configuration Configuration.setAsynchronous2Pc(boolean asynchronous2Pc)
          Set if two phase commit should be executed asynchronously.
 Configuration Configuration.setBackgroundRecoveryInterval(int backgroundRecoveryInterval)
          Deprecated. superceded by #setBackgroundRecoveryIntervalSeconds(int).
 Configuration Configuration.setBackgroundRecoveryIntervalSeconds(int backgroundRecoveryIntervalSeconds)
          Set the interval in seconds at which to run the recovery process in the background.
 Configuration Configuration.setCurrentNodeOnlyRecovery(boolean currentNodeOnlyRecovery)
          Set to true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
 Configuration Configuration.setDebugZeroResourceTransaction(boolean debugZeroResourceTransaction)
          Set if creation and commit call stacks of transactions executed without a single enlisted resource should be tracked and logged.
 Configuration Configuration.setDefaultTransactionTimeout(int defaultTransactionTimeout)
          Set the default transaction timeout in seconds.
 Configuration Configuration.setDisableJmx(boolean disableJmx)
          Set to true if JMX Mbeans should not be registered even if a JMX MBean server is detected.
 Configuration Configuration.setExceptionAnalyzer(String exceptionAnalyzer)
          Set the exception analyzer implementation.
 Configuration Configuration.setFilterLogStatus(boolean filterLogStatus)
          Set if only mandatory logs should be written.
 Configuration Configuration.setForceBatchingEnabled(boolean forceBatchingEnabled)
          Set if disk forces are batched.
 Configuration Configuration.setForcedWriteEnabled(boolean forcedWriteEnabled)
          Set if logs are forced to disk.
 Configuration Configuration.setGracefulShutdownInterval(int gracefulShutdownInterval)
          Set the maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
 Configuration Configuration.setJndiTransactionSynchronizationRegistryName(String jndiTransactionSynchronizationRegistryName)
          Set the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
 Configuration Configuration.setJndiUserTransactionName(String jndiUserTransactionName)
          Set the name the UserTransaction should be bound under in the BitronixContext.
 Configuration Configuration.setJournal(String journal)
          Set the journal name.
 Configuration Configuration.setLogPart1Filename(String logPart1Filename)
          Set the journal fragment file 1 name.
 Configuration Configuration.setLogPart2Filename(String logPart2Filename)
          Set the journal fragment file 2 name.
 Configuration Configuration.setMaxLogSizeInMb(int maxLogSizeInMb)
          Set the Maximum size in megabytes of the journal fragments.
 Configuration Configuration.setResourceConfigurationFilename(String resourceConfigurationFilename)
          Set the ResourceLoader configuration file name.
 Configuration Configuration.setServerId(String serverId)
          Set the ASCII ID that must uniquely identify this TM instance.
 Configuration Configuration.setSkipCorruptedLogs(boolean skipCorruptedLogs)
          Set if corrupted logs should be skipped.
 Configuration Configuration.setWarnAboutZeroResourceTransaction(boolean warnAboutZeroResourceTransaction)
          Set if transactions executed without a single enlisted resource should result in a warning or not.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/Version.html0000644000175000017500000001336712215446622022031 0ustar tonytony Uses of Class bitronix.tm.Version (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.Version

No usage of bitronix.tm.Version



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixTransactionSynchronizationRegistry.html0000644000175000017500000002011612215446622031251 0ustar tonytony Uses of Class bitronix.tm.BitronixTransactionSynchronizationRegistry (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.BitronixTransactionSynchronizationRegistry

Packages that use BitronixTransactionSynchronizationRegistry
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of BitronixTransactionSynchronizationRegistry in bitronix.tm
 

Methods in bitronix.tm that return BitronixTransactionSynchronizationRegistry
static BitronixTransactionSynchronizationRegistry TransactionManagerServices.getTransactionSynchronizationRegistry()
          Create the JTA 1.1 TransactionSynchronizationRegistry.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixTransactionManager.html0000644000175000017500000001742212215446622025677 0ustar tonytony Uses of Class bitronix.tm.BitronixTransactionManager (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.BitronixTransactionManager

Packages that use BitronixTransactionManager
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of BitronixTransactionManager in bitronix.tm
 

Methods in bitronix.tm that return BitronixTransactionManager
static BitronixTransactionManager TransactionManagerServices.getTransactionManager()
          Create an initialized transaction manager.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixTransaction.html0000644000175000017500000004552312215446622024407 0ustar tonytony Uses of Class bitronix.tm.BitronixTransaction (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.BitronixTransaction

Packages that use BitronixTransaction
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.internal Internal implementation details. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.timer Timed tasks scheduler. 
bitronix.tm.twopc Two-phase commit logic. 
 

Uses of BitronixTransaction in bitronix.tm
 

Methods in bitronix.tm that return BitronixTransaction
 BitronixTransaction BitronixTransactionManager.getCurrentTransaction()
          Get the transaction currently registered on the current thread context.
 

Uses of BitronixTransaction in bitronix.tm.internal
 

Methods in bitronix.tm.internal that return BitronixTransaction
 BitronixTransaction ThreadContext.getTransaction()
          Return the transaction linked with this thread context.
 

Methods in bitronix.tm.internal with parameters of type BitronixTransaction
 void ThreadContext.setTransaction(BitronixTransaction transaction)
          Link a transaction with this thead context.
 

Uses of BitronixTransaction in bitronix.tm.resource.common
 

Methods in bitronix.tm.resource.common that return BitronixTransaction
static BitronixTransaction TransactionContextHelper.currentTransaction()
          Get the transaction running on the current thead context.
 

Uses of BitronixTransaction in bitronix.tm.timer
 

Methods in bitronix.tm.timer with parameters of type BitronixTransaction
 void TaskScheduler.cancelTransactionTimeout(BitronixTransaction transaction)
          Cancel the task that will mark the transaction as timed out at the specified date.
 void TaskScheduler.scheduleTransactionTimeout(BitronixTransaction transaction, Date executionTime)
          Schedule a task that will mark the transaction as timed out at the specified date.
 

Constructors in bitronix.tm.timer with parameters of type BitronixTransaction
TransactionTimeoutTask(BitronixTransaction transaction, Date executionTime, TaskScheduler scheduler)
           
 

Uses of BitronixTransaction in bitronix.tm.twopc
 

Methods in bitronix.tm.twopc with parameters of type BitronixTransaction
 void Committer.commit(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Execute phase 2 commit.
 List<XAResourceHolderState> Preparer.prepare(BitronixTransaction transaction)
          Execute phase 1 prepare.
 void Rollbacker.rollback(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Rollback the current XA transaction.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixXid.html0000644000175000017500000003712012215446622022640 0ustar tonytony Uses of Class bitronix.tm.BitronixXid (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.BitronixXid

Packages that use BitronixXid
bitronix.tm.internal Internal implementation details. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.utils Misc utility classes. 
 

Uses of BitronixXid in bitronix.tm.internal
 

Methods in bitronix.tm.internal that return BitronixXid
 BitronixXid XAResourceHolderState.getXid()
           
 

Methods in bitronix.tm.internal with parameters of type BitronixXid
 void XAResourceHolderState.setXid(BitronixXid xid)
           
 

Uses of BitronixXid in bitronix.tm.recovery
 

Methods in bitronix.tm.recovery that return types with arguments of type BitronixXid
static Set<BitronixXid> RecoveryHelper.recover(XAResourceHolderState xaResourceHolderState)
          Run the recovery process on the target resource.
 

Uses of BitronixXid in bitronix.tm.resource.common
 

Methods in bitronix.tm.resource.common with parameters of type BitronixXid
 void XAResourceHolder.putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState)
          Add a XAResourceHolderState of this wrapped resource.
 void AbstractXAResourceHolder.putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState)
           
 void XAResourceHolder.removeXAResourceHolderState(BitronixXid xid)
          Remove all states related to a specific Xid from this wrapped resource.
 void AbstractXAResourceHolder.removeXAResourceHolderState(BitronixXid xid)
           
 

Uses of BitronixXid in bitronix.tm.utils
 

Methods in bitronix.tm.utils that return BitronixXid
static BitronixXid UidGenerator.generateXid(Uid gtrid)
          Generate a XID with the specified globalTransactionId.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/class-use/BitronixTransactionManagerObjectFactory.html0000644000175000017500000001771712215446622030365 0ustar tonytony Uses of Class bitronix.tm.BitronixTransactionManagerObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.BitronixTransactionManagerObjectFactory

Packages that use BitronixTransactionManagerObjectFactory
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of BitronixTransactionManagerObjectFactory in bitronix.tm
 

Subclasses of BitronixTransactionManagerObjectFactory in bitronix.tm
 class BitronixUserTransactionObjectFactory
          BitronixTransactionManager object factory for JNDI references.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/Configuration.html0000644000175000017500000022177212215446620021313 0ustar tonytony Configuration (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class Configuration

java.lang.Object
  extended by bitronix.tm.Configuration
All Implemented Interfaces:
Service

public class Configuration
extends Object
implements Service

Configuration repository of the transaction manager. You can set configurable values either via the properties file or by setting properties of the Configuration object. Once the transaction manager has started it is not possible to change the configuration: all calls to setters will throw a IllegalStateException.

The configuration filename must be specified with the bitronix.tm.configuration system property.

The default settings are good enough for running in a test environment but certainly not for production usage. Also, all properties are reset to their default value after the transaction manager has shut down.

All those properties can refer to other defined ones or to system properties using the Ant notation: ${some.property.name}.

Author:
lorban

Constructor Summary
protected Configuration()
           
 
Method Summary
 byte[] buildServerIdArray()
          Build the server ID byte array that will be prepended in generated UIDs.
 int getBackgroundRecoveryInterval()
          Deprecated. superceded by #getBackgroundRecoveryIntervalSeconds().
 int getBackgroundRecoveryIntervalSeconds()
          Interval in seconds at which to run the recovery process in the background.
 int getDefaultTransactionTimeout()
          Default transaction timeout in seconds.
 String getExceptionAnalyzer()
          Get the exception analyzer implementation.
 int getGracefulShutdownInterval()
          Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
 String getJndiTransactionSynchronizationRegistryName()
          Get the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
 String getJndiUserTransactionName()
          Get the name the UserTransaction should be bound under in the BitronixContext.
 String getJournal()
          Get the journal implementation.
 String getLogPart1Filename()
          Get the journal fragment file 1 name.
 String getLogPart2Filename()
          Get the journal fragment file 2 name.
 int getMaxLogSizeInMb()
          Maximum size in megabytes of the journal fragments.
 String getResourceConfigurationFilename()
          ResourceLoader configuration file name.
 String getServerId()
          ASCII ID that must uniquely identify this TM instance.
 boolean isAllowMultipleLrc()
          Should the transaction manager allow enlistment of multiple LRC resources in a single transaction? This is highly unsafe but could be useful for testing.
 boolean isAsynchronous2Pc()
          Should two phase commit be executed asynchronously? Asynchronous two phase commit can improve performance when there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread spawning requirements.
 boolean isCurrentNodeOnlyRecovery()
          Should the recovery process not recover XIDs generated with another JVM unique ID? Setting this property to true is useful in clustered environments where multiple instances of BTM are running on different nodes.
 boolean isDebugZeroResourceTransaction()
          Should creation and commit call stacks of transactions executed without a single enlisted tracked and logged or not?
 boolean isDisableJmx()
          Should JMX Mbeans not be registered even if a JMX MBean server is detected?
 boolean isFilterLogStatus()
          Should only mandatory logs be written? Enabling this parameter lowers space usage of the fragments but makes debugging more complex.
 boolean isForceBatchingEnabled()
          Are disk forces batched? Disabling batching can seriously lower the transaction manager's throughput.
 boolean isForcedWriteEnabled()
          Are logs forced to disk? Do not set to false in production since without disk force, integrity is not guaranteed.
 boolean isSkipCorruptedLogs()
          Should corrupted logs be skipped?
 boolean isWarnAboutZeroResourceTransaction()
          Should transactions executed without a single enlisted resource result in a warning or not? Most of the time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere.
 Configuration setAllowMultipleLrc(boolean allowMultipleLrc)
          Set to true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction.
 Configuration setAsynchronous2Pc(boolean asynchronous2Pc)
          Set if two phase commit should be executed asynchronously.
 Configuration setBackgroundRecoveryInterval(int backgroundRecoveryInterval)
          Deprecated. superceded by #setBackgroundRecoveryIntervalSeconds(int).
 Configuration setBackgroundRecoveryIntervalSeconds(int backgroundRecoveryIntervalSeconds)
          Set the interval in seconds at which to run the recovery process in the background.
 Configuration setCurrentNodeOnlyRecovery(boolean currentNodeOnlyRecovery)
          Set to true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
 Configuration setDebugZeroResourceTransaction(boolean debugZeroResourceTransaction)
          Set if creation and commit call stacks of transactions executed without a single enlisted resource should be tracked and logged.
 Configuration setDefaultTransactionTimeout(int defaultTransactionTimeout)
          Set the default transaction timeout in seconds.
 Configuration setDisableJmx(boolean disableJmx)
          Set to true if JMX Mbeans should not be registered even if a JMX MBean server is detected.
 Configuration setExceptionAnalyzer(String exceptionAnalyzer)
          Set the exception analyzer implementation.
 Configuration setFilterLogStatus(boolean filterLogStatus)
          Set if only mandatory logs should be written.
 Configuration setForceBatchingEnabled(boolean forceBatchingEnabled)
          Set if disk forces are batched.
 Configuration setForcedWriteEnabled(boolean forcedWriteEnabled)
          Set if logs are forced to disk.
 Configuration setGracefulShutdownInterval(int gracefulShutdownInterval)
          Set the maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
 Configuration setJndiTransactionSynchronizationRegistryName(String jndiTransactionSynchronizationRegistryName)
          Set the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
 Configuration setJndiUserTransactionName(String jndiUserTransactionName)
          Set the name the UserTransaction should be bound under in the BitronixContext.
 Configuration setJournal(String journal)
          Set the journal name.
 Configuration setLogPart1Filename(String logPart1Filename)
          Set the journal fragment file 1 name.
 Configuration setLogPart2Filename(String logPart2Filename)
          Set the journal fragment file 2 name.
 Configuration setMaxLogSizeInMb(int maxLogSizeInMb)
          Set the Maximum size in megabytes of the journal fragments.
 Configuration setResourceConfigurationFilename(String resourceConfigurationFilename)
          Set the ResourceLoader configuration file name.
 Configuration setServerId(String serverId)
          Set the ASCII ID that must uniquely identify this TM instance.
 Configuration setSkipCorruptedLogs(boolean skipCorruptedLogs)
          Set if corrupted logs should be skipped.
 Configuration setWarnAboutZeroResourceTransaction(boolean warnAboutZeroResourceTransaction)
          Set if transactions executed without a single enlisted resource should result in a warning or not.
 void shutdown()
          Shutdown the service and free all held resources.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Configuration

protected Configuration()
Method Detail

getServerId

public String getServerId()
ASCII ID that must uniquely identify this TM instance. It must not exceed 51 characters or it will be truncated.

Property name:
bitronix.tm.serverId - (defaults to server's IP address but that's unsafe for production use)

Returns:
the unique ID of this TM instance.

setServerId

public Configuration setServerId(String serverId)
Set the ASCII ID that must uniquely identify this TM instance. It must not exceed 51 characters or it will be truncated.

Parameters:
serverId - the unique ID of this TM instance.
Returns:
this.
See Also:
getServerId()

getLogPart1Filename

public String getLogPart1Filename()
Get the journal fragment file 1 name.

Property name:
bitronix.tm.journal.disk.logPart1Filename - (defaults to btm1.tlog)

Returns:
the journal fragment file 1 name.

setLogPart1Filename

public Configuration setLogPart1Filename(String logPart1Filename)
Set the journal fragment file 1 name.

Parameters:
logPart1Filename - the journal fragment file 1 name.
Returns:
this.
See Also:
getLogPart1Filename()

getLogPart2Filename

public String getLogPart2Filename()
Get the journal fragment file 2 name.

Property name:
bitronix.tm.journal.disk.logPart2Filename - (defaults to btm2.tlog)

Returns:
the journal fragment file 2 name.

setLogPart2Filename

public Configuration setLogPart2Filename(String logPart2Filename)
Set the journal fragment file 2 name.

Parameters:
logPart2Filename - the journal fragment file 2 name.
Returns:
this.
See Also:
getLogPart2Filename()

isForcedWriteEnabled

public boolean isForcedWriteEnabled()
Are logs forced to disk? Do not set to false in production since without disk force, integrity is not guaranteed.

Property name:
bitronix.tm.journal.disk.forcedWriteEnabled - (defaults to true)

Returns:
true if logs are forced to disk, false otherwise.

setForcedWriteEnabled

public Configuration setForcedWriteEnabled(boolean forcedWriteEnabled)
Set if logs are forced to disk. Do not set to false in production since without disk force, integrity is not guaranteed.

Parameters:
forcedWriteEnabled - true if logs should be forced to disk, false otherwise.
Returns:
this.
See Also:
isForcedWriteEnabled()

isForceBatchingEnabled

public boolean isForceBatchingEnabled()
Are disk forces batched? Disabling batching can seriously lower the transaction manager's throughput.

Property name:
bitronix.tm.journal.disk.forceBatchingEnabled - (defaults to true)

Returns:
true if disk forces are batched, false otherwise.

setForceBatchingEnabled

public Configuration setForceBatchingEnabled(boolean forceBatchingEnabled)
Set if disk forces are batched. Disabling batching can seriously lower the transaction manager's throughput.

Parameters:
forceBatchingEnabled - true if disk forces are batched, false otherwise.
Returns:
this.
See Also:
isForceBatchingEnabled()

getMaxLogSizeInMb

public int getMaxLogSizeInMb()
Maximum size in megabytes of the journal fragments. Larger logs allow transactions to stay longer in-doubt but the TM pauses longer when a fragment is full.

Property name:
bitronix.tm.journal.disk.maxLogSize - (defaults to 2)

Returns:
the maximum size in megabytes of the journal fragments.

setMaxLogSizeInMb

public Configuration setMaxLogSizeInMb(int maxLogSizeInMb)
Set the Maximum size in megabytes of the journal fragments. Larger logs allow transactions to stay longer in-doubt but the TM pauses longer when a fragment is full.

Parameters:
maxLogSizeInMb - the maximum size in megabytes of the journal fragments.
Returns:
this.
See Also:
getMaxLogSizeInMb()

isFilterLogStatus

public boolean isFilterLogStatus()
Should only mandatory logs be written? Enabling this parameter lowers space usage of the fragments but makes debugging more complex.

Property name:
bitronix.tm.journal.disk.filterLogStatus - (defaults to false)

Returns:
true if only mandatory logs should be written.

setFilterLogStatus

public Configuration setFilterLogStatus(boolean filterLogStatus)
Set if only mandatory logs should be written. Enabling this parameter lowers space usage of the fragments but makes debugging more complex.

Parameters:
filterLogStatus - true if only mandatory logs should be written.
Returns:
this.
See Also:
isFilterLogStatus()

isSkipCorruptedLogs

public boolean isSkipCorruptedLogs()
Should corrupted logs be skipped?

Property name:
bitronix.tm.journal.disk.skipCorruptedLogs - (defaults to false)

Returns:
true if corrupted logs should be skipped.

setSkipCorruptedLogs

public Configuration setSkipCorruptedLogs(boolean skipCorruptedLogs)
Set if corrupted logs should be skipped.

Parameters:
skipCorruptedLogs - true if corrupted logs should be skipped.
Returns:
this.
See Also:
isSkipCorruptedLogs()

isAsynchronous2Pc

public boolean isAsynchronous2Pc()
Should two phase commit be executed asynchronously? Asynchronous two phase commit can improve performance when there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread spawning requirements. It also makes debugging more complex.

Property name:
bitronix.tm.2pc.async - (defaults to false)

Returns:
true if two phase commit should be executed asynchronously.

setAsynchronous2Pc

public Configuration setAsynchronous2Pc(boolean asynchronous2Pc)
Set if two phase commit should be executed asynchronously. Asynchronous two phase commit can improve performance when there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread spawning requirements. It also makes debugging more complex.

Parameters:
asynchronous2Pc - true if two phase commit should be executed asynchronously.
Returns:
this.
See Also:
isAsynchronous2Pc()

isWarnAboutZeroResourceTransaction

public boolean isWarnAboutZeroResourceTransaction()
Should transactions executed without a single enlisted resource result in a warning or not? Most of the time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere.

Property name:
bitronix.tm.2pc.warnAboutZeroResourceTransactions - (defaults to true)

Returns:
true if transactions executed without a single enlisted resource should result in a warning.

setWarnAboutZeroResourceTransaction

public Configuration setWarnAboutZeroResourceTransaction(boolean warnAboutZeroResourceTransaction)
Set if transactions executed without a single enlisted resource should result in a warning or not. Most of the time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere.

Parameters:
warnAboutZeroResourceTransaction - true if transactions executed without a single enlisted resource should result in a warning.
Returns:
this.
See Also:
isWarnAboutZeroResourceTransaction()

isDebugZeroResourceTransaction

public boolean isDebugZeroResourceTransaction()
Should creation and commit call stacks of transactions executed without a single enlisted tracked and logged or not?

Property name:
bitronix.tm.2pc.debugZeroResourceTransactions - (defaults to false)

Returns:
true if creation and commit call stacks of transactions executed without a single enlisted resource should be tracked and logged.

setDebugZeroResourceTransaction

public Configuration setDebugZeroResourceTransaction(boolean debugZeroResourceTransaction)
Set if creation and commit call stacks of transactions executed without a single enlisted resource should be tracked and logged.

Parameters:
debugZeroResourceTransaction - true if the creation and commit call stacks of transaction executed without a single enlisted resource should be tracked and logged.
Returns:
this.
See Also:
isDebugZeroResourceTransaction(), isWarnAboutZeroResourceTransaction()

getDefaultTransactionTimeout

public int getDefaultTransactionTimeout()
Default transaction timeout in seconds.

Property name:
bitronix.tm.timer.defaultTransactionTimeout - (defaults to 60)

Returns:
the default transaction timeout in seconds.

setDefaultTransactionTimeout

public Configuration setDefaultTransactionTimeout(int defaultTransactionTimeout)
Set the default transaction timeout in seconds.

Parameters:
defaultTransactionTimeout - the default transaction timeout in seconds.
Returns:
this.
See Also:
getDefaultTransactionTimeout()

getGracefulShutdownInterval

public int getGracefulShutdownInterval()
Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.

Property name:
bitronix.tm.timer.gracefulShutdownInterval - (defaults to 60)

Returns:
the maximum amount of time in seconds.

setGracefulShutdownInterval

public Configuration setGracefulShutdownInterval(int gracefulShutdownInterval)
Set the maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.

Parameters:
gracefulShutdownInterval - the maximum amount of time in seconds.
Returns:
this.
See Also:
getGracefulShutdownInterval()

getBackgroundRecoveryInterval

public int getBackgroundRecoveryInterval()
Deprecated. superceded by #getBackgroundRecoveryIntervalSeconds().

Interval in minutes at which to run the recovery process in the background. Disabled when set to 0.

Property name:
bitronix.tm.timer.backgroundRecoveryInterval - (defaults to 0)

Returns:
the interval in minutes.

setBackgroundRecoveryInterval

public Configuration setBackgroundRecoveryInterval(int backgroundRecoveryInterval)
Deprecated. superceded by #setBackgroundRecoveryIntervalSeconds(int).

Set the interval in minutes at which to run the recovery process in the background. Disabled when set to 0.

Parameters:
backgroundRecoveryInterval - the interval in minutes.
Returns:
this.
See Also:
getBackgroundRecoveryInterval()

getBackgroundRecoveryIntervalSeconds

public int getBackgroundRecoveryIntervalSeconds()
Interval in seconds at which to run the recovery process in the background. Disabled when set to 0.

Property name:
bitronix.tm.timer.backgroundRecoveryIntervalSeconds - (defaults to 60)

Returns:
the interval in seconds.

setBackgroundRecoveryIntervalSeconds

public Configuration setBackgroundRecoveryIntervalSeconds(int backgroundRecoveryIntervalSeconds)
Set the interval in seconds at which to run the recovery process in the background. Disabled when set to 0.

Parameters:
backgroundRecoveryIntervalSeconds - the interval in minutes.
Returns:
this.
See Also:
getBackgroundRecoveryIntervalSeconds()

isDisableJmx

public boolean isDisableJmx()
Should JMX Mbeans not be registered even if a JMX MBean server is detected?

Property name:
bitronix.tm.disableJmx - (defaults to false)

Returns:
true if JMX MBeans should never be registered.

setDisableJmx

public Configuration setDisableJmx(boolean disableJmx)
Set to true if JMX Mbeans should not be registered even if a JMX MBean server is detected.

Parameters:
disableJmx - true if JMX MBeans should never be registered.
Returns:
this.
See Also:
isDisableJmx()

getJndiUserTransactionName

public String getJndiUserTransactionName()
Get the name the UserTransaction should be bound under in the BitronixContext.

Returns:
the name the UserTransaction should be bound under in the BitronixContext.

setJndiUserTransactionName

public Configuration setJndiUserTransactionName(String jndiUserTransactionName)
Set the name the UserTransaction should be bound under in the BitronixContext.

Parameters:
jndiUserTransactionName - the name the UserTransaction should be bound under in the BitronixContext.
Returns:
this.
See Also:
getJndiUserTransactionName()

getJndiTransactionSynchronizationRegistryName

public String getJndiTransactionSynchronizationRegistryName()
Get the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.

Returns:
the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.

setJndiTransactionSynchronizationRegistryName

public Configuration setJndiTransactionSynchronizationRegistryName(String jndiTransactionSynchronizationRegistryName)
Set the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.

Parameters:
jndiTransactionSynchronizationRegistryName - the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
Returns:
this.
See Also:
getJndiUserTransactionName()

getJournal

public String getJournal()
Get the journal implementation. Can be disk, null or a class name.

Returns:
the journal name.

setJournal

public Configuration setJournal(String journal)
Set the journal name. Can be disk, null or a class name.

Parameters:
journal - the journal name.
Returns:
this.
See Also:
getJournal()

getExceptionAnalyzer

public String getExceptionAnalyzer()
Get the exception analyzer implementation. Can be null for the default one or a class name.

Returns:
the exception analyzer name.

setExceptionAnalyzer

public Configuration setExceptionAnalyzer(String exceptionAnalyzer)
Set the exception analyzer implementation. Can be null for the default one or a class name.

Parameters:
exceptionAnalyzer - the exception analyzer name.
Returns:
this.
See Also:
getExceptionAnalyzer()

isCurrentNodeOnlyRecovery

public boolean isCurrentNodeOnlyRecovery()
Should the recovery process not recover XIDs generated with another JVM unique ID? Setting this property to true is useful in clustered environments where multiple instances of BTM are running on different nodes.

Returns:
true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
See Also:
contains the value used as the JVM unique ID.

setCurrentNodeOnlyRecovery

public Configuration setCurrentNodeOnlyRecovery(boolean currentNodeOnlyRecovery)
Set to true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.

Parameters:
currentNodeOnlyRecovery - true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
Returns:
this.
See Also:
isCurrentNodeOnlyRecovery()

isAllowMultipleLrc

public boolean isAllowMultipleLrc()
Should the transaction manager allow enlistment of multiple LRC resources in a single transaction? This is highly unsafe but could be useful for testing.

Returns:
true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction, false otherwise.

setAllowMultipleLrc

public Configuration setAllowMultipleLrc(boolean allowMultipleLrc)
Set to true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction.

Parameters:
allowMultipleLrc - true if the transaction manager should allow enlistment of multiple LRC resources in a single transaction, false otherwise.
Returns:
this

getResourceConfigurationFilename

public String getResourceConfigurationFilename()
ResourceLoader configuration file name. ResourceLoader will be disabled if this value is null.

Property name:
bitronix.tm.resource.configuration - (defaults to null)

Returns:
the filename of the resources configuration file or null if not configured.

setResourceConfigurationFilename

public Configuration setResourceConfigurationFilename(String resourceConfigurationFilename)
Set the ResourceLoader configuration file name.

Parameters:
resourceConfigurationFilename - the filename of the resources configuration file or null you do not want to use the ResourceLoader.
Returns:
this.
See Also:
getResourceConfigurationFilename()

buildServerIdArray

public byte[] buildServerIdArray()
Build the server ID byte array that will be prepended in generated UIDs. Once built, the value is cached for the duration of the JVM lifespan.

Returns:
the server ID.

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/package-summary.html0000644000175000017500000002463712215446622021575 0ustar tonytony bitronix.tm (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm

JTA interfaces implementations and global services.

See:
          Description

Interface Summary
BitronixTransactionMBean BitronixTransaction Management interface.
 

Class Summary
BitronixTransaction Implementation of Transaction.
BitronixTransactionManager Implementation of TransactionManager and UserTransaction.
BitronixTransactionManagerObjectFactory BitronixTransactionManager object factory for JNDI references.
BitronixTransactionSynchronizationRegistry Implementation of JTA 1.1 TransactionSynchronizationRegistry.
BitronixTransactionSynchronizationRegistryObjectFactory BitronixTransactionSynchronizationRegistry object factory for JNDI references.
BitronixUserTransactionObjectFactory BitronixTransactionManager object factory for JNDI references.
BitronixXid Implementation of Xid.
Configuration Configuration repository of the transaction manager.
TransactionManagerServices Container for all BTM services.
Version  
 

Package bitronix.tm Description

JTA interfaces implementations and global services.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/Version.html0000644000175000017500000002671512215446620020131 0ustar tonytony Version (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class Version

java.lang.Object
  extended by bitronix.tm.Version

public final class Version
extends Object


Constructor Summary
Version()
           
 
Method Summary
static String getVersion()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Version

public Version()
Method Detail

getVersion

public static String getVersion()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/BitronixTransactionSynchronizationRegistry.html0000644000175000017500000005666312215446620027370 0ustar tonytony BitronixTransactionSynchronizationRegistry (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class BitronixTransactionSynchronizationRegistry

java.lang.Object
  extended by bitronix.tm.BitronixTransactionSynchronizationRegistry
All Implemented Interfaces:
Referenceable, TransactionSynchronizationRegistry

public class BitronixTransactionSynchronizationRegistry
extends Object
implements TransactionSynchronizationRegistry, Referenceable

Implementation of JTA 1.1 TransactionSynchronizationRegistry.

Author:
lorban

Constructor Summary
BitronixTransactionSynchronizationRegistry()
           
 
Method Summary
 Reference getReference()
           
 Object getResource(Object key)
           
 boolean getRollbackOnly()
           
 Object getTransactionKey()
           
 int getTransactionStatus()
           
 void putResource(Object key, Object value)
           
 void registerInterposedSynchronization(Synchronization synchronization)
           
 void setRollbackOnly()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitronixTransactionSynchronizationRegistry

public BitronixTransactionSynchronizationRegistry()
Method Detail

getResource

public Object getResource(Object key)
Specified by:
getResource in interface TransactionSynchronizationRegistry

getRollbackOnly

public boolean getRollbackOnly()
Specified by:
getRollbackOnly in interface TransactionSynchronizationRegistry

getTransactionKey

public Object getTransactionKey()
Specified by:
getTransactionKey in interface TransactionSynchronizationRegistry

getTransactionStatus

public int getTransactionStatus()
Specified by:
getTransactionStatus in interface TransactionSynchronizationRegistry

putResource

public void putResource(Object key,
                        Object value)
Specified by:
putResource in interface TransactionSynchronizationRegistry

registerInterposedSynchronization

public void registerInterposedSynchronization(Synchronization synchronization)
Specified by:
registerInterposedSynchronization in interface TransactionSynchronizationRegistry

setRollbackOnly

public void setRollbackOnly()
Specified by:
setRollbackOnly in interface TransactionSynchronizationRegistry

getReference

public Reference getReference()
                       throws NamingException
Specified by:
getReference in interface Referenceable
Throws:
NamingException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/0000755000175000017500000000000012215446622017257 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/journal/package-frame.html0000644000175000017500000000462012215446622022632 0ustar tonytony bitronix.tm.journal (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.journal
Interfaces 
Journal
Classes 
DiskForceBatcherThread
DiskForceWaitQueue
DiskJournal
NullJournal
TransactionLogAppender
TransactionLogCursor
TransactionLogHeader
TransactionLogRecord
Exceptions 
CorruptedTransactionLogException
btm-dist-2.1.4/doc/api/bitronix/tm/journal/TransactionLogRecord.html0000644000175000017500000006127312215446620024242 0ustar tonytony TransactionLogRecord (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class TransactionLogRecord

java.lang.Object
  extended by bitronix.tm.journal.TransactionLogRecord

public class TransactionLogRecord
extends Object

Representation of a transaction log record on disk.

On-disk format has been implemented following Mike Spille's recommendations. Quoting him:

[RECORD_TYPE :4] [RECORD_LEN :4] [HEADER_LEN :4] [System.currentTimeMillis :8] [Sequence number :4] [Checksum :4] [Payload :X] [END_RECORD_INDICATOR :4]

Where [RECORD_TYPE] is a passed-in record type from the TM. [RECORD_LEN] is the overall record length (sans [RECORD_TYPE and [RECORD_LEN]). [HEADER_LEN] is the length of the remainder of the header - important if you want to support easy upgrades of your format. The remaining pieces are the rest of the header, and the payload. The header at least should have [System.currentTimeMillis] and [Sequence number], with the [sequence number] coming from some monotically increasing sequence generator unique to the process. The [checksum] is optional for the paranoid among us. The time information can be very useful for profiling and tracking down problems in production, and in conjunction with the sequence number it can give you precise ordering. This doesn't give you much in this solution, but can be priceless if you ever move to a system with multiple dual log file pairs to lessen single-threading on a single log file pair. Finally, I like having an [END_RECORD_INDICATOR] as an extra corruption detector device - I'm a suspenders and belt kind of guy. Actually, the END_RECORD_INDICATOR and [RECORD_LEN] in conjunction are very useful in development, as well, to catch programming mistakes in the log system early.

Payload contains [GTRID LENGTH :1] [GTRID :A] [UNIQUE NAMES COUNT :4] ([UNIQUE NAME LENGTH :2] [UNIQUE NAME :Y] ...) which makes a major difference with Mike's proposed format because here a record can vary in length: the GTRID size is A bytes long (A being the GTRID length) and there can be X unique names that are Y characters long, Y being eventually different for each name.

Author:
lorban
See Also:
XA Exposed, Part III: The Implementor's Notebook

Constructor Summary
TransactionLogRecord(int status, int recordLength, int headerLength, long time, int sequenceNumber, int crc32, Uid gtrid, Set<String> uniqueNames, int endRecord)
          Use this constructor when restoring a log from the disk.
TransactionLogRecord(int status, Uid gtrid, Set<String> uniqueNames)
          Create a new transaction log ready to be stored.
 
Method Summary
 int calculateCrc32()
          Calculate the CRC32 value of this record.
 int getCrc32()
           
 int getEndRecord()
           
 Uid getGtrid()
           
 int getHeaderLength()
           
 int getRecordLength()
           
 int getSequenceNumber()
           
 int getStatus()
           
 long getTime()
           
 Set<String> getUniqueNames()
           
 boolean isCrc32Correct()
          Recalculate the CRC32 value of this record (using calculateCrc32()) and compare it with the stored value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionLogRecord

public TransactionLogRecord(int status,
                            int recordLength,
                            int headerLength,
                            long time,
                            int sequenceNumber,
                            int crc32,
                            Uid gtrid,
                            Set<String> uniqueNames,
                            int endRecord)
Use this constructor when restoring a log from the disk.

Parameters:
status - record type
recordLength - record length excluding status and recordLength
headerLength - length of all fields except gtrid, uniqueNames and endRecord
time - current time in milliseconds
sequenceNumber - atomically generated sequence number during a JVM's lifespan
crc32 - checksum of the full record
gtrid - global transaction id
uniqueNames - unique names of XA data sources used in this transaction
endRecord - end of record marker

TransactionLogRecord

public TransactionLogRecord(int status,
                            Uid gtrid,
                            Set<String> uniqueNames)
Create a new transaction log ready to be stored.

Parameters:
status - record type
gtrid - global transaction id
uniqueNames - unique names of XA data sources used in this transaction
Method Detail

getStatus

public int getStatus()

getRecordLength

public int getRecordLength()

getHeaderLength

public int getHeaderLength()

getTime

public long getTime()

getSequenceNumber

public int getSequenceNumber()

getCrc32

public int getCrc32()

getGtrid

public Uid getGtrid()

getUniqueNames

public Set<String> getUniqueNames()

getEndRecord

public int getEndRecord()

isCrc32Correct

public boolean isCrc32Correct()
Recalculate the CRC32 value of this record (using calculateCrc32()) and compare it with the stored value.

Returns:
true if the recalculated value equals the stored one, false otherwise.

calculateCrc32

public int calculateCrc32()
Calculate the CRC32 value of this record.

Returns:
the CRC32 value of this record.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/DiskForceBatcherThread.html0000644000175000017500000006211612215446620024443 0ustar tonytony DiskForceBatcherThread (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class DiskForceBatcherThread

java.lang.Object
  extended by java.lang.Thread
      extended by bitronix.tm.journal.DiskForceBatcherThread
All Implemented Interfaces:
Runnable

public final class DiskForceBatcherThread
extends Thread

Thread that executes disk force batches.

Author:
lorban

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
 void enqueue(TransactionLogAppender tla)
          Add the TransactionLogAppender to the wait queue and wait until the disk force is done.
static DiskForceBatcherThread getInstance()
          Get the single instance of the DiskForceBatcherThread.
 void run()
           
 boolean setAlive(boolean alive)
          Thread will run for as long as this flag is not false.
 String toString()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static DiskForceBatcherThread getInstance()
Get the single instance of the DiskForceBatcherThread.

Returns:
the single instance of the DiskForceBatcherThread.

setAlive

public boolean setAlive(boolean alive)
Thread will run for as long as this flag is not false.

Parameters:
alive - The new flag value.
Returns:
the old flag value.

enqueue

public void enqueue(TransactionLogAppender tla)
Add the TransactionLogAppender to the wait queue and wait until the disk force is done.

Parameters:
tla - the TransactionLogAppender

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

toString

public String toString()
Overrides:
toString in class Thread


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/package-tree.html0000644000175000017500000002235012215446622022477 0ustar tonytony bitronix.tm.journal Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.journal

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/CorruptedTransactionLogException.html0000644000175000017500000003542412215446620026651 0ustar tonytony CorruptedTransactionLogException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class CorruptedTransactionLogException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by bitronix.tm.journal.CorruptedTransactionLogException
All Implemented Interfaces:
Serializable

public class CorruptedTransactionLogException
extends IOException

Thrown by TransactionLogCursor when an integrity check fails upon reading a record.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
CorruptedTransactionLogException(String s)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CorruptedTransactionLogException

public CorruptedTransactionLogException(String s)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/Journal.html0000644000175000017500000003725112215446620021565 0ustar tonytony Journal (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Interface Journal

All Superinterfaces:
Service
All Known Implementing Classes:
DiskJournal, NullJournal

public interface Journal
extends Service

Transaction logs journal implementations must implement this interface to provide functionality required by the transaction manager.

Author:
lorban

Method Summary
 void close()
          Close this journal and release all underlying resources.
 Map<Uid,TransactionLogRecord> collectDanglingRecords()
          Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record.
 void force()
          Force journal to synchronize with permanent storage.
 void log(int status, Uid gtrid, Set<String> uniqueNames)
          Log a new transaction status to journal.
 void open()
          Open the journal.
 
Methods inherited from interface bitronix.tm.utils.Service
shutdown
 

Method Detail

log

void log(int status,
         Uid gtrid,
         Set<String> uniqueNames)
         throws IOException
Log a new transaction status to journal. Note that the journal will not check the flow of the transactions. If you call this method with erroneous data, it will be added to the journal as-is.

Parameters:
status - transaction status to log.
gtrid - GTRID of the transaction.
uniqueNames - unique names of the RecoverableXAResourceProducers participating in the transaction.
Throws:
IOException - if an I/O error occurs.

open

void open()
          throws IOException
Open the journal. Integrity should be checked and an exception should be thrown in case the journal is corrupt.

Throws:
IOException - if an I/O error occurs.

close

void close()
           throws IOException
Close this journal and release all underlying resources.

Throws:
IOException - if an I/O error occurs.

force

void force()
           throws IOException
Force journal to synchronize with permanent storage.

Throws:
IOException - if an I/O error occurs.

collectDanglingRecords

Map<Uid,TransactionLogRecord> collectDanglingRecords()
                                                     throws IOException
Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record.

Returns:
a Map using Uid objects GTRID as key and TransactionLogRecord as value
Throws:
IOException - if an I/O error occurs.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/package-use.html0000644000175000017500000002454012215446622022337 0ustar tonytony Uses of Package bitronix.tm.journal (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.journal

Packages that use bitronix.tm.journal
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.gui GUI admin console. 
bitronix.tm.journal Transactions disk journal. 
 

Classes in bitronix.tm.journal used by bitronix.tm
Journal
          Transaction logs journal implementations must implement this interface to provide functionality required by the transaction manager.
 

Classes in bitronix.tm.journal used by bitronix.tm.gui
TransactionLogRecord
          Representation of a transaction log record on disk.
 

Classes in bitronix.tm.journal used by bitronix.tm.journal
DiskForceBatcherThread
          Thread that executes disk force batches.
Journal
          Transaction logs journal implementations must implement this interface to provide functionality required by the transaction manager.
TransactionLogAppender
          Used to write TransactionLogRecord objects to a log file.
TransactionLogCursor
          Used to read TransactionLogRecord objects from a log file.
TransactionLogHeader
          Used to control a log file's header.
TransactionLogRecord
          Representation of a transaction log record on disk.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/0000755000175000017500000000000012215446622021156 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/TransactionLogRecord.html0000644000175000017500000004400112215446622026131 0ustar tonytony Uses of Class bitronix.tm.journal.TransactionLogRecord (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.TransactionLogRecord

Packages that use TransactionLogRecord
bitronix.tm.gui GUI admin console. 
bitronix.tm.journal Transactions disk journal. 
 

Uses of TransactionLogRecord in bitronix.tm.gui
 

Methods in bitronix.tm.gui that return TransactionLogRecord
abstract  TransactionLogRecord TransactionTableModel.getRow(int row)
           
 TransactionLogRecord RawTransactionTableModel.getRow(int row)
           
 TransactionLogRecord PendingTransactionTableModel.getRow(int row)
           
 

Methods in bitronix.tm.gui with parameters of type TransactionLogRecord
abstract  boolean TransactionTableModel.acceptLog(TransactionLogRecord tlog)
           
 boolean RawTransactionTableModel.acceptLog(TransactionLogRecord tlog)
           
 boolean PendingTransactionTableModel.acceptLog(TransactionLogRecord tlog)
           
 

Constructors in bitronix.tm.gui with parameters of type TransactionLogRecord
TransactionLogDialog(JFrame frame, TransactionLogRecord tlog)
           
 

Uses of TransactionLogRecord in bitronix.tm.journal
 

Methods in bitronix.tm.journal that return TransactionLogRecord
 TransactionLogRecord TransactionLogCursor.readLog()
          Fetch the next TransactionLogRecord from log, recalculating the CRC and checking it against the stored one.
 TransactionLogRecord TransactionLogCursor.readLog(boolean skipCrcCheck)
          Fetch the next TransactionLogRecord from log.
 

Methods in bitronix.tm.journal that return types with arguments of type TransactionLogRecord
 Map<Uid,TransactionLogRecord> NullJournal.collectDanglingRecords()
           
 Map<Uid,TransactionLogRecord> Journal.collectDanglingRecords()
          Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record.
 Map<Uid,TransactionLogRecord> DiskJournal.collectDanglingRecords()
          Collect all dangling records of the active log file.
 

Methods in bitronix.tm.journal with parameters of type TransactionLogRecord
 boolean TransactionLogAppender.writeLog(TransactionLogRecord tlog)
          Write a TransactionLogRecord to disk.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/DiskForceBatcherThread.html0000644000175000017500000001766512215446622026355 0ustar tonytony Uses of Class bitronix.tm.journal.DiskForceBatcherThread (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.DiskForceBatcherThread

Packages that use DiskForceBatcherThread
bitronix.tm.journal Transactions disk journal. 
 

Uses of DiskForceBatcherThread in bitronix.tm.journal
 

Methods in bitronix.tm.journal that return DiskForceBatcherThread
static DiskForceBatcherThread DiskForceBatcherThread.getInstance()
          Get the single instance of the DiskForceBatcherThread.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/CorruptedTransactionLogException.html0000644000175000017500000001416412215446622030550 0ustar tonytony Uses of Class bitronix.tm.journal.CorruptedTransactionLogException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.CorruptedTransactionLogException

No usage of bitronix.tm.journal.CorruptedTransactionLogException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/Journal.html0000644000175000017500000002271712215446622023467 0ustar tonytony Uses of Interface bitronix.tm.journal.Journal (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.journal.Journal

Packages that use Journal
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.journal Transactions disk journal. 
 

Uses of Journal in bitronix.tm
 

Methods in bitronix.tm that return Journal
static Journal TransactionManagerServices.getJournal()
          Create the transactions journal.
 

Uses of Journal in bitronix.tm.journal
 

Classes in bitronix.tm.journal that implement Journal
 class DiskJournal
          Simple implementation of a journal that writes on a two-files disk log.
 class NullJournal
          No-op journal.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/TransactionLogCursor.html0000644000175000017500000001763312215446622026203 0ustar tonytony Uses of Class bitronix.tm.journal.TransactionLogCursor (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.TransactionLogCursor

Packages that use TransactionLogCursor
bitronix.tm.journal Transactions disk journal. 
 

Uses of TransactionLogCursor in bitronix.tm.journal
 

Methods in bitronix.tm.journal that return TransactionLogCursor
 TransactionLogCursor TransactionLogAppender.getCursor()
          Creates a cursor on this journal file allowing iteration of its records.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/DiskForceWaitQueue.html0000644000175000017500000001375012215446622025555 0ustar tonytony Uses of Class bitronix.tm.journal.DiskForceWaitQueue (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.DiskForceWaitQueue

No usage of bitronix.tm.journal.DiskForceWaitQueue



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/TransactionLogAppender.html0000644000175000017500000002401012215446622026447 0ustar tonytony Uses of Class bitronix.tm.journal.TransactionLogAppender (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.TransactionLogAppender

Packages that use TransactionLogAppender
bitronix.tm.journal Transactions disk journal. 
 

Uses of TransactionLogAppender in bitronix.tm.journal
 

Methods in bitronix.tm.journal that return TransactionLogAppender
 TransactionLogAppender DiskForceWaitQueue.head()
           
 

Methods in bitronix.tm.journal with parameters of type TransactionLogAppender
 boolean DiskForceWaitQueue.enqueue(TransactionLogAppender tla)
           
 void DiskForceBatcherThread.enqueue(TransactionLogAppender tla)
          Add the TransactionLogAppender to the wait queue and wait until the disk force is done.
 void DiskForceWaitQueue.waitUntilNotContains(TransactionLogAppender tla)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/NullJournal.html0000644000175000017500000001364212215446622024317 0ustar tonytony Uses of Class bitronix.tm.journal.NullJournal (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.NullJournal

No usage of bitronix.tm.journal.NullJournal



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/TransactionLogHeader.html0000644000175000017500000002004512215446622026105 0ustar tonytony Uses of Class bitronix.tm.journal.TransactionLogHeader (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.TransactionLogHeader

Packages that use TransactionLogHeader
bitronix.tm.journal Transactions disk journal. 
 

Uses of TransactionLogHeader in bitronix.tm.journal
 

Methods in bitronix.tm.journal that return TransactionLogHeader
 TransactionLogHeader TransactionLogAppender.getHeader()
          Return a TransactionLogHeader that allows reading and controlling the log file's header.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/class-use/DiskJournal.html0000644000175000017500000001364212215446622024277 0ustar tonytony Uses of Class bitronix.tm.journal.DiskJournal (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.journal.DiskJournal

No usage of bitronix.tm.journal.DiskJournal



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/package-summary.html0000644000175000017500000002370012215446622023235 0ustar tonytony bitronix.tm.journal (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.journal

Transactions disk journal.

See:
          Description

Interface Summary
Journal Transaction logs journal implementations must implement this interface to provide functionality required by the transaction manager.
 

Class Summary
DiskForceBatcherThread Thread that executes disk force batches.
DiskForceWaitQueue TransactionLogAppenders waiting for a disk force get enqueued here.
DiskJournal Simple implementation of a journal that writes on a two-files disk log.
NullJournal No-op journal.
TransactionLogAppender Used to write TransactionLogRecord objects to a log file.
TransactionLogCursor Used to read TransactionLogRecord objects from a log file.
TransactionLogHeader Used to control a log file's header.
TransactionLogRecord Representation of a transaction log record on disk.
 

Exception Summary
CorruptedTransactionLogException Thrown by TransactionLogCursor when an integrity check fails upon reading a record.
 

Package bitronix.tm.journal Description

Transactions disk journal.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/TransactionLogCursor.html0000644000175000017500000004054212215446620024275 0ustar tonytony TransactionLogCursor (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class TransactionLogCursor

java.lang.Object
  extended by bitronix.tm.journal.TransactionLogCursor

public class TransactionLogCursor
extends Object

Used to read TransactionLogRecord objects from a log file.

Author:
lorban

Constructor Summary
TransactionLogCursor(File file)
          Create a TransactionLogCursor that will read from the specified file.
 
Method Summary
 void close()
          Close the cursor and the underlying file
 TransactionLogRecord readLog()
          Fetch the next TransactionLogRecord from log, recalculating the CRC and checking it against the stored one.
 TransactionLogRecord readLog(boolean skipCrcCheck)
          Fetch the next TransactionLogRecord from log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionLogCursor

public TransactionLogCursor(File file)
                     throws IOException
Create a TransactionLogCursor that will read from the specified file. This opens a new read-only file descriptor.

Parameters:
file - the file to read logs from
Throws:
IOException - if an I/O error occurs.
Method Detail

readLog

public TransactionLogRecord readLog()
                             throws IOException
Fetch the next TransactionLogRecord from log, recalculating the CRC and checking it against the stored one. InvalidChecksumException is thrown if the check fails.

Returns:
the TransactionLogRecord or null if the end of the log file has been reached
Throws:
IOException - if an I/O error occurs.

readLog

public TransactionLogRecord readLog(boolean skipCrcCheck)
                             throws IOException
Fetch the next TransactionLogRecord from log.

Parameters:
skipCrcCheck - if set to false, the method will thow an InvalidChecksumException if the CRC on disk does not match the recalculated one. Otherwise, the CRC is not recalculated nor checked agains the stored one.
Returns:
the TransactionLogRecord or null if the end of the log file has been reached
Throws:
IOException - if an I/O error occurs.

close

public void close()
           throws IOException
Close the cursor and the underlying file

Throws:
IOException - if an I/O error occurs.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/DiskForceWaitQueue.html0000644000175000017500000004104412215446620023651 0ustar tonytony DiskForceWaitQueue (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class DiskForceWaitQueue

java.lang.Object
  extended by bitronix.tm.journal.DiskForceWaitQueue

public class DiskForceWaitQueue
extends Object

TransactionLogAppenders waiting for a disk force get enqueued here.

Author:
lorban

Constructor Summary
DiskForceWaitQueue()
           
 
Method Summary
 void clear()
           
 boolean enqueue(TransactionLogAppender tla)
           
 TransactionLogAppender head()
           
 boolean isEmpty()
           
 int size()
           
 void waitUntilNotContains(TransactionLogAppender tla)
           
 void waitUntilNotEmpty()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskForceWaitQueue

public DiskForceWaitQueue()
Method Detail

enqueue

public boolean enqueue(TransactionLogAppender tla)
Returns:
true if the tla was successfully enqueued, false otherwise

head

public TransactionLogAppender head()

clear

public void clear()

isEmpty

public boolean isEmpty()

waitUntilNotEmpty

public void waitUntilNotEmpty()
                       throws InterruptedException
Throws:
InterruptedException

size

public int size()

waitUntilNotContains

public void waitUntilNotContains(TransactionLogAppender tla)
                          throws InterruptedException
Throws:
InterruptedException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/TransactionLogAppender.html0000644000175000017500000005410012215446620024551 0ustar tonytony TransactionLogAppender (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class TransactionLogAppender

java.lang.Object
  extended by bitronix.tm.journal.TransactionLogAppender

public class TransactionLogAppender
extends Object

Used to write TransactionLogRecord objects to a log file.

Author:
lorban

Field Summary
static int END_RECORD
          int-encoded "xntB" ASCII string.
 
Constructor Summary
TransactionLogAppender(File file, long maxFileLength)
          Create an appender that will write to specified file up to the specified maximum length.
 
Method Summary
 void close()
          Close the appender and the underlying file.
protected  void doForce()
           
 void force()
          Force flushing the logs to disk
 TransactionLogCursor getCursor()
          Creates a cursor on this journal file allowing iteration of its records.
 TransactionLogHeader getHeader()
          Return a TransactionLogHeader that allows reading and controlling the log file's header.
 String toString()
           
 boolean writeLog(TransactionLogRecord tlog)
          Write a TransactionLogRecord to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

END_RECORD

public static final int END_RECORD
int-encoded "xntB" ASCII string. This will be useful after swapping log files since we will potentially overwrite old logs not necessarily of the same size. Very useful when debugging and eventually restoring broken log files.

See Also:
Constant Field Values
Constructor Detail

TransactionLogAppender

public TransactionLogAppender(File file,
                              long maxFileLength)
                       throws IOException
Create an appender that will write to specified file up to the specified maximum length. All disk access are synchronized arround the RandomAccessFile object, including header calls.

Parameters:
file - the underlying File used to write to disk.
maxFileLength - size of the file on disk that can never be bypassed.
Throws:
IOException - if an I/O error occurs.
Method Detail

getHeader

public TransactionLogHeader getHeader()
Return a TransactionLogHeader that allows reading and controlling the log file's header.

Returns:
this log file's TransactionLogHeader

writeLog

public boolean writeLog(TransactionLogRecord tlog)
                 throws IOException
Write a TransactionLogRecord to disk.

Parameters:
tlog - the record to write to disk.
Returns:
true if there was room in the log file and the log was written, false otherwise.
Throws:
IOException - if an I/O error occurs.

close

public void close()
           throws IOException
Close the appender and the underlying file.

Throws:
IOException - if an I/O error occurs.

getCursor

public TransactionLogCursor getCursor()
                               throws IOException
Creates a cursor on this journal file allowing iteration of its records. This opens a new read-only file descriptor independent of the write-only one still used for writing transaction logs.

Returns:
a TransactionLogCursor.
Throws:
IOException - if an I/O error occurs.

force

public void force()
           throws IOException
Force flushing the logs to disk

Throws:
IOException - if an I/O error occurs.

toString

public String toString()
Overrides:
toString in class Object

doForce

protected void doForce()
                throws IOException
Throws:
IOException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/NullJournal.html0000644000175000017500000005510212215446620022413 0ustar tonytony NullJournal (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class NullJournal

java.lang.Object
  extended by bitronix.tm.journal.NullJournal
All Implemented Interfaces:
Journal, Service

public class NullJournal
extends Object
implements Journal

No-op journal. Do not use for anything else than testing as the transaction manager cannot guarantee data integrity with this journal implementation.

Author:
lorban

Constructor Summary
NullJournal()
           
 
Method Summary
 void close()
          Close this journal and release all underlying resources.
 Map<Uid,TransactionLogRecord> collectDanglingRecords()
          Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record.
 void force()
          Force journal to synchronize with permanent storage.
 void log(int status, Uid gtrid, Set<String> uniqueNames)
          Log a new transaction status to journal.
 void open()
          Open the journal.
 void shutdown()
          Shutdown the service and free all held resources.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NullJournal

public NullJournal()
Method Detail

log

public void log(int status,
                Uid gtrid,
                Set<String> uniqueNames)
         throws IOException
Description copied from interface: Journal
Log a new transaction status to journal. Note that the journal will not check the flow of the transactions. If you call this method with erroneous data, it will be added to the journal as-is.

Specified by:
log in interface Journal
Parameters:
status - transaction status to log.
gtrid - GTRID of the transaction.
uniqueNames - unique names of the RecoverableXAResourceProducers participating in the transaction.
Throws:
IOException - if an I/O error occurs.

open

public void open()
          throws IOException
Description copied from interface: Journal
Open the journal. Integrity should be checked and an exception should be thrown in case the journal is corrupt.

Specified by:
open in interface Journal
Throws:
IOException - if an I/O error occurs.

close

public void close()
           throws IOException
Description copied from interface: Journal
Close this journal and release all underlying resources.

Specified by:
close in interface Journal
Throws:
IOException - if an I/O error occurs.

force

public void force()
           throws IOException
Description copied from interface: Journal
Force journal to synchronize with permanent storage.

Specified by:
force in interface Journal
Throws:
IOException - if an I/O error occurs.

collectDanglingRecords

public Map<Uid,TransactionLogRecord> collectDanglingRecords()
                                                     throws IOException
Description copied from interface: Journal
Collect all dangling records of the journal, ie: COMMITTING records with no corresponding COMMITTED record.

Specified by:
collectDanglingRecords in interface Journal
Returns:
a Map using Uid objects GTRID as key and TransactionLogRecord as value
Throws:
IOException - if an I/O error occurs.

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/TransactionLogHeader.html0000644000175000017500000007307312215446620024215 0ustar tonytony TransactionLogHeader (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class TransactionLogHeader

java.lang.Object
  extended by bitronix.tm.journal.TransactionLogHeader

public class TransactionLogHeader
extends Object

Used to control a log file's header.

The physical data is read when this object is created then cached. Calling setter methods sets the header field then moves the file pointer back to the previous location.

Author:
lorban

Field Summary
static byte CLEAN_LOG_STATE
          State of the log file when it has been closed properly.
static int CURRENT_POSITION_HEADER
          Position of the current log position in the header.
static int FORMAT_ID_HEADER
          Position of the format ID in the header (see BitronixXid.FORMAT_ID).
static int HEADER_LENGTH
          Total length of the header.
static int STATE_HEADER
          Position of the log file state in the header.
static int TIMESTAMP_HEADER
          Position of the timestamp in the header.
static byte UNCLEAN_LOG_STATE
          State of the log file when it hasn't been closed properly or it is still open.
 
Constructor Summary
TransactionLogHeader(FileChannel fc, long maxFileLength)
          TransactionLogHeader are used to control headers of the specified RandomAccessFile.
 
Method Summary
 int getFormatId()
          Get FORMAT_ID_HEADER.
 long getPosition()
          Get CURRENT_POSITION_HEADER.
 byte getState()
          Get STATE_HEADER.
 long getTimestamp()
          Get TIMESTAMP_HEADER.
 void goAhead(long distance)
          Advance CURRENT_POSITION_HEADER.
 void rewind()
          Rewind CURRENT_POSITION_HEADER back to the beginning of the file.
 void setFormatId(int formatId)
          Set FORMAT_ID_HEADER.
 void setPosition(long position)
          Set CURRENT_POSITION_HEADER.
 void setState(byte state)
          Set STATE_HEADER.
 void setTimestamp(long timestamp)
          Set TIMESTAMP_HEADER.
 String toString()
          Create human-readable String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORMAT_ID_HEADER

public static final int FORMAT_ID_HEADER
Position of the format ID in the header (see BitronixXid.FORMAT_ID).

See Also:
Constant Field Values

TIMESTAMP_HEADER

public static final int TIMESTAMP_HEADER
Position of the timestamp in the header.

See Also:
Constant Field Values

STATE_HEADER

public static final int STATE_HEADER
Position of the log file state in the header.

See Also:
Constant Field Values

CURRENT_POSITION_HEADER

public static final int CURRENT_POSITION_HEADER
Position of the current log position in the header.

See Also:
Constant Field Values

HEADER_LENGTH

public static final int HEADER_LENGTH
Total length of the header.

See Also:
Constant Field Values

CLEAN_LOG_STATE

public static final byte CLEAN_LOG_STATE
State of the log file when it has been closed properly.

See Also:
Constant Field Values

UNCLEAN_LOG_STATE

public static final byte UNCLEAN_LOG_STATE
State of the log file when it hasn't been closed properly or it is still open.

See Also:
Constant Field Values
Constructor Detail

TransactionLogHeader

public TransactionLogHeader(FileChannel fc,
                            long maxFileLength)
                     throws IOException
TransactionLogHeader are used to control headers of the specified RandomAccessFile. All calls to setters are synchronized on the passed-in RandomAccessFile.

Parameters:
fc - the file channel to read from.
maxFileLength - the max file length.
Throws:
IOException - if an I/O error occurs.
Method Detail

getFormatId

public int getFormatId()
Get FORMAT_ID_HEADER.

Returns:
the FORMAT_ID_HEADER value.
See Also:
FORMAT_ID_HEADER

getTimestamp

public long getTimestamp()
Get TIMESTAMP_HEADER.

Returns:
the TIMESTAMP_HEADER value.
See Also:
TIMESTAMP_HEADER

getState

public byte getState()
Get STATE_HEADER.

Returns:
the STATE_HEADER value.
See Also:
STATE_HEADER

getPosition

public long getPosition()
Get CURRENT_POSITION_HEADER.

Returns:
the CURRENT_POSITION_HEADER value.
See Also:
CURRENT_POSITION_HEADER

setFormatId

public void setFormatId(int formatId)
                 throws IOException
Set FORMAT_ID_HEADER.

Parameters:
formatId - the FORMAT_ID_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
FORMAT_ID_HEADER

setTimestamp

public void setTimestamp(long timestamp)
                  throws IOException
Set TIMESTAMP_HEADER.

Parameters:
timestamp - the TIMESTAMP_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
TIMESTAMP_HEADER

setState

public void setState(byte state)
              throws IOException
Set STATE_HEADER.

Parameters:
state - the STATE_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
STATE_HEADER

setPosition

public void setPosition(long position)
                 throws IOException
Set CURRENT_POSITION_HEADER.

Parameters:
position - the CURRENT_POSITION_HEADER value.
Throws:
IOException - if an I/O error occurs.
See Also:
CURRENT_POSITION_HEADER

goAhead

public void goAhead(long distance)
             throws IOException
Advance CURRENT_POSITION_HEADER.

Parameters:
distance - the value to add to the current position.
Throws:
IOException - if an I/O error occurs.
See Also:
setPosition(long)

rewind

public void rewind()
            throws IOException
Rewind CURRENT_POSITION_HEADER back to the beginning of the file.

Throws:
IOException - if an I/O error occurs.
See Also:
setPosition(long)

toString

public String toString()
Create human-readable String representation.

Overrides:
toString in class Object
Returns:
a human-readable String representing this object's state.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/journal/DiskJournal.html0000644000175000017500000005403112215446620022373 0ustar tonytony DiskJournal (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.journal
Class DiskJournal

java.lang.Object
  extended by bitronix.tm.journal.DiskJournal
All Implemented Interfaces:
Journal, Service

public class DiskJournal
extends Object
implements Journal

Simple implementation of a journal that writes on a two-files disk log.

Files are pre-allocated in size, never grow and when the first one is full, dangling records are copied to the second file and logging starts again on the latter.

This implementation is not highly efficient but quite robust and simple. It is based on one of the implementations proposed by Mike Spille.

Configurable properties are all starting with bitronix.tm.journal.disk.

Author:
lorban
See Also:
Configuration, XA Exposed, Part III: The Implementor's Notebook

Constructor Summary
DiskJournal()
          Create an uninitialized disk journal.
 
Method Summary
 void close()
          Close the disk journal and the underlying files.
 Map<Uid,TransactionLogRecord> collectDanglingRecords()
          Collect all dangling records of the active log file.
 void force()
          Force active log file to synchronize with the underlying disk device.
 void log(int status, Uid gtrid, Set<String> uniqueNames)
          Log a new transaction status to journal.
 void open()
          Open the disk journal.
 void shutdown()
          Shutdown the service and free all held resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskJournal

public DiskJournal()
Create an uninitialized disk journal. You must call open() prior you can use it.

Method Detail

log

public void log(int status,
                Uid gtrid,
                Set<String> uniqueNames)
         throws IOException
Log a new transaction status to journal. Note that the DiskJournal will not check the flow of the transaction. If you call this method with erroneous data, it will be added to the journal anyway.

Specified by:
log in interface Journal
Parameters:
status - transaction status to log. See Status constants.
gtrid - raw GTRID of the transaction.
uniqueNames - unique names of the ResourceBeans participating in this transaction.
Throws:
IOException - in case of disk IO failure or if the disk journal is not open.

force

public void force()
           throws IOException
Force active log file to synchronize with the underlying disk device.

Specified by:
force in interface Journal
Throws:
IOException - in case of disk IO failure or if the disk journal is not open.

open

public void open()
          throws IOException
Open the disk journal. Files are checked for integrity and DiskJournal will refuse to open corrupted log files. If files are not present on disk, this method will create and pre-allocate them.

Specified by:
open in interface Journal
Throws:
IOException - in case of disk IO failure.

close

public void close()
           throws IOException
Close the disk journal and the underlying files.

Specified by:
close in interface Journal
Throws:
IOException - in case of disk IO failure.

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service

collectDanglingRecords

public Map<Uid,TransactionLogRecord> collectDanglingRecords()
                                                     throws IOException
Collect all dangling records of the active log file.

Specified by:
collectDanglingRecords in interface Journal
Returns:
a Map using Uid objects GTRID as key and TransactionLogRecord as value
Throws:
IOException - in case of disk IO failure or if the disk journal is not open.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/BitronixTransactionManager.html0000644000175000017500000012351212215446620023774 0ustar tonytony BitronixTransactionManager (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class BitronixTransactionManager

java.lang.Object
  extended by bitronix.tm.BitronixTransactionManager
All Implemented Interfaces:
Service, Referenceable, TransactionManager, UserTransaction

public class BitronixTransactionManager
extends Object
implements TransactionManager, UserTransaction, Referenceable, Service

Implementation of TransactionManager and UserTransaction.

Author:
lorban

Constructor Summary
BitronixTransactionManager()
          Create the BitronixTransactionManager.
 
Method Summary
 void begin()
          Start a new transaction and bind the context to the calling thread.
 void commit()
           
 void dumpTransactionContexts()
          Dump an overview of all running transactions as debug logs.
 BitronixTransaction getCurrentTransaction()
          Get the transaction currently registered on the current thread context.
 Map getInFlightTransactions()
          Return all in-flight transactions.
 long getOldestInFlightTransactionTimestamp()
          Return the timestamp of the oldest in-flight transaction.
 Reference getReference()
          BitronixTransactionManager can only have a single instance per JVM so this method always returns a reference with no special information to find back the sole instance.
 int getStatus()
           
 Transaction getTransaction()
           
 void resume(Transaction transaction)
           
 void rollback()
           
 void setRollbackOnly()
           
 void setTransactionTimeout(int seconds)
           
 void shutdown()
          Shut down the transaction manager and release all resources held by it.
 Transaction suspend()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixTransactionManager

public BitronixTransactionManager()
Create the BitronixTransactionManager. Open the journal, load resources and perform recovery synchronously. The recovery service then gets scheduled for background recovery.

Method Detail

begin

public void begin()
           throws NotSupportedException,
                  SystemException
Start a new transaction and bind the context to the calling thread.

Specified by:
begin in interface TransactionManager
Specified by:
begin in interface UserTransaction
Throws:
NotSupportedException - if a transaction is already bound to the calling thread.
SystemException - if the transaction manager is shutting down.

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   SecurityException,
                   IllegalStateException,
                   SystemException
Specified by:
commit in interface TransactionManager
Specified by:
commit in interface UserTransaction
Throws:
RollbackException
HeuristicMixedException
HeuristicRollbackException
SecurityException
IllegalStateException
SystemException

rollback

public void rollback()
              throws IllegalStateException,
                     SecurityException,
                     SystemException
Specified by:
rollback in interface TransactionManager
Specified by:
rollback in interface UserTransaction
Throws:
IllegalStateException
SecurityException
SystemException

getStatus

public int getStatus()
              throws SystemException
Specified by:
getStatus in interface TransactionManager
Specified by:
getStatus in interface UserTransaction
Throws:
SystemException

getTransaction

public Transaction getTransaction()
                           throws SystemException
Specified by:
getTransaction in interface TransactionManager
Throws:
SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws IllegalStateException,
                            SystemException
Specified by:
setRollbackOnly in interface TransactionManager
Specified by:
setRollbackOnly in interface UserTransaction
Throws:
IllegalStateException
SystemException

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws SystemException
Specified by:
setTransactionTimeout in interface TransactionManager
Specified by:
setTransactionTimeout in interface UserTransaction
Throws:
SystemException

suspend

public Transaction suspend()
                    throws SystemException
Specified by:
suspend in interface TransactionManager
Throws:
SystemException

resume

public void resume(Transaction transaction)
            throws InvalidTransactionException,
                   IllegalStateException,
                   SystemException
Specified by:
resume in interface TransactionManager
Throws:
InvalidTransactionException
IllegalStateException
SystemException

getReference

public Reference getReference()
                       throws NamingException
BitronixTransactionManager can only have a single instance per JVM so this method always returns a reference with no special information to find back the sole instance. BitronixTransactionManagerObjectFactory will be used by the JNDI server to get the BitronixTransactionManager instance of the JVM.

Specified by:
getReference in interface Referenceable
Returns:
an empty reference to get the BitronixTransactionManager.
Throws:
NamingException

getInFlightTransactions

public Map getInFlightTransactions()
Return all in-flight transactions.

Returns:
a map of BitronixTransaction objects using Uid as key and BitronixTransaction as value.

getOldestInFlightTransactionTimestamp

public long getOldestInFlightTransactionTimestamp()
Return the timestamp of the oldest in-flight transaction.

Returns:
the timestamp or Long.MIN_VALUE if there is no in-flight transaction.

getCurrentTransaction

public BitronixTransaction getCurrentTransaction()
Get the transaction currently registered on the current thread context.

Returns:
the current transaction or null if no transaction has been started on the current thread.

dumpTransactionContexts

public void dumpTransactionContexts()
Dump an overview of all running transactions as debug logs.


shutdown

public void shutdown()
Shut down the transaction manager and release all resources held by it.

This call will also close the resources pools registered by the ResourceLoader like JMS and JDBC pools. The manually created ones are left untouched.

The Transaction Manager will wait during a configurable graceful period before forcibly killing active transactions.

After this method is called, attempts to create new transactions (via calls to TransactionManager.begin()) will be rejected with a SystemException.

Specified by:
shutdown in interface Service
See Also:
Configuration.getGracefulShutdownInterval()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/BitronixTransaction.html0000644000175000017500000012414512215446620022504 0ustar tonytony BitronixTransaction (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class BitronixTransaction

java.lang.Object
  extended by bitronix.tm.BitronixTransaction
All Implemented Interfaces:
BitronixTransactionMBean, Transaction

public class BitronixTransaction
extends Object
implements Transaction, BitronixTransactionMBean

Implementation of Transaction.

Author:
lorban

Constructor Summary
BitronixTransaction()
           
 
Method Summary
 void addTransactionStatusChangeListener(TransactionStatusChangeListener listener)
           
 void commit()
           
 boolean delistResource(XAResource xaResource, int flag)
           
 boolean enlistResource(XAResource xaResource)
           
 boolean equals(Object obj)
           
 Collection getEnlistedResourcesUniqueNames()
           
 String getGtrid()
           
 XAResourceManager getResourceManager()
           
 Date getStartDate()
           
 int getStatus()
           
 String getStatusDescription()
           
 Scheduler<Synchronization> getSynchronizationScheduler()
           
 String getThreadName()
           
 int hashCode()
           
 void registerSynchronization(Synchronization synchronization)
           
 void rollback()
           
 void setActive(int timeout)
           
 void setRollbackOnly()
           
 void setStatus(int status)
           
 void setStatus(int status, Set<String> uniqueNames)
           
 boolean timedOut()
           
 void timeout()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BitronixTransaction

public BitronixTransaction()
Method Detail

getStatus

public int getStatus()
              throws SystemException
Specified by:
getStatus in interface Transaction
Throws:
SystemException

enlistResource

public boolean enlistResource(XAResource xaResource)
                       throws RollbackException,
                              IllegalStateException,
                              SystemException
Specified by:
enlistResource in interface Transaction
Throws:
RollbackException
IllegalStateException
SystemException

delistResource

public boolean delistResource(XAResource xaResource,
                              int flag)
                       throws IllegalStateException,
                              SystemException
Specified by:
delistResource in interface Transaction
Throws:
IllegalStateException
SystemException

registerSynchronization

public void registerSynchronization(Synchronization synchronization)
                             throws RollbackException,
                                    IllegalStateException,
                                    SystemException
Specified by:
registerSynchronization in interface Transaction
Throws:
RollbackException
IllegalStateException
SystemException

getSynchronizationScheduler

public Scheduler<Synchronization> getSynchronizationScheduler()

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   SecurityException,
                   SystemException
Specified by:
commit in interface Transaction
Throws:
RollbackException
HeuristicMixedException
HeuristicRollbackException
SecurityException
SystemException

rollback

public void rollback()
              throws IllegalStateException,
                     SystemException
Specified by:
rollback in interface Transaction
Throws:
IllegalStateException
SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws IllegalStateException,
                            SystemException
Specified by:
setRollbackOnly in interface Transaction
Throws:
IllegalStateException
SystemException

getResourceManager

public XAResourceManager getResourceManager()

timeout

public void timeout()
             throws BitronixSystemException
Throws:
BitronixSystemException

timedOut

public boolean timedOut()

setActive

public void setActive(int timeout)
               throws IllegalStateException,
                      SystemException
Throws:
IllegalStateException
SystemException

setStatus

public void setStatus(int status)
               throws BitronixSystemException
Throws:
BitronixSystemException

setStatus

public void setStatus(int status,
                      Set<String> uniqueNames)
               throws BitronixSystemException
Throws:
BitronixSystemException

addTransactionStatusChangeListener

public void addTransactionStatusChangeListener(TransactionStatusChangeListener listener)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

getGtrid

public String getGtrid()
Specified by:
getGtrid in interface BitronixTransactionMBean

getStatusDescription

public String getStatusDescription()
Specified by:
getStatusDescription in interface BitronixTransactionMBean

getEnlistedResourcesUniqueNames

public Collection getEnlistedResourcesUniqueNames()
Specified by:
getEnlistedResourcesUniqueNames in interface BitronixTransactionMBean

getThreadName

public String getThreadName()
Specified by:
getThreadName in interface BitronixTransactionMBean

getStartDate

public Date getStartDate()
Specified by:
getStartDate in interface BitronixTransactionMBean


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/0000755000175000017500000000000012215446622016741 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/twopc/package-frame.html0000644000175000017500000000305112215446622022311 0ustar tonytony bitronix.tm.twopc (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.twopc
Classes 
AbstractPhaseEngine
Committer
Preparer
Rollbacker
Exceptions 
PhaseException
btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/0000755000175000017500000000000012215446622020577 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/package-frame.html0000644000175000017500000000277012215446622024156 0ustar tonytony bitronix.tm.twopc.executor (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.twopc.executor
Interfaces 
Executor
Classes 
AsyncExecutor
Job
SyncExecutor
btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/package-tree.html0000644000175000017500000001700412215446622024017 0ustar tonytony bitronix.tm.twopc.executor Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.twopc.executor

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/SyncExecutor.html0000644000175000017500000004467612215446622024141 0ustar tonytony SyncExecutor (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc.executor
Class SyncExecutor

java.lang.Object
  extended by bitronix.tm.twopc.executor.SyncExecutor
All Implemented Interfaces:
Executor, Service

public class SyncExecutor
extends Object
implements Executor

This implementation executes submitted jobs synchronously.

Author:
lorban

Constructor Summary
SyncExecutor()
           
 
Method Summary
 boolean isDone(Object future)
          Check if the thread pool has terminated the execution of the job represented by a future.
 void shutdown()
          Shutdown the thead pool.
 Object submit(Job job)
          Submit a job to be executed by the thread pool.
 void waitFor(Object future, long timeout)
          Wait for the job represented by the future to terminate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncExecutor

public SyncExecutor()
Method Detail

submit

public Object submit(Job job)
Description copied from interface: Executor
Submit a job to be executed by the thread pool.

Specified by:
submit in interface Executor
Parameters:
job - the Runnable to execute.
Returns:
an object used to monitor the execution of the submitted Runnable.

waitFor

public void waitFor(Object future,
                    long timeout)
Description copied from interface: Executor
Wait for the job represented by the future to terminate. The call to this method will block until the job finished its execution or the specified timeout elapsed.

Specified by:
waitFor in interface Executor
Parameters:
future - the future representing the job as returned by Executor.submit(bitronix.tm.twopc.executor.Job).
timeout - if the job did not finish during the specified timeout in milliseconds, this method returns anyway.

isDone

public boolean isDone(Object future)
Description copied from interface: Executor
Check if the thread pool has terminated the execution of the job represented by a future.

Specified by:
isDone in interface Executor
Parameters:
future - the future representing the job as returned by Executor.submit(bitronix.tm.twopc.executor.Job).
Returns:
true if the job is done, false otherwise.

shutdown

public void shutdown()
Description copied from interface: Executor
Shutdown the thead pool.

Specified by:
shutdown in interface Executor
Specified by:
shutdown in interface Service


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/package-use.html0000644000175000017500000002244012215446622023654 0ustar tonytony Uses of Package bitronix.tm.twopc.executor (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.twopc.executor

Packages that use bitronix.tm.twopc.executor
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.twopc Two-phase commit logic. 
bitronix.tm.twopc.executor Two-phase commit commands executors. 
 

Classes in bitronix.tm.twopc.executor used by bitronix.tm
Executor
          Thread pool interface required by the two-phase commit logic.
 

Classes in bitronix.tm.twopc.executor used by bitronix.tm.twopc
Executor
          Thread pool interface required by the two-phase commit logic.
Job
          Abstract job definition executable by the 2PC thread pools.
 

Classes in bitronix.tm.twopc.executor used by bitronix.tm.twopc.executor
Executor
          Thread pool interface required by the two-phase commit logic.
Job
          Abstract job definition executable by the 2PC thread pools.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/Job.html0000644000175000017500000004700212215446622022202 0ustar tonytony Job (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc.executor
Class Job

java.lang.Object
  extended by bitronix.tm.twopc.executor.Job
All Implemented Interfaces:
Runnable

public abstract class Job
extends Object
implements Runnable

Abstract job definition executable by the 2PC thread pools.

Author:
lorban

Field Summary
protected  RuntimeException runtimeException
           
protected  XAException xaException
           
 
Constructor Summary
Job(XAResourceHolderState resourceHolder)
           
 
Method Summary
protected abstract  void execute()
           
 Object getFuture()
           
 XAResourceHolderState getResource()
           
 RuntimeException getRuntimeException()
           
 XAException getXAException()
           
 void run()
           
 void setFuture(Object future)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xaException

protected volatile XAException xaException

runtimeException

protected volatile RuntimeException runtimeException
Constructor Detail

Job

public Job(XAResourceHolderState resourceHolder)
Method Detail

getResource

public XAResourceHolderState getResource()

getXAException

public XAException getXAException()

getRuntimeException

public RuntimeException getRuntimeException()

setFuture

public void setFuture(Object future)

getFuture

public Object getFuture()

run

public final void run()
Specified by:
run in interface Runnable

execute

protected abstract void execute()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/class-use/0000755000175000017500000000000012215446622022476 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/class-use/SyncExecutor.html0000644000175000017500000001404512215446622026023 0ustar tonytony Uses of Class bitronix.tm.twopc.executor.SyncExecutor (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.executor.SyncExecutor

No usage of bitronix.tm.twopc.executor.SyncExecutor



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/class-use/Job.html0000644000175000017500000003215212215446622024101 0ustar tonytony Uses of Class bitronix.tm.twopc.executor.Job (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.executor.Job

Packages that use Job
bitronix.tm.twopc Two-phase commit logic. 
bitronix.tm.twopc.executor Two-phase commit commands executors. 
 

Uses of Job in bitronix.tm.twopc
 

Methods in bitronix.tm.twopc that return Job
protected  Job Rollbacker.createJob(XAResourceHolderState resourceHolder)
           
protected  Job Preparer.createJob(XAResourceHolderState xaResourceHolderState)
           
protected  Job Committer.createJob(XAResourceHolderState resourceHolder)
           
protected abstract  Job AbstractPhaseEngine.createJob(XAResourceHolderState xaResourceHolderState)
          Create a Job that is going to execute the phase command on the given resource.
 

Uses of Job in bitronix.tm.twopc.executor
 

Methods in bitronix.tm.twopc.executor with parameters of type Job
 Object SyncExecutor.submit(Job job)
           
 Object Executor.submit(Job job)
          Submit a job to be executed by the thread pool.
 Object AsyncExecutor.submit(Job job)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/class-use/Executor.html0000644000175000017500000003110212215446622025157 0ustar tonytony Uses of Interface bitronix.tm.twopc.executor.Executor (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.twopc.executor.Executor

Packages that use Executor
bitronix.tm JTA interfaces implementations and global services. 
bitronix.tm.twopc Two-phase commit logic. 
bitronix.tm.twopc.executor Two-phase commit commands executors. 
 

Uses of Executor in bitronix.tm
 

Methods in bitronix.tm that return Executor
static Executor TransactionManagerServices.getExecutor()
          Create the 2PC executor.
 

Uses of Executor in bitronix.tm.twopc
 

Constructors in bitronix.tm.twopc with parameters of type Executor
AbstractPhaseEngine(Executor executor)
           
Committer(Executor executor)
           
Preparer(Executor executor)
           
Rollbacker(Executor executor)
           
 

Uses of Executor in bitronix.tm.twopc.executor
 

Classes in bitronix.tm.twopc.executor that implement Executor
 class AsyncExecutor
          This implementation executes submitted jobs using a java.util.concurrent cached thread pool.
 class SyncExecutor
          This implementation executes submitted jobs synchronously.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/class-use/AsyncExecutor.html0000644000175000017500000001405712215446622026167 0ustar tonytony Uses of Class bitronix.tm.twopc.executor.AsyncExecutor (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.executor.AsyncExecutor

No usage of bitronix.tm.twopc.executor.AsyncExecutor



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/package-summary.html0000644000175000017500000001745512215446622024567 0ustar tonytony bitronix.tm.twopc.executor (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.twopc.executor

Two-phase commit commands executors.

See:
          Description

Interface Summary
Executor Thread pool interface required by the two-phase commit logic.
 

Class Summary
AsyncExecutor This implementation executes submitted jobs using a java.util.concurrent cached thread pool.
Job Abstract job definition executable by the 2PC thread pools.
SyncExecutor This implementation executes submitted jobs synchronously.
 

Package bitronix.tm.twopc.executor Description

Two-phase commit commands executors.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/Executor.html0000644000175000017500000003245412215446622023273 0ustar tonytony Executor (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc.executor
Interface Executor

All Superinterfaces:
Service
All Known Implementing Classes:
AsyncExecutor, SyncExecutor

public interface Executor
extends Service

Thread pool interface required by the two-phase commit logic.

Author:
lorban

Method Summary
 boolean isDone(Object future)
          Check if the thread pool has terminated the execution of the job represented by a future.
 void shutdown()
          Shutdown the thead pool.
 Object submit(Job job)
          Submit a job to be executed by the thread pool.
 void waitFor(Object future, long timeout)
          Wait for the job represented by the future to terminate.
 

Method Detail

submit

Object submit(Job job)
Submit a job to be executed by the thread pool.

Parameters:
job - the Runnable to execute.
Returns:
an object used to monitor the execution of the submitted Runnable.

waitFor

void waitFor(Object future,
             long timeout)
Wait for the job represented by the future to terminate. The call to this method will block until the job finished its execution or the specified timeout elapsed.

Parameters:
future - the future representing the job as returned by submit(bitronix.tm.twopc.executor.Job).
timeout - if the job did not finish during the specified timeout in milliseconds, this method returns anyway.

isDone

boolean isDone(Object future)
Check if the thread pool has terminated the execution of the job represented by a future.

Parameters:
future - the future representing the job as returned by submit(bitronix.tm.twopc.executor.Job).
Returns:
true if the job is done, false otherwise.

shutdown

void shutdown()
Shutdown the thead pool.

Specified by:
shutdown in interface Service


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/executor/AsyncExecutor.html0000644000175000017500000004502412215446622024266 0ustar tonytony AsyncExecutor (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc.executor
Class AsyncExecutor

java.lang.Object
  extended by bitronix.tm.twopc.executor.AsyncExecutor
All Implemented Interfaces:
Executor, Service

public class AsyncExecutor
extends Object
implements Executor

This implementation executes submitted jobs using a java.util.concurrent cached thread pool.

Author:
lorban

Constructor Summary
AsyncExecutor()
           
 
Method Summary
 boolean isDone(Object future)
          Check if the thread pool has terminated the execution of the job represented by a future.
 void shutdown()
          Shutdown the thead pool.
 Object submit(Job job)
          Submit a job to be executed by the thread pool.
 void waitFor(Object future, long timeout)
          Wait for the job represented by the future to terminate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncExecutor

public AsyncExecutor()
Method Detail

submit

public Object submit(Job job)
Description copied from interface: Executor
Submit a job to be executed by the thread pool.

Specified by:
submit in interface Executor
Parameters:
job - the Runnable to execute.
Returns:
an object used to monitor the execution of the submitted Runnable.

waitFor

public void waitFor(Object future,
                    long timeout)
Description copied from interface: Executor
Wait for the job represented by the future to terminate. The call to this method will block until the job finished its execution or the specified timeout elapsed.

Specified by:
waitFor in interface Executor
Parameters:
future - the future representing the job as returned by Executor.submit(bitronix.tm.twopc.executor.Job).
timeout - if the job did not finish during the specified timeout in milliseconds, this method returns anyway.

isDone

public boolean isDone(Object future)
Description copied from interface: Executor
Check if the thread pool has terminated the execution of the job represented by a future.

Specified by:
isDone in interface Executor
Parameters:
future - the future representing the job as returned by Executor.submit(bitronix.tm.twopc.executor.Job).
Returns:
true if the job is done, false otherwise.

shutdown

public void shutdown()
Description copied from interface: Executor
Shutdown the thead pool.

Specified by:
shutdown in interface Executor
Specified by:
shutdown in interface Service


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/PhaseException.html0000644000175000017500000004631612215446622022560 0ustar tonytony PhaseException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc
Class PhaseException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by bitronix.tm.twopc.PhaseException
All Implemented Interfaces:
Serializable

public class PhaseException
extends Exception

Thrown when a phase exection has thrown one or more exception(s).

Author:
lorban
See Also:
Serialized Form

Constructor Summary
PhaseException(List<Exception> exceptions, List<XAResourceHolderState> resourceStates)
           
 
Method Summary
 List<Exception> getExceptions()
          Get the list of exceptions that have been thrown during a phase execution.
 String getMessage()
           
 List<XAResourceHolderState> getResourceStates()
          Get the list of resource which threw an exception during a phase execution.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PhaseException

public PhaseException(List<Exception> exceptions,
                      List<XAResourceHolderState> resourceStates)
Method Detail

getMessage

public String getMessage()
Overrides:
getMessage in class Throwable

getExceptions

public List<Exception> getExceptions()
Get the list of exceptions that have been thrown during a phase execution.

Returns:
the list of exceptions that have been thrown during a phase execution.

getResourceStates

public List<XAResourceHolderState> getResourceStates()
Get the list of resource which threw an exception during a phase execution. This list always contains exactly one resource per exception present in getExceptions() list. Indices of both list always match a resource against the exception it threw.

Returns:
the list of resource which threw an exception during a phase execution.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/Committer.html0000644000175000017500000005001512215446622021573 0ustar tonytony Committer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc
Class Committer

java.lang.Object
  extended by bitronix.tm.twopc.AbstractPhaseEngine
      extended by bitronix.tm.twopc.Committer

public final class Committer
extends AbstractPhaseEngine

Phase 2 Commit logic engine.

Author:
lorban

Constructor Summary
Committer(Executor executor)
           
 
Method Summary
 void commit(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Execute phase 2 commit.
protected  Job createJob(XAResourceHolderState resourceHolder)
          Create a Job that is going to execute the phase command on the given resource.
protected  boolean isParticipating(XAResourceHolderState xaResourceHolderState)
          Determine if a resource is participating in the phase or not.
 
Methods inherited from class bitronix.tm.twopc.AbstractPhaseEngine
collectNotInterestedResources, collectResourcesUniqueNames, executePhase, logFailedResources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Committer

public Committer(Executor executor)
Method Detail

commit

public void commit(BitronixTransaction transaction,
                   List<XAResourceHolderState> interestedResources)
            throws HeuristicMixedException,
                   HeuristicRollbackException,
                   BitronixSystemException,
                   BitronixRollbackException
Execute phase 2 commit.

Parameters:
transaction - the transaction wanting to commit phase 2
interestedResources - a map of phase 1 prepared resources wanting to participate in phase 2 using Xids as keys
Throws:
HeuristicRollbackException - when all resources committed instead.
HeuristicMixedException - when some resources committed and some rolled back.
BitronixSystemException - when an internal error occured.
BitronixRollbackException - during 1PC when resource fails to commit

createJob

protected Job createJob(XAResourceHolderState resourceHolder)
Description copied from class: AbstractPhaseEngine
Create a Job that is going to execute the phase command on the given resource.

Specified by:
createJob in class AbstractPhaseEngine
Parameters:
resourceHolder - the resource that is going to receive a command.
Returns:
the Job that is going to execute the command.

isParticipating

protected boolean isParticipating(XAResourceHolderState xaResourceHolderState)
Description copied from class: AbstractPhaseEngine
Determine if a resource is participating in the phase or not. A participating resource gets a job created to execute the phase's command on it.

Specified by:
isParticipating in class AbstractPhaseEngine
Parameters:
xaResourceHolderState - the resource to check for its participation.
Returns:
true if the resource must participate in the phase.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/package-tree.html0000644000175000017500000001653012215446622022164 0ustar tonytony bitronix.tm.twopc Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.twopc

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/package-use.html0000644000175000017500000001577412215446622022032 0ustar tonytony Uses of Package bitronix.tm.twopc (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.twopc

Packages that use bitronix.tm.twopc
bitronix.tm.twopc Two-phase commit logic. 
 

Classes in bitronix.tm.twopc used by bitronix.tm.twopc
AbstractPhaseEngine
          Abstract phase execution engine.
PhaseException
          Thrown when a phase exection has thrown one or more exception(s).
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/Preparer.html0000644000175000017500000004643712215446622021425 0ustar tonytony Preparer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc
Class Preparer

java.lang.Object
  extended by bitronix.tm.twopc.AbstractPhaseEngine
      extended by bitronix.tm.twopc.Preparer

public final class Preparer
extends AbstractPhaseEngine

Phase 1 Prepare logic engine.

Author:
lorban

Constructor Summary
Preparer(Executor executor)
           
 
Method Summary
protected  Job createJob(XAResourceHolderState xaResourceHolderState)
          Create a Job that is going to execute the phase command on the given resource.
protected  boolean isParticipating(XAResourceHolderState xaResourceHolderState)
          Determine if a resource is participating in the phase or not.
 List<XAResourceHolderState> prepare(BitronixTransaction transaction)
          Execute phase 1 prepare.
 
Methods inherited from class bitronix.tm.twopc.AbstractPhaseEngine
collectNotInterestedResources, collectResourcesUniqueNames, executePhase, logFailedResources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Preparer

public Preparer(Executor executor)
Method Detail

prepare

public List<XAResourceHolderState> prepare(BitronixTransaction transaction)
                                    throws RollbackException,
                                           BitronixSystemException
Execute phase 1 prepare.

Parameters:
transaction - the transaction to prepare.
Returns:
a list that will be filled with all resources that received the prepare command and replied with XAResource.XA_OK.
Throws:
RollbackException - when an error occured that can be fixed with a rollback.
BitronixSystemException - when an internal error occured.

createJob

protected Job createJob(XAResourceHolderState xaResourceHolderState)
Description copied from class: AbstractPhaseEngine
Create a Job that is going to execute the phase command on the given resource.

Specified by:
createJob in class AbstractPhaseEngine
Parameters:
xaResourceHolderState - the resource that is going to receive a command.
Returns:
the Job that is going to execute the command.

isParticipating

protected boolean isParticipating(XAResourceHolderState xaResourceHolderState)
Description copied from class: AbstractPhaseEngine
Determine if a resource is participating in the phase or not. A participating resource gets a job created to execute the phase's command on it.

Specified by:
isParticipating in class AbstractPhaseEngine
Parameters:
xaResourceHolderState - the resource to check for its participation.
Returns:
true if the resource must participate in the phase.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/class-use/0000755000175000017500000000000012215446622020640 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/twopc/class-use/PhaseException.html0000644000175000017500000002150612215446622024451 0ustar tonytony Uses of Class bitronix.tm.twopc.PhaseException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.PhaseException

Packages that use PhaseException
bitronix.tm.twopc Two-phase commit logic. 
 

Uses of PhaseException in bitronix.tm.twopc
 

Methods in bitronix.tm.twopc with parameters of type PhaseException
protected  void AbstractPhaseEngine.logFailedResources(PhaseException ex)
          Log exceptions that happened during a phase failure.
 

Methods in bitronix.tm.twopc that throw PhaseException
protected  void AbstractPhaseEngine.executePhase(XAResourceManager resourceManager, boolean reverse)
          Execute the phase.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/class-use/Committer.html0000644000175000017500000001357212215446622023501 0ustar tonytony Uses of Class bitronix.tm.twopc.Committer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.Committer

No usage of bitronix.tm.twopc.Committer



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/class-use/Preparer.html0000644000175000017500000001356012215446622023313 0ustar tonytony Uses of Class bitronix.tm.twopc.Preparer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.Preparer

No usage of bitronix.tm.twopc.Preparer



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/class-use/Rollbacker.html0000644000175000017500000001360412215446622023612 0ustar tonytony Uses of Class bitronix.tm.twopc.Rollbacker (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.Rollbacker

No usage of bitronix.tm.twopc.Rollbacker



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/class-use/AbstractPhaseEngine.html0000644000175000017500000002061012215446622025377 0ustar tonytony Uses of Class bitronix.tm.twopc.AbstractPhaseEngine (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.twopc.AbstractPhaseEngine

Packages that use AbstractPhaseEngine
bitronix.tm.twopc Two-phase commit logic. 
 

Uses of AbstractPhaseEngine in bitronix.tm.twopc
 

Subclasses of AbstractPhaseEngine in bitronix.tm.twopc
 class Committer
          Phase 2 Commit logic engine.
 class Preparer
          Phase 1 Prepare logic engine.
 class Rollbacker
          Phase 1 & 2 Rollback logic engine.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/package-summary.html0000644000175000017500000001733112215446622022722 0ustar tonytony bitronix.tm.twopc (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.twopc

Two-phase commit logic.

See:
          Description

Class Summary
AbstractPhaseEngine Abstract phase execution engine.
Committer Phase 2 Commit logic engine.
Preparer Phase 1 Prepare logic engine.
Rollbacker Phase 1 & 2 Rollback logic engine.
 

Exception Summary
PhaseException Thrown when a phase exection has thrown one or more exception(s).
 

Package bitronix.tm.twopc Description

Two-phase commit logic.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/Rollbacker.html0000644000175000017500000004714612215446622021723 0ustar tonytony Rollbacker (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc
Class Rollbacker

java.lang.Object
  extended by bitronix.tm.twopc.AbstractPhaseEngine
      extended by bitronix.tm.twopc.Rollbacker

public final class Rollbacker
extends AbstractPhaseEngine

Phase 1 & 2 Rollback logic engine.

Author:
lorban

Constructor Summary
Rollbacker(Executor executor)
           
 
Method Summary
protected  Job createJob(XAResourceHolderState resourceHolder)
          Create a Job that is going to execute the phase command on the given resource.
protected  boolean isParticipating(XAResourceHolderState xaResourceHolderState)
          Determine if a resource is participating in the phase or not.
 void rollback(BitronixTransaction transaction, List<XAResourceHolderState> interestedResources)
          Rollback the current XA transaction.
 
Methods inherited from class bitronix.tm.twopc.AbstractPhaseEngine
collectNotInterestedResources, collectResourcesUniqueNames, executePhase, logFailedResources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rollbacker

public Rollbacker(Executor executor)
Method Detail

rollback

public void rollback(BitronixTransaction transaction,
                     List<XAResourceHolderState> interestedResources)
              throws HeuristicMixedException,
                     HeuristicCommitException,
                     BitronixSystemException
Rollback the current XA transaction. Transaction will not timeout while changing status but rather by some extra logic that will manually throw the exception after doing as much cleanup as possible.

Parameters:
transaction - the transaction to rollback.
interestedResources - resources that should be rolled back.
Throws:
HeuristicCommitException - when all resources committed instead.
HeuristicMixedException - when some resources committed and some rolled back.
BitronixSystemException - when an internal error occured.

createJob

protected Job createJob(XAResourceHolderState resourceHolder)
Description copied from class: AbstractPhaseEngine
Create a Job that is going to execute the phase command on the given resource.

Specified by:
createJob in class AbstractPhaseEngine
Parameters:
resourceHolder - the resource that is going to receive a command.
Returns:
the Job that is going to execute the command.

isParticipating

protected boolean isParticipating(XAResourceHolderState xaResourceHolderState)
Description copied from class: AbstractPhaseEngine
Determine if a resource is participating in the phase or not. A participating resource gets a job created to execute the phase's command on it.

Specified by:
isParticipating in class AbstractPhaseEngine
Parameters:
xaResourceHolderState - the resource to check for its participation.
Returns:
true if the resource must participate in the phase.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/twopc/AbstractPhaseEngine.html0000644000175000017500000005511112215446622023504 0ustar tonytony AbstractPhaseEngine (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.twopc
Class AbstractPhaseEngine

java.lang.Object
  extended by bitronix.tm.twopc.AbstractPhaseEngine
Direct Known Subclasses:
Committer, Preparer, Rollbacker

public abstract class AbstractPhaseEngine
extends Object

Abstract phase execution engine.

Author:
lorban

Constructor Summary
protected AbstractPhaseEngine(Executor executor)
           
 
Method Summary
protected static List<XAResourceHolderState> collectNotInterestedResources(List<XAResourceHolderState> allResources, List<XAResourceHolderState> interestedResources)
           
protected static Set<String> collectResourcesUniqueNames(List<XAResourceHolderState> resources)
           
protected abstract  Job createJob(XAResourceHolderState xaResourceHolderState)
          Create a Job that is going to execute the phase command on the given resource.
protected  void executePhase(XAResourceManager resourceManager, boolean reverse)
          Execute the phase.
protected abstract  boolean isParticipating(XAResourceHolderState xaResourceHolderState)
          Determine if a resource is participating in the phase or not.
protected  void logFailedResources(PhaseException ex)
          Log exceptions that happened during a phase failure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPhaseEngine

protected AbstractPhaseEngine(Executor executor)
Method Detail

executePhase

protected void executePhase(XAResourceManager resourceManager,
                            boolean reverse)
                     throws PhaseException
Execute the phase. Resources receive the phase command in position order (reversed or not). If there is more than once resource in a position, command is sent in enlistment order (again reversed or not). If Configuration.isAsynchronous2Pc() is true, all commands in a given position are sent in parallel by using the detected Executor implementation.

Parameters:
resourceManager - the XAResourceManager containing the enlisted resources to execute the phase on.
reverse - true if jobs should be executed in reverse position / enlistment order, false for natural position / enlistment order.
Throws:
PhaseException - if one or more resource threw an exception during phase execution.
See Also:
SyncExecutor, AsyncExecutor

isParticipating

protected abstract boolean isParticipating(XAResourceHolderState xaResourceHolderState)
Determine if a resource is participating in the phase or not. A participating resource gets a job created to execute the phase's command on it.

Parameters:
xaResourceHolderState - the resource to check for its participation.
Returns:
true if the resource must participate in the phase.

createJob

protected abstract Job createJob(XAResourceHolderState xaResourceHolderState)
Create a Job that is going to execute the phase command on the given resource.

Parameters:
xaResourceHolderState - the resource that is going to receive a command.
Returns:
the Job that is going to execute the command.

logFailedResources

protected void logFailedResources(PhaseException ex)
Log exceptions that happened during a phase failure.

Parameters:
ex - the phase exception.

collectResourcesUniqueNames

protected static Set<String> collectResourcesUniqueNames(List<XAResourceHolderState> resources)

collectNotInterestedResources

protected static List<XAResourceHolderState> collectNotInterestedResources(List<XAResourceHolderState> allResources,
                                                                           List<XAResourceHolderState> interestedResources)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/0000755000175000017500000000000012215446622016371 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/gui/package-frame.html0000644000175000017500000000424212215446622021744 0ustar tonytony bitronix.tm.gui (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.gui
Classes 
Console
DuplicatedGtridTableModel
PendingTransactionTableModel
RawTransactionTableModel
ResourcesPanel
ResourcesTreeModel
TransactionLogDialog
TransactionLogHeaderPanel
TransactionTableCellRenderer
TransactionTableModel
TransactionTableMouseListener
btm-dist-2.1.4/doc/api/bitronix/tm/gui/PendingTransactionTableModel.html0000644000175000017500000005745012215446620025013 0ustar tonytony PendingTransactionTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class PendingTransactionTableModel

java.lang.Object
  extended by bitronix.tm.gui.TransactionTableModel
      extended by bitronix.tm.gui.PendingTransactionTableModel
All Implemented Interfaces:
TableModel

public class PendingTransactionTableModel
extends TransactionTableModel

Author:
lorban

Field Summary
 
Fields inherited from class bitronix.tm.gui.TransactionTableModel
tLogs
 
Constructor Summary
PendingTransactionTableModel(File filename)
           
 
Method Summary
 boolean acceptLog(TransactionLogRecord tlog)
           
 void addTableModelListener(TableModelListener l)
           
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 TransactionLogRecord getRow(int row)
           
 int getRowCount()
           
 Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
protected  void readFullTransactionLog(File filename)
           
 void removeTableModelListener(TableModelListener l)
           
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PendingTransactionTableModel

public PendingTransactionTableModel(File filename)
Method Detail

getColumnCount

public int getColumnCount()

getRowCount

public int getRowCount()

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)

getColumnClass

public Class getColumnClass(int columnIndex)

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)

getColumnName

public String getColumnName(int columnIndex)

addTableModelListener

public void addTableModelListener(TableModelListener l)

removeTableModelListener

public void removeTableModelListener(TableModelListener l)

readFullTransactionLog

protected void readFullTransactionLog(File filename)
                               throws IOException
Overrides:
readFullTransactionLog in class TransactionTableModel
Throws:
IOException

acceptLog

public boolean acceptLog(TransactionLogRecord tlog)
Specified by:
acceptLog in class TransactionTableModel

getRow

public TransactionLogRecord getRow(int row)
Specified by:
getRow in class TransactionTableModel


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/RawTransactionTableModel.html0000644000175000017500000006063512215446620024157 0ustar tonytony RawTransactionTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class RawTransactionTableModel

java.lang.Object
  extended by bitronix.tm.gui.TransactionTableModel
      extended by bitronix.tm.gui.RawTransactionTableModel
All Implemented Interfaces:
TableModel

public class RawTransactionTableModel
extends TransactionTableModel

Author:
lorban

Field Summary
static int GTRID_COL
           
 
Fields inherited from class bitronix.tm.gui.TransactionTableModel
tLogs
 
Constructor Summary
RawTransactionTableModel(File filename)
           
 
Method Summary
 boolean acceptLog(TransactionLogRecord tlog)
           
 void addTableModelListener(TableModelListener l)
           
 void filterByGtrid(String gtrid)
           
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 TransactionLogRecord getRow(int row)
           
 int getRowCount()
           
 Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 void removeTableModelListener(TableModelListener l)
           
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 
Methods inherited from class bitronix.tm.gui.TransactionTableModel
readFullTransactionLog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GTRID_COL

public static final int GTRID_COL
See Also:
Constant Field Values
Constructor Detail

RawTransactionTableModel

public RawTransactionTableModel(File filename)
Method Detail

getColumnCount

public int getColumnCount()

getRowCount

public int getRowCount()

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)

getColumnClass

public Class getColumnClass(int columnIndex)

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)

getColumnName

public String getColumnName(int columnIndex)

addTableModelListener

public void addTableModelListener(TableModelListener l)

removeTableModelListener

public void removeTableModelListener(TableModelListener l)

acceptLog

public boolean acceptLog(TransactionLogRecord tlog)
Specified by:
acceptLog in class TransactionTableModel

getRow

public TransactionLogRecord getRow(int row)
Specified by:
getRow in class TransactionTableModel

filterByGtrid

public void filterByGtrid(String gtrid)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/ResourcesPanel.html0000644000175000017500000025253012215446620022216 0ustar tonytony ResourcesPanel (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class ResourcesPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by bitronix.tm.gui.ResourcesPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ResourcesPanel
extends JPanel

Author:
lorban
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ResourcesPanel()
           
 
Method Summary
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourcesPanel

public ResourcesPanel()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/package-tree.html0000644000175000017500000003601612215446622021615 0ustar tonytony bitronix.tm.gui Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.gui

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/package-use.html0000644000175000017500000001520712215446622021451 0ustar tonytony Uses of Package bitronix.tm.gui (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.gui

Packages that use bitronix.tm.gui
bitronix.tm.gui GUI admin console. 
 

Classes in bitronix.tm.gui used by bitronix.tm.gui
TransactionTableModel
          
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/TransactionTableMouseListener.html0000644000175000017500000004112512215446620025234 0ustar tonytony TransactionTableMouseListener (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class TransactionTableMouseListener

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by bitronix.tm.gui.TransactionTableMouseListener
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class TransactionTableMouseListener
extends MouseAdapter

Author:
lorban

Constructor Summary
TransactionTableMouseListener(JFrame frame, JTable table)
           
 
Method Summary
 void mouseClicked(MouseEvent evt)
           
 
Methods inherited from class java.awt.event.MouseAdapter
mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionTableMouseListener

public TransactionTableMouseListener(JFrame frame,
                                     JTable table)
Method Detail

mouseClicked

public void mouseClicked(MouseEvent evt)
Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class MouseAdapter


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/0000755000175000017500000000000012215446622020270 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/PendingTransactionTableModel.html0000644000175000017500000001404412215446622026704 0ustar tonytony Uses of Class bitronix.tm.gui.PendingTransactionTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.PendingTransactionTableModel

No usage of bitronix.tm.gui.PendingTransactionTableModel



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/RawTransactionTableModel.html0000644000175000017500000001377412215446622026062 0ustar tonytony Uses of Class bitronix.tm.gui.RawTransactionTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.RawTransactionTableModel

No usage of bitronix.tm.gui.RawTransactionTableModel



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/ResourcesPanel.html0000644000175000017500000001363012215446622024113 0ustar tonytony Uses of Class bitronix.tm.gui.ResourcesPanel (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.ResourcesPanel

No usage of bitronix.tm.gui.ResourcesPanel



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/TransactionTableMouseListener.html0000644000175000017500000001405612215446622027140 0ustar tonytony Uses of Class bitronix.tm.gui.TransactionTableMouseListener (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.TransactionTableMouseListener

No usage of bitronix.tm.gui.TransactionTableMouseListener



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/Console.html0000644000175000017500000001352212215446622022563 0ustar tonytony Uses of Class bitronix.tm.gui.Console (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.Console

No usage of bitronix.tm.gui.Console



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/ResourcesTreeModel.html0000644000175000017500000001370012215446622024732 0ustar tonytony Uses of Class bitronix.tm.gui.ResourcesTreeModel (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.ResourcesTreeModel

No usage of bitronix.tm.gui.ResourcesTreeModel



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/DuplicatedGtridTableModel.html0000644000175000017500000001400612215446622026160 0ustar tonytony Uses of Class bitronix.tm.gui.DuplicatedGtridTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.DuplicatedGtridTableModel

No usage of bitronix.tm.gui.DuplicatedGtridTableModel



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/TransactionLogDialog.html0000644000175000017500000001372412215446622025234 0ustar tonytony Uses of Class bitronix.tm.gui.TransactionLogDialog (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.TransactionLogDialog

No usage of bitronix.tm.gui.TransactionLogDialog



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/TransactionLogHeaderPanel.html0000644000175000017500000001400612215446622026177 0ustar tonytony Uses of Class bitronix.tm.gui.TransactionLogHeaderPanel (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.TransactionLogHeaderPanel

No usage of bitronix.tm.gui.TransactionLogHeaderPanel



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/TransactionTableCellRenderer.html0000644000175000017500000001404412215446622026705 0ustar tonytony Uses of Class bitronix.tm.gui.TransactionTableCellRenderer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.TransactionTableCellRenderer

No usage of bitronix.tm.gui.TransactionTableCellRenderer



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/class-use/TransactionTableModel.html0000644000175000017500000001777512215446622025415 0ustar tonytony Uses of Class bitronix.tm.gui.TransactionTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.gui.TransactionTableModel

Packages that use TransactionTableModel
bitronix.tm.gui GUI admin console. 
 

Uses of TransactionTableModel in bitronix.tm.gui
 

Subclasses of TransactionTableModel in bitronix.tm.gui
 class PendingTransactionTableModel
          
 class RawTransactionTableModel
          
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/Console.html0000644000175000017500000027316212215446620020672 0ustar tonytony Console (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class Console

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by bitronix.tm.gui.Console
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class Console
extends JFrame

Author:
lorban
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected static SimpleDateFormat dateFormatter
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Console()
           
 
Method Summary
static void main(String[] args)
           
static File pickCurrentLogFile(File file1, File file2)
           
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

dateFormatter

protected static final SimpleDateFormat dateFormatter
Constructor Detail

Console

public Console()
        throws IOException
Throws:
IOException
Method Detail

pickCurrentLogFile

public static File pickCurrentLogFile(File file1,
                                      File file2)
                               throws IOException
Throws:
IOException

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/package-summary.html0000644000175000017500000002110612215446622022345 0ustar tonytony bitronix.tm.gui (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.gui

GUI admin console.

See:
          Description

Class Summary
Console
DuplicatedGtridTableModel
PendingTransactionTableModel
RawTransactionTableModel
ResourcesPanel  
ResourcesTreeModel  
TransactionLogDialog
TransactionLogHeaderPanel
TransactionTableCellRenderer
TransactionTableModel
TransactionTableMouseListener
 

Package bitronix.tm.gui Description

GUI admin console.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/ResourcesTreeModel.html0000644000175000017500000005563312215446620023044 0ustar tonytony ResourcesTreeModel (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class ResourcesTreeModel

java.lang.Object
  extended by bitronix.tm.gui.ResourcesTreeModel
All Implemented Interfaces:
TreeModel

public class ResourcesTreeModel
extends Object
implements TreeModel

Author:
lorban

Constructor Summary
ResourcesTreeModel()
           
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
           
 Object getChild(Object parent, int index)
           
 int getChildCount(Object parent)
           
 int getIndexOfChild(Object parent, Object child)
           
 Object getRoot()
           
 boolean isLeaf(Object node)
           
 void removeTreeModelListener(TreeModelListener l)
           
 void valueForPathChanged(TreePath path, Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourcesTreeModel

public ResourcesTreeModel()
Method Detail

getRoot

public Object getRoot()
Specified by:
getRoot in interface TreeModel

getChildCount

public int getChildCount(Object parent)
Specified by:
getChildCount in interface TreeModel

isLeaf

public boolean isLeaf(Object node)
Specified by:
isLeaf in interface TreeModel

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Specified by:
addTreeModelListener in interface TreeModel

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Specified by:
removeTreeModelListener in interface TreeModel

getChild

public Object getChild(Object parent,
                       int index)
Specified by:
getChild in interface TreeModel

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Specified by:
getIndexOfChild in interface TreeModel

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Specified by:
valueForPathChanged in interface TreeModel


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/DuplicatedGtridTableModel.html0000644000175000017500000006634012215446620024267 0ustar tonytony DuplicatedGtridTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class DuplicatedGtridTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by javax.swing.table.DefaultTableModel
          extended by bitronix.tm.gui.DuplicatedGtridTableModel
All Implemented Interfaces:
Serializable, TableModel

public class DuplicatedGtridTableModel
extends DefaultTableModel

Author:
lorban
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DuplicatedGtridTableModel(Map map)
           
 
Method Summary
 String getColumnName(int column)
           
 Object getValueAt(int row, int column)
           
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getDataVector, getRowCount, insertRow, insertRow, isCellEditable, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount, setValueAt
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DuplicatedGtridTableModel

public DuplicatedGtridTableModel(Map map)
Method Detail

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class DefaultTableModel

getValueAt

public Object getValueAt(int row,
                         int column)
Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class DefaultTableModel


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/TransactionLogDialog.html0000644000175000017500000025336512215446620023342 0ustar tonytony TransactionLogDialog (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class TransactionLogDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by bitronix.tm.gui.TransactionLogDialog
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class TransactionLogDialog
extends JDialog

Author:
lorban
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TransactionLogDialog(JFrame frame, TransactionLogRecord tlog)
           
 
Method Summary
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionLogDialog

public TransactionLogDialog(JFrame frame,
                            TransactionLogRecord tlog)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/TransactionLogHeaderPanel.html0000644000175000017500000026250012215446620024302 0ustar tonytony TransactionLogHeaderPanel (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class TransactionLogHeaderPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by bitronix.tm.gui.TransactionLogHeaderPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class TransactionLogHeaderPanel
extends JPanel

Author:
lorban
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TransactionLogHeaderPanel()
           
 
Method Summary
 void read(File logFile, boolean active)
           
 void setLogFile(File logFile)
           
 void setPosition(long position)
           
 void setState(byte state)
           
 void setTimestamp(long timestamp)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionLogHeaderPanel

public TransactionLogHeaderPanel()
Method Detail

setLogFile

public void setLogFile(File logFile)

setTimestamp

public void setTimestamp(long timestamp)

setState

public void setState(byte state)

setPosition

public void setPosition(long position)

read

public void read(File logFile,
                 boolean active)
          throws IOException
Throws:
IOException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/TransactionTableCellRenderer.html0000644000175000017500000031207312215446620025007 0ustar tonytony TransactionTableCellRenderer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class TransactionTableCellRenderer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by javax.swing.table.DefaultTableCellRenderer
                      extended by bitronix.tm.gui.TransactionTableCellRenderer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, TableCellRenderer

public class TransactionTableCellRenderer
extends DefaultTableCellRenderer

Author:
lorban
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.table.DefaultTableCellRenderer
DefaultTableCellRenderer.UIResource
 
Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableCellRenderer
noFocusBorder
 
Fields inherited from class javax.swing.JLabel
labelFor
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TransactionTableCellRenderer()
           
 
Method Summary
 Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
           
 
Methods inherited from class javax.swing.table.DefaultTableCellRenderer
firePropertyChange, firePropertyChange, invalidate, isOpaque, repaint, repaint, repaint, revalidate, setBackground, setForeground, setValue, updateUI, validate
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionTableCellRenderer

public TransactionTableCellRenderer()
Method Detail

getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
Specified by:
getTableCellRendererComponent in interface TableCellRenderer
Overrides:
getTableCellRendererComponent in class DefaultTableCellRenderer


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/gui/TransactionTableModel.html0000644000175000017500000004507512215446620023506 0ustar tonytony TransactionTableModel (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.gui
Class TransactionTableModel

java.lang.Object
  extended by bitronix.tm.gui.TransactionTableModel
All Implemented Interfaces:
TableModel
Direct Known Subclasses:
PendingTransactionTableModel, RawTransactionTableModel

public abstract class TransactionTableModel
extends Object
implements TableModel

Author:
lorban

Field Summary
protected  List tLogs
           
 
Constructor Summary
TransactionTableModel()
           
 
Method Summary
abstract  boolean acceptLog(TransactionLogRecord tlog)
           
abstract  TransactionLogRecord getRow(int row)
           
protected  void readFullTransactionLog(File filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 

Field Detail

tLogs

protected List tLogs
Constructor Detail

TransactionTableModel

public TransactionTableModel()
Method Detail

readFullTransactionLog

protected void readFullTransactionLog(File filename)
                               throws IOException
Throws:
IOException

acceptLog

public abstract boolean acceptLog(TransactionLogRecord tlog)

getRow

public abstract TransactionLogRecord getRow(int row)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/BitronixXid.html0000644000175000017500000006070612215446620020745 0ustar tonytony BitronixXid (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class BitronixXid

java.lang.Object
  extended by bitronix.tm.BitronixXid
All Implemented Interfaces:
Xid

public class BitronixXid
extends Object
implements Xid

Implementation of Xid.

A XID is divided in two parts: globalTransactionId (GTRID) and branchQualifier (BQUAL). The first one uniquely identifies the global transaction while the latter uniquely identifies the transaction branch, or the local part of the global transaction inside a resource.

Technically in the Bitronix implementation, GTRID and BQUAL have the same format as described by Mike Spille. Each BitronixTransaction get assigned a GTRID at creation time and full XIDs are created and assigned to every XAResourceHolderState when enlisted in the transaction's XAResourceManager. Both GTRID and XIDs are generated by the UidGenerator.

Author:
lorban
See Also:
UidGenerator, BitronixTransaction, XAResourceManager, XA Exposed, Part III: The Implementor's Notebook

Field Summary
static int FORMAT_ID
          int-encoded "Btnx" string.
 
Fields inherited from interface javax.transaction.xa.Xid
MAXBQUALSIZE, MAXGTRIDSIZE
 
Constructor Summary
BitronixXid(Uid globalTransactionId, Uid branchQualifier)
          Create a new XID using the specified GTRID and BQUAL.
BitronixXid(Xid xid)
           
 
Method Summary
 boolean equals(Object obj)
          Compare two XIDs for equality.
 byte[] getBranchQualifier()
          Get the BQUAL of the XID.
 Uid getBranchQualifierUid()
           
 int getFormatId()
          Get Bitronix XID format ID.
 byte[] getGlobalTransactionId()
          Get the GTRID of the XID.
 Uid getGlobalTransactionIdUid()
           
 int hashCode()
          Get an integer hash for the XID.
 String toString()
          Get a human-readable string representation of the XID.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FORMAT_ID

public static final int FORMAT_ID
int-encoded "Btnx" string. This is used as the globally unique ID to discriminate BTM XIDs.

See Also:
Constant Field Values
Constructor Detail

BitronixXid

public BitronixXid(Uid globalTransactionId,
                   Uid branchQualifier)
Create a new XID using the specified GTRID and BQUAL.

Parameters:
globalTransactionId - the GTRID.
branchQualifier - the BQUAL.

BitronixXid

public BitronixXid(Xid xid)
Method Detail

getFormatId

public int getFormatId()
Get Bitronix XID format ID. Defined by FORMAT_ID.

Specified by:
getFormatId in interface Xid
Returns:
the Bitronix XID format ID.

getBranchQualifier

public byte[] getBranchQualifier()
Get the BQUAL of the XID.

Specified by:
getBranchQualifier in interface Xid
Returns:
the XID branch qualifier.

getBranchQualifierUid

public Uid getBranchQualifierUid()

getGlobalTransactionId

public byte[] getGlobalTransactionId()
Get the GTRID of the XID.

Specified by:
getGlobalTransactionId in interface Xid
Returns:
the XID global transaction ID.

getGlobalTransactionIdUid

public Uid getGlobalTransactionIdUid()

toString

public String toString()
Get a human-readable string representation of the XID.

Overrides:
toString in class Object
Returns:
a human-readable string representation.

equals

public boolean equals(Object obj)
Compare two XIDs for equality.

Overrides:
equals in class Object
Parameters:
obj - the XID to compare to.
Returns:
true if both XIDs have the same format ID and contain exactly the same GTRID and BQUAL.

hashCode

public int hashCode()
Get an integer hash for the XID.

Overrides:
hashCode in class Object
Returns:
a constant hash value.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/0000755000175000017500000000000012215446622017434 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/ResourceRegistrar.html0000644000175000017500000005162512215446622024005 0ustar tonytony ResourceRegistrar (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource
Class ResourceRegistrar

java.lang.Object
  extended by bitronix.tm.resource.ResourceRegistrar

public class ResourceRegistrar
extends Object

Collection of initialized XAResourceProducers. All resources must be registered in the ResourceRegistrar before they can be used by the transaction manager.

Author:
lorban

Constructor Summary
ResourceRegistrar()
           
 
Method Summary
static XAResourceHolder findXAResourceHolder(XAResource xaResource)
          Find in the registered XAResourceProducers the XAResourceHolder from which the specified XAResource comes from.
static XAResourceProducer get(String uniqueName)
          Get a registered XAResourceProducer.
static Set<String> getResourcesUniqueNames()
          Get all XAResourceProducers unique names.
static void register(XAResourceProducer producer)
          Register a XAResourceProducer.
static void unregister(XAResourceProducer producer)
          Unregister a previously registered XAResourceProducer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceRegistrar

public ResourceRegistrar()
Method Detail

get

public static XAResourceProducer get(String uniqueName)
Get a registered XAResourceProducer.

Parameters:
uniqueName - the name of the recoverable resource producer.
Returns:
the XAResourceProducer or null if there was none registered under that name.

getResourcesUniqueNames

public static Set<String> getResourcesUniqueNames()
Get all XAResourceProducers unique names.

Returns:
a Set containing all XAResourceProducers unique names.

register

public static void register(XAResourceProducer producer)
                     throws RecoveryException
Register a XAResourceProducer. If registration happens after the transaction manager started, incremental recovery is run on that resource.

Parameters:
producer - the XAResourceProducer.
Throws:
RecoveryException - when an error happens during recovery.

unregister

public static void unregister(XAResourceProducer producer)
Unregister a previously registered XAResourceProducer.

Parameters:
producer - the XAResourceProducer.

findXAResourceHolder

public static XAResourceHolder findXAResourceHolder(XAResource xaResource)
Find in the registered XAResourceProducers the XAResourceHolder from which the specified XAResource comes from.

Parameters:
xaResource - the XAResource to look for
Returns:
the associated XAResourceHolder or null if it cannot be found.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/package-frame.html0000644000175000017500000000303112215446622023002 0ustar tonytony bitronix.tm.resource (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.resource
Classes 
ResourceLoader
ResourceObjectFactory
ResourceRegistrar
Exceptions 
ResourceConfigurationException
btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/0000755000175000017500000000000012215446622021014 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/package-frame.html0000644000175000017500000000224412215446622024367 0ustar tonytony bitronix.tm.resource.ehcache (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.resource.ehcache
Classes 
EhCacheXAResourceHolder
EhCacheXAResourceProducer
btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/EhCacheXAResourceHolder.html0000644000175000017500000006611012215446620026263 0ustar tonytony EhCacheXAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.ehcache
Class EhCacheXAResourceHolder

java.lang.Object
  extended by bitronix.tm.resource.common.AbstractXAStatefulHolder
      extended by bitronix.tm.resource.common.AbstractXAResourceHolder
          extended by bitronix.tm.resource.ehcache.EhCacheXAResourceHolder
All Implemented Interfaces:
XAResourceHolder, XAStatefulHolder

public class EhCacheXAResourceHolder
extends AbstractXAResourceHolder

Ehcache implementation of BTM's XAResourceHolder.

Copyright 2003-2010 Terracotta, Inc.

Author:
lorban

Field Summary
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Constructor Summary
EhCacheXAResourceHolder(XAResource resource, ResourceBean bean)
          Create a new EhCacheXAResourceHolder for a particular XAResource
 
Method Summary
 void close()
          Close the physical connection that this XAStatefulHolder represents.
 Object getConnectionHandle()
          Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
 Date getLastReleaseDate()
          Get the date at which this object was last released to the pool.
 ResourceBean getResourceBean()
          Get the ResourceBean which created this XAResourceHolder.
 XAResource getXAResource()
          Get the vendor's XAResource implementation of the wrapped resource.
 List<XAResourceHolder> getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAResourceHolder
getXAResourceHolderStateGtrids, getXAResourceHolderStatesForGtrid, hasStateForXAResource, isParticipatingInActiveGlobalTransaction, putXAResourceHolderState, removeXAResourceHolderState
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 

Constructor Detail

EhCacheXAResourceHolder

public EhCacheXAResourceHolder(XAResource resource,
                               ResourceBean bean)
Create a new EhCacheXAResourceHolder for a particular XAResource

Parameters:
resource - the required XAResource
bean - the required ResourceBean
Method Detail

getXAResource

public XAResource getXAResource()
Get the vendor's XAResource implementation of the wrapped resource.

Returns:
the vendor's XAResource implementation.

getResourceBean

public ResourceBean getResourceBean()
Get the ResourceBean which created this XAResourceHolder.

Returns:
the ResourceBean which created this XAResourceHolder.

close

public void close()
           throws Exception
Close the physical connection that this XAStatefulHolder represents.

Throws:
Exception - a resource-specific exception thrown when there is an error closing the physical connection.

getConnectionHandle

public Object getConnectionHandle()
                           throws Exception
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.

This method is thread-safe.

Returns:
a resource-specific disaposable connection object.
Throws:
Exception - a resource-specific exception thrown when the disaposable connection cannot be created.

getLastReleaseDate

public Date getLastReleaseDate()
Get the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.

Returns:
the date at which this object was last released to the pool or null if it never left the pool.

getXAResourceHolders

public List<XAResourceHolder> getXAResourceHolders()
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.

This method is thread-safe.

Returns:
the list of XAResourceHolders created by this XAStatefulHolder that are still open.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/EhCacheXAResourceProducer.html0000644000175000017500000011164612215446620026636 0ustar tonytony EhCacheXAResourceProducer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.ehcache
Class EhCacheXAResourceProducer

java.lang.Object
  extended by bitronix.tm.resource.common.ResourceBean
      extended by bitronix.tm.resource.ehcache.EhCacheXAResourceProducer
All Implemented Interfaces:
XAResourceProducer, Serializable, Referenceable

public final class EhCacheXAResourceProducer
extends ResourceBean
implements XAResourceProducer

EHCache implementation of BTM's XAResourceProducer.

Copyright 2003-2010 Terracotta, Inc.

Author:
lorban
See Also:
Serialized Form

Method Summary
 void close()
          Release this XAResourceProducer's internal resources.
 XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 void endRecovery()
          Release internal resources held after call to startRecovery().
 XAResourceHolder findXAResourceHolder(XAResource xaResource)
          Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
 Reference getReference()
          
 void init()
          Initialize this XAResourceProducer's internal resources.
static void registerXAResource(String uniqueName, XAResource xaResource)
          Register an XAResource of a cache with BTM.
 void setFailed(boolean failed)
          Mark this resource producer as failed or not.
 XAResourceHolderState startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 String toString()
           
static void unregisterXAResource(String uniqueName, XAResource xaResource)
          Unregister an XAResource of a cache from BTM.
 
Methods inherited from class bitronix.tm.resource.common.ResourceBean
getAcquireIncrement, getAcquisitionInterval, getAcquisitionTimeout, getAllowLocalTransactions, getApplyTransactionTimeout, getAutomaticEnlistingEnabled, getClassName, getDeferConnectionRelease, getDriverProperties, getIgnoreRecoveryFailures, getMaxIdleTime, getMaxPoolSize, getMinPoolSize, getShareTransactionConnections, getTwoPcOrderingPosition, getUniqueName, getUseTmJoin, incCreatedResourcesCounter, isDisabled, setAcquireIncrement, setAcquisitionInterval, setAcquisitionTimeout, setAllowLocalTransactions, setApplyTransactionTimeout, setAutomaticEnlistingEnabled, setClassName, setDeferConnectionRelease, setDisabled, setDriverProperties, setIgnoreRecoveryFailures, setMaxIdleTime, setMaxPoolSize, setMinPoolSize, setShareTransactionConnections, setTwoPcOrderingPosition, setUniqueName, setUseTmJoin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAResourceProducer
getUniqueName
 

Method Detail

registerXAResource

public static void registerXAResource(String uniqueName,
                                      XAResource xaResource)
Register an XAResource of a cache with BTM. The first time a XAResource is registered a new EhCacheXAResourceProducer is created to hold it.

Parameters:
uniqueName - the uniqueName of this XAResourceProducer, usually the cache's name
xaResource - the XAResource to be registered

unregisterXAResource

public static void unregisterXAResource(String uniqueName,
                                        XAResource xaResource)
Unregister an XAResource of a cache from BTM.

Parameters:
uniqueName - the uniqueName of this XAResourceProducer, usually the cache's name
xaResource - the XAResource to be registered

startRecovery

public XAResourceHolderState startRecovery()
                                    throws RecoveryException
Prepare the recoverable XAResource producer for recovery.

Specified by:
startRecovery in interface XAResourceProducer
Returns:
a XAResourceHolderState object that can be used to call recover().
Throws:
RecoveryException - thrown when a XAResourceHolderState cannot be acquired.

endRecovery

public void endRecovery()
                 throws RecoveryException
Release internal resources held after call to startRecovery().

Specified by:
endRecovery in interface XAResourceProducer
Throws:
RecoveryException - thrown when an error occured while releasing reserved resources.

setFailed

public void setFailed(boolean failed)
Mark this resource producer as failed or not. A resource is considered failed if recovery fails to run on it.

Specified by:
setFailed in interface XAResourceProducer
Parameters:
failed - true is the resource must be considered failed, false it it must be considered sane.

findXAResourceHolder

public XAResourceHolder findXAResourceHolder(XAResource xaResource)
Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.

Specified by:
findXAResourceHolder in interface XAResourceProducer
Parameters:
xaResource - the XAResource to look for.
Returns:
the associated XAResourceHolder or null if the XAResource does not belong to this XAResourceProducer.

init

public void init()
Initialize this XAResourceProducer's internal resources.

Specified by:
init in interface XAResourceProducer

close

public void close()
Release this XAResourceProducer's internal resources.

Specified by:
close in interface XAResourceProducer

createPooledConnection

public XAStatefulHolder createPooledConnection(Object xaFactory,
                                               ResourceBean bean)
                                        throws Exception
Create a XAStatefulHolder that will be placed in an XAPool.

Specified by:
createPooledConnection in interface XAResourceProducer
Parameters:
xaFactory - the vendor's resource-specific XA factory.
bean - the resource-specific bean describing the resource parameters.
Returns:
a XAStatefulHolder that will be placed in an XAPool.
Throws:
Exception - thrown when the XAStatefulHolder cannot be created.

getReference

public Reference getReference()
                       throws NamingException

Specified by:
getReference in interface Referenceable
Throws:
NamingException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/package-tree.html0000644000175000017500000001765412215446622024247 0ustar tonytony bitronix.tm.resource.ehcache Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.resource.ehcache

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/package-use.html0000644000175000017500000001327012215446622024072 0ustar tonytony Uses of Package bitronix.tm.resource.ehcache (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.resource.ehcache

No usage of bitronix.tm.resource.ehcache



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/class-use/0000755000175000017500000000000012215446622022713 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/class-use/EhCacheXAResourceHolder.html0000644000175000017500000001424712215446622030170 0ustar tonytony Uses of Class bitronix.tm.resource.ehcache.EhCacheXAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.ehcache.EhCacheXAResourceHolder

No usage of bitronix.tm.resource.ehcache.EhCacheXAResourceHolder



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/class-use/EhCacheXAResourceProducer.html0000644000175000017500000001427312215446622030535 0ustar tonytony Uses of Class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.ehcache.EhCacheXAResourceProducer

No usage of bitronix.tm.resource.ehcache.EhCacheXAResourceProducer



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ehcache/package-summary.html0000644000175000017500000001614212215446622024774 0ustar tonytony bitronix.tm.resource.ehcache (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.resource.ehcache

Ehcache specific resource management code.

See:
          Description

Class Summary
EhCacheXAResourceHolder Ehcache implementation of BTM's XAResourceHolder.
EhCacheXAResourceProducer EHCache implementation of BTM's XAResourceProducer.
 

Package bitronix.tm.resource.ehcache Description

Ehcache specific resource management code.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/package-tree.html0000644000175000017500000001752012215446622022657 0ustar tonytony bitronix.tm.resource Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.resource

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ResourceObjectFactory.html0000644000175000017500000003645012215446622024600 0ustar tonytony ResourceObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource
Class ResourceObjectFactory

java.lang.Object
  extended by bitronix.tm.resource.ResourceObjectFactory
All Implemented Interfaces:
ObjectFactory

public class ResourceObjectFactory
extends Object
implements ObjectFactory

XAResourceProducer object factory for JNDI references.

Author:
lorban
See Also:
ResourceBean

Constructor Summary
ResourceObjectFactory()
           
 
Method Summary
 Object getObjectInstance(Object obj, Name jndiNameObject, Context nameCtx, Hashtable<?,?> environment)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceObjectFactory

public ResourceObjectFactory()
Method Detail

getObjectInstance

public Object getObjectInstance(Object obj,
                                Name jndiNameObject,
                                Context nameCtx,
                                Hashtable<?,?> environment)
                         throws Exception
Specified by:
getObjectInstance in interface ObjectFactory
Throws:
Exception


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/0000755000175000017500000000000012215446622020724 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/common/package-frame.html0000644000175000017500000000477712215446622024314 0ustar tonytony bitronix.tm.resource.common (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.resource.common
Interfaces 
StateChangeListener
XAResourceHolder
XAResourceProducer
XAStatefulHolder
Classes 
AbstractXAResourceHolder
AbstractXAStatefulHolder
DeferredReleaseSynchronization
RecoveryXAResourceHolder
ResourceBean
TransactionContextHelper
XAPool
btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/ResourceBean.html0000644000175000017500000013160412215446620024172 0ustar tonytony ResourceBean (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Class ResourceBean

java.lang.Object
  extended by bitronix.tm.resource.common.ResourceBean
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EhCacheXAResourceProducer, PoolingConnectionFactory, PoolingDataSource

public abstract class ResourceBean
extends Object
implements Serializable

Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
protected ResourceBean()
          Initialize all properties with their default values.
 
Method Summary
 int getAcquireIncrement()
           
 int getAcquisitionInterval()
           
 int getAcquisitionTimeout()
           
 boolean getAllowLocalTransactions()
           
 boolean getApplyTransactionTimeout()
           
 boolean getAutomaticEnlistingEnabled()
           
 String getClassName()
           
 boolean getDeferConnectionRelease()
           
 Properties getDriverProperties()
           
 boolean getIgnoreRecoveryFailures()
           
 int getMaxIdleTime()
           
 int getMaxPoolSize()
           
 int getMinPoolSize()
           
 boolean getShareTransactionConnections()
           
 int getTwoPcOrderingPosition()
           
 String getUniqueName()
           
 boolean getUseTmJoin()
           
 int incCreatedResourcesCounter()
          Increment a transient counter.
 boolean isDisabled()
           
 void setAcquireIncrement(int acquireIncrement)
          Define the amount of connections to be created at once when the pool needs to grow.
 void setAcquisitionInterval(int acquisitionInterval)
          Set the amount of time in seconds the pool will wait before trying to acquire a connection again after an invalid connection has been attempted to be acquired.
 void setAcquisitionTimeout(int acquisitionTimeout)
          Define the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty.
 void setAllowLocalTransactions(boolean allowLocalTransactions)
          Set if the transaction manager should allow mixing XA and non-XA transactions.
 void setApplyTransactionTimeout(boolean applyTransactionTimeout)
          Set if the transaction-timeout should be set on the XAResource when the XAResource is enlisted.
 void setAutomaticEnlistingEnabled(boolean automaticEnlistingEnabled)
          Specify if the XA resource wrapper should enlist/delist this resource automatically in global transactions.
 void setClassName(String className)
          Specify the underlying implementation class name of the XA resource described by this bean.
 void setDeferConnectionRelease(boolean deferConnectionRelease)
          Define the transaction interleaving capability of the database.
 void setDisabled(boolean disabled)
          Set whether this resource is disabled, meaning it's temporarily forbidden to acquire a connection from its pool.
 void setDriverProperties(Properties driverProperties)
          Set the properties that should be set on the underlying implementation.
 void setIgnoreRecoveryFailures(boolean ignoreRecoveryFailures)
          Set whether XA recovery errors should quarantine the resource or be ignored.
 void setMaxIdleTime(int maxIdleTime)
          Define the amount of seconds and idle connection can stay in the pool before getting closed.
 void setMaxPoolSize(int maxPoolSize)
          Define the maximum amount of connections that can be in the pool.
 void setMinPoolSize(int minPoolSize)
          Define the minimal amount of connections that can be in the pool.
 void setShareTransactionConnections(boolean shareAccessibleConnections)
          Set whether connections in the ACCESSIBLE state can be shared within the context of a transaction.
 void setTwoPcOrderingPosition(int twoPcOrderingPosition)
          Set the position at which this resource should stand during 2PC commit.
 void setUniqueName(String uniqueName)
          Specify the resource unique name to be used to identify this resource during recovery.
 void setUseTmJoin(boolean useTmJoin)
          Specify if the transaction manager should try to join resources by calling XAResource.start(javax.transaction.xa.Xid, int) with XAResource.TMJOIN.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBean

protected ResourceBean()
Initialize all properties with their default values.

Method Detail

getClassName

public String getClassName()
Returns:
the underlying implementation class name.

setClassName

public void setClassName(String className)
Specify the underlying implementation class name of the XA resource described by this bean.

Parameters:
className - the underlying implementation class name.

getUniqueName

public String getUniqueName()
Returns:
the resource's unique name.

setUniqueName

public void setUniqueName(String uniqueName)
Specify the resource unique name to be used to identify this resource during recovery. This name will be registered in the transactions journal so once assigned it must never be changed.

Parameters:
uniqueName - the resource's unique name.

getAutomaticEnlistingEnabled

public boolean getAutomaticEnlistingEnabled()
Returns:
true if the the XA resource wrapper should enlist/delist this resource automatically in global transactions.

setAutomaticEnlistingEnabled

public void setAutomaticEnlistingEnabled(boolean automaticEnlistingEnabled)
Specify if the XA resource wrapper should enlist/delist this resource automatically in global transactions. When set to false, you have to enlist resources yourself with Transaction.enlistResource(javax.transaction.xa.XAResource) and delist them Transaction.delistResource(javax.transaction.xa.XAResource, int).

Parameters:
automaticEnlistingEnabled - true if the the XA resource wrapper should enlist/delist this resource automatically in global transactions.

getUseTmJoin

public boolean getUseTmJoin()
Returns:
true if transaction branches joining should be used.

setUseTmJoin

public void setUseTmJoin(boolean useTmJoin)
Specify if the transaction manager should try to join resources by calling XAResource.start(javax.transaction.xa.Xid, int) with XAResource.TMJOIN. The transaction manager checks if two branches can be joined by calling XAResource.isSameRM(javax.transaction.xa.XAResource). It should only be set to true if the underlying implementation supports resource joining.

Parameters:
useTmJoin - true if transaction branches joining should be used.

getDriverProperties

public Properties getDriverProperties()
Returns:
the properties that should be set on the underlying implementation.

setDriverProperties

public void setDriverProperties(Properties driverProperties)
Set the properties that should be set on the underlying implementation.

Parameters:
driverProperties - the properties that should be set on the underlying implementation.

getMaxPoolSize

public int getMaxPoolSize()
Returns:
the maximum amount of connections that can be in the pool.

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)
Define the maximum amount of connections that can be in the pool.

Parameters:
maxPoolSize - the maximum amount of connections that can be in the pool.

getMinPoolSize

public int getMinPoolSize()
Returns:
the minimal amount of connections that can be in the pool.

setMinPoolSize

public void setMinPoolSize(int minPoolSize)
Define the minimal amount of connections that can be in the pool.

Parameters:
minPoolSize - the maximum amount of connections that can be in the pool.

getMaxIdleTime

public int getMaxIdleTime()
Returns:
the amount of seconds and idle connection can stay in the pool before getting closed.

setMaxIdleTime

public void setMaxIdleTime(int maxIdleTime)
Define the amount of seconds and idle connection can stay in the pool before getting closed.

Parameters:
maxIdleTime - the amount of seconds and idle connection can stay in the pool before getting closed.

getAcquireIncrement

public int getAcquireIncrement()
Returns:
the amount of connections to be created at once when the pool needs to grow.

setAcquireIncrement

public void setAcquireIncrement(int acquireIncrement)
Define the amount of connections to be created at once when the pool needs to grow.

Parameters:
acquireIncrement - the amount of connections to be created at once when the pool needs to grow.

getAcquisitionTimeout

public int getAcquisitionTimeout()
Returns:
the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty.

setAcquisitionTimeout

public void setAcquisitionTimeout(int acquisitionTimeout)
Define the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty.

Parameters:
acquisitionTimeout - the amount of time in seconds.

getDeferConnectionRelease

public boolean getDeferConnectionRelease()
Returns:
false only if the database can run many transactions on the same connection.

setDeferConnectionRelease

public void setDeferConnectionRelease(boolean deferConnectionRelease)
Define the transaction interleaving capability of the database. Should be true only if the database can run many transactions on the same connection.

Parameters:
deferConnectionRelease - false only if the database can run many transactions on the same connection.

getAcquisitionInterval

public int getAcquisitionInterval()
Returns:
the amount of time between failed connection acquirements.

setAcquisitionInterval

public void setAcquisitionInterval(int acquisitionInterval)
Set the amount of time in seconds the pool will wait before trying to acquire a connection again after an invalid connection has been attempted to be acquired.

Parameters:
acquisitionInterval - amount of time in seconds.

getAllowLocalTransactions

public boolean getAllowLocalTransactions()
Returns:
true if the transaction manager should allow mixing XA and non-XA transactions.

setAllowLocalTransactions

public void setAllowLocalTransactions(boolean allowLocalTransactions)
Set if the transaction manager should allow mixing XA and non-XA transactions. If you know all your transactions should be executed within global (ie: XA) scope it is a good idea to set this property to false.

Parameters:
allowLocalTransactions - if the transaction manager should allow mixing XA and non-XA transactions.

getTwoPcOrderingPosition

public int getTwoPcOrderingPosition()
Returns:
the position at which this resource should stand during 2PC commit.

setTwoPcOrderingPosition

public void setTwoPcOrderingPosition(int twoPcOrderingPosition)
Set the position at which this resource should stand during 2PC commit.

Parameters:
twoPcOrderingPosition - the position at which this resource should stand during 2PC commit.

getApplyTransactionTimeout

public boolean getApplyTransactionTimeout()
Returns:
true if the transaction-timeout should be set on the XAResource.

setApplyTransactionTimeout

public void setApplyTransactionTimeout(boolean applyTransactionTimeout)
Set if the transaction-timeout should be set on the XAResource when the XAResource is enlisted.

Parameters:
applyTransactionTimeout - true if the transaction-timeout should be set.

setShareTransactionConnections

public void setShareTransactionConnections(boolean shareAccessibleConnections)
Set whether connections in the ACCESSIBLE state can be shared within the context of a transaction.

Parameters:
shareAccessibleConnections - the shareAccessibleConnections to set.

getShareTransactionConnections

public boolean getShareTransactionConnections()
Returns:
true if accessible connections can be shared.

setIgnoreRecoveryFailures

public void setIgnoreRecoveryFailures(boolean ignoreRecoveryFailures)
Set whether XA recovery errors should quarantine the resource or be ignored.

Parameters:
ignoreRecoveryFailures - true if recovery errors should be ignored, false otherwise.

getIgnoreRecoveryFailures

public boolean getIgnoreRecoveryFailures()
Returns:
true if recovery errors should be ignored, false otherwise.

setDisabled

public void setDisabled(boolean disabled)
Set whether this resource is disabled, meaning it's temporarily forbidden to acquire a connection from its pool.

Parameters:
disabled - true to disable the resource, false to enable it.

isDisabled

public boolean isDisabled()
Returns:
true if the resource is disabled, false if it is enabled.

incCreatedResourcesCounter

public int incCreatedResourcesCounter()
Increment a transient counter. This is used for assigning per-resource numbers to connections.

Returns:
the current value of the counter.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/StateChangeListener.html0000644000175000017500000003101212215446620025501 0ustar tonytony StateChangeListener (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Interface StateChangeListener

All Known Implementing Classes:
DualSessionWrapper, JdbcPooledConnection, XAPool

public interface StateChangeListener

XAStatefulHolder state change listener interface.

Author:
lorban

Method Summary
 void stateChanged(XAStatefulHolder source, int oldState, int newState)
          Fired when the internal state of a XAStatefulHolder has changed.
 void stateChanging(XAStatefulHolder source, int currentState, int futureState)
          Fired before the internal state of a XAStatefulHolder has changed.
 

Method Detail

stateChanged

void stateChanged(XAStatefulHolder source,
                  int oldState,
                  int newState)
Fired when the internal state of a XAStatefulHolder has changed.

Parameters:
source - the XAStatefulHolder changing state.
oldState - the old state of the XAStatefulHolder.
newState - the new state of the XAStatefulHolder.

stateChanging

void stateChanging(XAStatefulHolder source,
                   int currentState,
                   int futureState)
Fired before the internal state of a XAStatefulHolder has changed.

Parameters:
source - the XAStatefulHolder changing state.
currentState - the current state of the XAStatefulHolder.
futureState - the future state of the XAStatefulHolder.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/AbstractXAResourceHolder.html0000644000175000017500000007552112215446620026464 0ustar tonytony AbstractXAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Class AbstractXAResourceHolder

java.lang.Object
  extended by bitronix.tm.resource.common.AbstractXAStatefulHolder
      extended by bitronix.tm.resource.common.AbstractXAResourceHolder
All Implemented Interfaces:
XAResourceHolder, XAStatefulHolder
Direct Known Subclasses:
DualSessionWrapper, EhCacheXAResourceHolder, JdbcPooledConnection, RecoveryXAResourceHolder

public abstract class AbstractXAResourceHolder
extends AbstractXAStatefulHolder
implements XAResourceHolder

Implementation of all services required by a XAResourceHolder. This class keeps a list of all XAResourceHolderStates of the XAResourceHolder plus the currently active one. There is one per transaction in which this XAResourceHolder is enlisted plus all the suspended transactions in which it is enlisted as well.

Author:
lorban

Field Summary
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Constructor Summary
AbstractXAResourceHolder()
           
 
Method Summary
 Set<String> getXAResourceHolderStateGtrids()
          Simple helper method which returns a set of GTRIDs of transactions in which this resource is enlisted.
 Map<Uid,XAResourceHolderState> getXAResourceHolderStatesForGtrid(Uid gtrid)
          Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.
 boolean hasStateForXAResource(XAResourceHolder xaResourceHolder)
          Check if this XAResourceHolder contains a state for a specific XAResourceHolder.
 boolean isParticipatingInActiveGlobalTransaction()
          If this method returns false, then local transaction calls like Connection.commit() can be made.
 void putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState)
          Add a XAResourceHolderState of this wrapped resource.
 void removeXAResourceHolderState(BitronixXid xid)
          Remove all states related to a specific Xid from this wrapped resource.
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAResourceHolder
getResourceBean, getXAResource
 
Methods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
addStateChangeEventListener, close, getConnectionHandle, getLastReleaseDate, getState, getXAResourceHolders, removeStateChangeEventListener, setState
 

Constructor Detail

AbstractXAResourceHolder

public AbstractXAResourceHolder()
Method Detail

getXAResourceHolderStatesForGtrid

public Map<Uid,XAResourceHolderState> getXAResourceHolderStatesForGtrid(Uid gtrid)
Description copied from interface: XAResourceHolder
Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.

The returned Map is guaranteed to return states in order they were added when its values are iterated.

Specified by:
getXAResourceHolderStatesForGtrid in interface XAResourceHolder
Parameters:
gtrid - the GTRID of the transaction state to add.
Returns:
the XAResourceHolderState.

putXAResourceHolderState

public void putXAResourceHolderState(BitronixXid xid,
                                     XAResourceHolderState xaResourceHolderState)
Description copied from interface: XAResourceHolder
Add a XAResourceHolderState of this wrapped resource.

Specified by:
putXAResourceHolderState in interface XAResourceHolder
Parameters:
xid - the Xid of the transaction state to add.
xaResourceHolderState - the XAResourceHolderState to set.

removeXAResourceHolderState

public void removeXAResourceHolderState(BitronixXid xid)
Description copied from interface: XAResourceHolder
Remove all states related to a specific Xid from this wrapped resource.

Specified by:
removeXAResourceHolderState in interface XAResourceHolder
Parameters:
xid - the Xid of the transaction state to remove.

hasStateForXAResource

public boolean hasStateForXAResource(XAResourceHolder xaResourceHolder)
Description copied from interface: XAResourceHolder
Check if this XAResourceHolder contains a state for a specific XAResourceHolder. In other words: has the XAResourceHolder's XAResource been enlisted in some transaction ?

Specified by:
hasStateForXAResource in interface XAResourceHolder
Parameters:
xaResourceHolder - the XAResourceHolder to look for.
Returns:
true if the XAResourceHolder is enlisted in some transaction, false otherwise.

isParticipatingInActiveGlobalTransaction

public boolean isParticipatingInActiveGlobalTransaction()
If this method returns false, then local transaction calls like Connection.commit() can be made.

Returns:
true if start() has been successfully called but not end() yet and the transaction is not suspended.

getXAResourceHolderStateGtrids

public Set<String> getXAResourceHolderStateGtrids()
Simple helper method which returns a set of GTRIDs of transactions in which this resource is enlisted. Useful for monitoring.

Returns:
a set of String-encoded GTRIDs of transactions in which this resource is enlisted.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/package-tree.html0000644000175000017500000002434712215446622024154 0ustar tonytony bitronix.tm.resource.common Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.resource.common

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/package-use.html0000644000175000017500000007117612215446622024013 0ustar tonytony Uses of Package bitronix.tm.resource.common (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.resource.common

Packages that use bitronix.tm.resource.common
bitronix.tm.internal Internal implementation details. 
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource Transaction Manager's resource management services. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
bitronix.tm.timer Timed tasks scheduler. 
 

Classes in bitronix.tm.resource.common used by bitronix.tm.internal
ResourceBean
          Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.
XAResourceHolder
          XAResource wrappers must implement this interface.
 

Classes in bitronix.tm.resource.common used by bitronix.tm.recovery
XAResourceProducer
          A XAResourceProducer is a XAStatefulHolder factory.
 

Classes in bitronix.tm.resource.common used by bitronix.tm.resource
XAResourceHolder
          XAResource wrappers must implement this interface.
XAResourceProducer
          A XAResourceProducer is a XAStatefulHolder factory.
 

Classes in bitronix.tm.resource.common used by bitronix.tm.resource.common
AbstractXAResourceHolder
          Implementation of all services required by a XAResourceHolder.
AbstractXAStatefulHolder
          Implementation of all services required by a XAStatefulHolder.
ResourceBean
          Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.
StateChangeListener
          XAStatefulHolder state change listener interface.
XAResourceHolder
          XAResource wrappers must implement this interface.
XAResourceProducer
          A XAResourceProducer is a XAStatefulHolder factory.
XAStatefulHolder
          Any pooled connection class must implement the XAStatefulHolder interface.
 

Classes in bitronix.tm.resource.common used by bitronix.tm.resource.ehcache
AbstractXAResourceHolder
          Implementation of all services required by a XAResourceHolder.
AbstractXAStatefulHolder
          Implementation of all services required by a XAStatefulHolder.
ResourceBean
          Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.
XAResourceHolder
          XAResource wrappers must implement this interface.
XAResourceProducer
          A XAResourceProducer is a XAStatefulHolder factory.
XAStatefulHolder
          Any pooled connection class must implement the XAStatefulHolder interface.
 

Classes in bitronix.tm.resource.common used by bitronix.tm.resource.jdbc
AbstractXAResourceHolder
          Implementation of all services required by a XAResourceHolder.
AbstractXAStatefulHolder
          Implementation of all services required by a XAStatefulHolder.
RecoveryXAResourceHolder
          XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
ResourceBean
          Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.
StateChangeListener
          XAStatefulHolder state change listener interface.
XAResourceHolder
          XAResource wrappers must implement this interface.
XAResourceProducer
          A XAResourceProducer is a XAStatefulHolder factory.
XAStatefulHolder
          Any pooled connection class must implement the XAStatefulHolder interface.
 

Classes in bitronix.tm.resource.common used by bitronix.tm.resource.jms
AbstractXAResourceHolder
          Implementation of all services required by a XAResourceHolder.
AbstractXAStatefulHolder
          Implementation of all services required by a XAStatefulHolder.
RecoveryXAResourceHolder
          XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
ResourceBean
          Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.
StateChangeListener
          XAStatefulHolder state change listener interface.
XAResourceHolder
          XAResource wrappers must implement this interface.
XAResourceProducer
          A XAResourceProducer is a XAStatefulHolder factory.
XAStatefulHolder
          Any pooled connection class must implement the XAStatefulHolder interface.
 

Classes in bitronix.tm.resource.common used by bitronix.tm.timer
XAPool
          Generic XA pool.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/DeferredReleaseSynchronization.html0000644000175000017500000004115712215446620027763 0ustar tonytony DeferredReleaseSynchronization (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Class DeferredReleaseSynchronization

java.lang.Object
  extended by bitronix.tm.resource.common.DeferredReleaseSynchronization
All Implemented Interfaces:
Synchronization

public class DeferredReleaseSynchronization
extends Object
implements Synchronization

Synchronization used to release a XAStatefulHolder object after 2PC has executed.

Author:
lorban

Constructor Summary
DeferredReleaseSynchronization(XAStatefulHolder xaStatefulHolder)
           
 
Method Summary
 void afterCompletion(int status)
           
 void beforeCompletion()
           
 XAStatefulHolder getXAStatefulHolder()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeferredReleaseSynchronization

public DeferredReleaseSynchronization(XAStatefulHolder xaStatefulHolder)
Method Detail

getXAStatefulHolder

public XAStatefulHolder getXAStatefulHolder()

afterCompletion

public void afterCompletion(int status)
Specified by:
afterCompletion in interface Synchronization

beforeCompletion

public void beforeCompletion()
Specified by:
beforeCompletion in interface Synchronization

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/0000755000175000017500000000000012215446622022623 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/ResourceBean.html0000644000175000017500000006734212215446622026102 0ustar tonytony Uses of Class bitronix.tm.resource.common.ResourceBean (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.common.ResourceBean

Packages that use ResourceBean
bitronix.tm.internal Internal implementation details. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of ResourceBean in bitronix.tm.internal
 

Constructors in bitronix.tm.internal with parameters of type ResourceBean
XAResourceHolderState(XAResourceHolder resourceHolder, ResourceBean bean)
           
 

Uses of ResourceBean in bitronix.tm.resource.common
 

Methods in bitronix.tm.resource.common that return ResourceBean
 ResourceBean XAResourceHolder.getResourceBean()
          Get the ResourceBean which created this XAResourceHolder.
 ResourceBean RecoveryXAResourceHolder.getResourceBean()
           
 

Methods in bitronix.tm.resource.common with parameters of type ResourceBean
 XAStatefulHolder XAResourceProducer.createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
static void TransactionContextHelper.requeue(XAStatefulHolder xaStatefulHolder, ResourceBean bean)
          Switch the XAStatefulHolder's state appropriately after the acquired resource handle has been closed.
 

Constructors in bitronix.tm.resource.common with parameters of type ResourceBean
XAPool(XAResourceProducer xaResourceProducer, ResourceBean bean)
           
 

Uses of ResourceBean in bitronix.tm.resource.ehcache
 

Subclasses of ResourceBean in bitronix.tm.resource.ehcache
 class EhCacheXAResourceProducer
          EHCache implementation of BTM's XAResourceProducer.
 

Methods in bitronix.tm.resource.ehcache that return ResourceBean
 ResourceBean EhCacheXAResourceHolder.getResourceBean()
          Get the ResourceBean which created this XAResourceHolder.
 

Methods in bitronix.tm.resource.ehcache with parameters of type ResourceBean
 XAStatefulHolder EhCacheXAResourceProducer.createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 

Constructors in bitronix.tm.resource.ehcache with parameters of type ResourceBean
EhCacheXAResourceHolder(XAResource resource, ResourceBean bean)
          Create a new EhCacheXAResourceHolder for a particular XAResource
 

Uses of ResourceBean in bitronix.tm.resource.jdbc
 

Subclasses of ResourceBean in bitronix.tm.resource.jdbc
 class PoolingDataSource
          Implementation of a JDBC DataSource wrapping vendor's XADataSource implementation.
 

Methods in bitronix.tm.resource.jdbc that return ResourceBean
 ResourceBean JdbcPooledConnection.getResourceBean()
           
 

Methods in bitronix.tm.resource.jdbc with parameters of type ResourceBean
 XAStatefulHolder PoolingDataSource.createPooledConnection(Object xaFactory, ResourceBean bean)
           
 

Uses of ResourceBean in bitronix.tm.resource.jms
 

Subclasses of ResourceBean in bitronix.tm.resource.jms
 class PoolingConnectionFactory
          Implementation of a JMS ConnectionFactory wrapping vendor's XAConnectionFactory implementation.
 

Methods in bitronix.tm.resource.jms that return ResourceBean
 ResourceBean DualSessionWrapper.getResourceBean()
           
 

Methods in bitronix.tm.resource.jms with parameters of type ResourceBean
 XAStatefulHolder PoolingConnectionFactory.createPooledConnection(Object xaFactory, ResourceBean bean)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/StateChangeListener.html0000644000175000017500000003537612215446622027423 0ustar tonytony Uses of Interface bitronix.tm.resource.common.StateChangeListener (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.common.StateChangeListener

Packages that use StateChangeListener
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of StateChangeListener in bitronix.tm.resource.common
 

Classes in bitronix.tm.resource.common that implement StateChangeListener
 class XAPool
          Generic XA pool.
 

Methods in bitronix.tm.resource.common with parameters of type StateChangeListener
 void XAStatefulHolder.addStateChangeEventListener(StateChangeListener listener)
          Register an implementation of StateChangeListener.
 void AbstractXAStatefulHolder.addStateChangeEventListener(StateChangeListener listener)
           
 void XAStatefulHolder.removeStateChangeEventListener(StateChangeListener listener)
          Unregister an implementation of StateChangeListener.
 void AbstractXAStatefulHolder.removeStateChangeEventListener(StateChangeListener listener)
           
 

Uses of StateChangeListener in bitronix.tm.resource.jdbc
 

Classes in bitronix.tm.resource.jdbc that implement StateChangeListener
 class JdbcPooledConnection
          Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
 

Uses of StateChangeListener in bitronix.tm.resource.jms
 

Classes in bitronix.tm.resource.jms that implement StateChangeListener
 class DualSessionWrapper
          JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/AbstractXAResourceHolder.html0000644000175000017500000003275612215446622030370 0ustar tonytony Uses of Class bitronix.tm.resource.common.AbstractXAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.common.AbstractXAResourceHolder

Packages that use AbstractXAResourceHolder
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of AbstractXAResourceHolder in bitronix.tm.resource.common
 

Subclasses of AbstractXAResourceHolder in bitronix.tm.resource.common
 class RecoveryXAResourceHolder
          XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
 

Uses of AbstractXAResourceHolder in bitronix.tm.resource.ehcache
 

Subclasses of AbstractXAResourceHolder in bitronix.tm.resource.ehcache
 class EhCacheXAResourceHolder
          Ehcache implementation of BTM's XAResourceHolder.
 

Uses of AbstractXAResourceHolder in bitronix.tm.resource.jdbc
 

Subclasses of AbstractXAResourceHolder in bitronix.tm.resource.jdbc
 class JdbcPooledConnection
          Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
 

Uses of AbstractXAResourceHolder in bitronix.tm.resource.jms
 

Subclasses of AbstractXAResourceHolder in bitronix.tm.resource.jms
 class DualSessionWrapper
          JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/DeferredReleaseSynchronization.html0000644000175000017500000001434312215446622031661 0ustar tonytony Uses of Class bitronix.tm.resource.common.DeferredReleaseSynchronization (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.common.DeferredReleaseSynchronization

No usage of bitronix.tm.resource.common.DeferredReleaseSynchronization



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/RecoveryXAResourceHolder.html0000644000175000017500000002367712215446622030425 0ustar tonytony Uses of Class bitronix.tm.resource.common.RecoveryXAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.common.RecoveryXAResourceHolder

Packages that use RecoveryXAResourceHolder
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of RecoveryXAResourceHolder in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc that return RecoveryXAResourceHolder
 RecoveryXAResourceHolder JdbcPooledConnection.createRecoveryXAResourceHolder()
           
 

Uses of RecoveryXAResourceHolder in bitronix.tm.resource.jms
 

Methods in bitronix.tm.resource.jms that return RecoveryXAResourceHolder
 RecoveryXAResourceHolder JmsPooledConnection.createRecoveryXAResourceHolder()
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/XAPool.html0000644000175000017500000002333512215446622024661 0ustar tonytony Uses of Class bitronix.tm.resource.common.XAPool (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.common.XAPool

Packages that use XAPool
bitronix.tm.timer Timed tasks scheduler. 
 

Uses of XAPool in bitronix.tm.timer
 

Methods in bitronix.tm.timer with parameters of type XAPool
 void TaskScheduler.cancelPoolShrinking(XAPool xaPool)
          Cancel the task that will tell a XA pool to close idle connections.
 void TaskScheduler.schedulePoolShrinking(XAPool xaPool)
          Schedule a task that will tell a XA pool to close idle connections.
 

Constructors in bitronix.tm.timer with parameters of type XAPool
PoolShrinkingTask(XAPool xaPool, Date executionTime, TaskScheduler scheduler)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/XAResourceProducer.html0000644000175000017500000005111512215446622027240 0ustar tonytony Uses of Interface bitronix.tm.resource.common.XAResourceProducer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.common.XAResourceProducer

Packages that use XAResourceProducer
bitronix.tm.recovery Recovery logic. 
bitronix.tm.resource Transaction Manager's resource management services. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of XAResourceProducer in bitronix.tm.recovery
 

Methods in bitronix.tm.recovery with parameters of type XAResourceProducer
static void IncrementalRecoverer.recover(XAResourceProducer xaResourceProducer)
          Run incremental recovery on the specified resource.
 

Uses of XAResourceProducer in bitronix.tm.resource
 

Methods in bitronix.tm.resource that return XAResourceProducer
static XAResourceProducer ResourceRegistrar.get(String uniqueName)
          Get a registered XAResourceProducer.
 

Methods in bitronix.tm.resource that return types with arguments of type XAResourceProducer
 Map<String,XAResourceProducer> ResourceLoader.getResources()
          Get a Map with the configured uniqueName as key and XAResourceProducer as value.
 

Methods in bitronix.tm.resource with parameters of type XAResourceProducer
static void ResourceRegistrar.register(XAResourceProducer producer)
          Register a XAResourceProducer.
static void ResourceRegistrar.unregister(XAResourceProducer producer)
          Unregister a previously registered XAResourceProducer.
 

Uses of XAResourceProducer in bitronix.tm.resource.common
 

Constructors in bitronix.tm.resource.common with parameters of type XAResourceProducer
XAPool(XAResourceProducer xaResourceProducer, ResourceBean bean)
           
 

Uses of XAResourceProducer in bitronix.tm.resource.ehcache
 

Classes in bitronix.tm.resource.ehcache that implement XAResourceProducer
 class EhCacheXAResourceProducer
          EHCache implementation of BTM's XAResourceProducer.
 

Uses of XAResourceProducer in bitronix.tm.resource.jdbc
 

Classes in bitronix.tm.resource.jdbc that implement XAResourceProducer
 class PoolingDataSource
          Implementation of a JDBC DataSource wrapping vendor's XADataSource implementation.
 

Uses of XAResourceProducer in bitronix.tm.resource.jms
 

Classes in bitronix.tm.resource.jms that implement XAResourceProducer
 class PoolingConnectionFactory
          Implementation of a JMS ConnectionFactory wrapping vendor's XAConnectionFactory implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/TransactionContextHelper.html0000644000175000017500000001424712215446622030513 0ustar tonytony Uses of Class bitronix.tm.resource.common.TransactionContextHelper (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.common.TransactionContextHelper

No usage of bitronix.tm.resource.common.TransactionContextHelper



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/AbstractXAStatefulHolder.html0000644000175000017500000003505212215446622030360 0ustar tonytony Uses of Class bitronix.tm.resource.common.AbstractXAStatefulHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.common.AbstractXAStatefulHolder

Packages that use AbstractXAStatefulHolder
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of AbstractXAStatefulHolder in bitronix.tm.resource.common
 

Subclasses of AbstractXAStatefulHolder in bitronix.tm.resource.common
 class AbstractXAResourceHolder
          Implementation of all services required by a XAResourceHolder.
 class RecoveryXAResourceHolder
          XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
 

Uses of AbstractXAStatefulHolder in bitronix.tm.resource.ehcache
 

Subclasses of AbstractXAStatefulHolder in bitronix.tm.resource.ehcache
 class EhCacheXAResourceHolder
          Ehcache implementation of BTM's XAResourceHolder.
 

Uses of AbstractXAStatefulHolder in bitronix.tm.resource.jdbc
 

Subclasses of AbstractXAStatefulHolder in bitronix.tm.resource.jdbc
 class JdbcPooledConnection
          Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
 

Uses of AbstractXAStatefulHolder in bitronix.tm.resource.jms
 

Subclasses of AbstractXAStatefulHolder in bitronix.tm.resource.jms
 class DualSessionWrapper
          JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
 class JmsPooledConnection
          Implementation of a JMS pooled connection wrapping vendor's XAConnection implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/XAStatefulHolder.html0000644000175000017500000010064712215446622026677 0ustar tonytony Uses of Interface bitronix.tm.resource.common.XAStatefulHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.common.XAStatefulHolder

Packages that use XAStatefulHolder
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of XAStatefulHolder in bitronix.tm.resource.common
 

Subinterfaces of XAStatefulHolder in bitronix.tm.resource.common
 interface XAResourceHolder
          XAResource wrappers must implement this interface.
 

Classes in bitronix.tm.resource.common that implement XAStatefulHolder
 class AbstractXAResourceHolder
          Implementation of all services required by a XAResourceHolder.
 class AbstractXAStatefulHolder
          Implementation of all services required by a XAStatefulHolder.
 class RecoveryXAResourceHolder
          XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
 

Methods in bitronix.tm.resource.common that return XAStatefulHolder
 XAStatefulHolder XAResourceProducer.createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 XAStatefulHolder DeferredReleaseSynchronization.getXAStatefulHolder()
           
 

Methods in bitronix.tm.resource.common with parameters of type XAStatefulHolder
static void TransactionContextHelper.recycle(XAStatefulHolder xaStatefulHolder)
          Ensure the XAStatefulHolder's release won't be deferred anymore (when appropriate) as it has been recycled.
static void TransactionContextHelper.requeue(XAStatefulHolder xaStatefulHolder, ResourceBean bean)
          Switch the XAStatefulHolder's state appropriately after the acquired resource handle has been closed.
 void XAPool.stateChanged(XAStatefulHolder source, int oldState, int newState)
           
 void StateChangeListener.stateChanged(XAStatefulHolder source, int oldState, int newState)
          Fired when the internal state of a XAStatefulHolder has changed.
 void XAPool.stateChanging(XAStatefulHolder source, int currentState, int futureState)
           
 void StateChangeListener.stateChanging(XAStatefulHolder source, int currentState, int futureState)
          Fired before the internal state of a XAStatefulHolder has changed.
 

Constructors in bitronix.tm.resource.common with parameters of type XAStatefulHolder
DeferredReleaseSynchronization(XAStatefulHolder xaStatefulHolder)
           
 

Uses of XAStatefulHolder in bitronix.tm.resource.ehcache
 

Classes in bitronix.tm.resource.ehcache that implement XAStatefulHolder
 class EhCacheXAResourceHolder
          Ehcache implementation of BTM's XAResourceHolder.
 

Methods in bitronix.tm.resource.ehcache that return XAStatefulHolder
 XAStatefulHolder EhCacheXAResourceProducer.createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 

Uses of XAStatefulHolder in bitronix.tm.resource.jdbc
 

Classes in bitronix.tm.resource.jdbc that implement XAStatefulHolder
 class JdbcPooledConnection
          Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
 

Methods in bitronix.tm.resource.jdbc that return XAStatefulHolder
 XAStatefulHolder PoolingDataSource.createPooledConnection(Object xaFactory, ResourceBean bean)
           
 

Methods in bitronix.tm.resource.jdbc with parameters of type XAStatefulHolder
 void JdbcPooledConnection.stateChanged(XAStatefulHolder source, int oldState, int newState)
           
 void JdbcPooledConnection.stateChanging(XAStatefulHolder source, int currentState, int futureState)
           
 

Uses of XAStatefulHolder in bitronix.tm.resource.jms
 

Classes in bitronix.tm.resource.jms that implement XAStatefulHolder
 class DualSessionWrapper
          JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
 class JmsPooledConnection
          Implementation of a JMS pooled connection wrapping vendor's XAConnection implementation.
 

Methods in bitronix.tm.resource.jms that return XAStatefulHolder
 XAStatefulHolder PoolingConnectionFactory.createPooledConnection(Object xaFactory, ResourceBean bean)
           
 

Methods in bitronix.tm.resource.jms with parameters of type XAStatefulHolder
 void DualSessionWrapper.stateChanged(XAStatefulHolder source, int oldState, int newState)
           
 void DualSessionWrapper.stateChanging(XAStatefulHolder source, int currentState, int futureState)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/class-use/XAResourceHolder.html0000644000175000017500000011221612215446622026672 0ustar tonytony Uses of Interface bitronix.tm.resource.common.XAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.common.XAResourceHolder

Packages that use XAResourceHolder
bitronix.tm.internal Internal implementation details. 
bitronix.tm.resource Transaction Manager's resource management services. 
bitronix.tm.resource.common Resource management code common across all resource types. 
bitronix.tm.resource.ehcache Ehcache specific resource management code. 
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of XAResourceHolder in bitronix.tm.internal
 

Methods in bitronix.tm.internal that return XAResourceHolder
 XAResourceHolder XAResourceHolderState.getXAResourceHolder()
           
 

Constructors in bitronix.tm.internal with parameters of type XAResourceHolder
XAResourceHolderState(XAResourceHolder resourceHolder, ResourceBean bean)
           
 

Uses of XAResourceHolder in bitronix.tm.resource
 

Methods in bitronix.tm.resource that return XAResourceHolder
static XAResourceHolder ResourceRegistrar.findXAResourceHolder(XAResource xaResource)
          Find in the registered XAResourceProducers the XAResourceHolder from which the specified XAResource comes from.
 

Uses of XAResourceHolder in bitronix.tm.resource.common
 

Classes in bitronix.tm.resource.common that implement XAResourceHolder
 class AbstractXAResourceHolder
          Implementation of all services required by a XAResourceHolder.
 class RecoveryXAResourceHolder
          XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
 

Methods in bitronix.tm.resource.common that return XAResourceHolder
 XAResourceHolder XAResourceProducer.findXAResourceHolder(XAResource xaResource)
          Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
 XAResourceHolder XAPool.findXAResourceHolder(XAResource xaResource)
           
 

Methods in bitronix.tm.resource.common that return types with arguments of type XAResourceHolder
 List<XAResourceHolder> XAStatefulHolder.getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
 List<XAResourceHolder> RecoveryXAResourceHolder.getXAResourceHolders()
           
 

Methods in bitronix.tm.resource.common with parameters of type XAResourceHolder
static void TransactionContextHelper.delistFromCurrentTransaction(XAResourceHolder xaResourceHolder)
          Delist the XAResourceHolder from the current transaction or do nothing if there is no global transaction context for this thread.
static void TransactionContextHelper.enlistInCurrentTransaction(XAResourceHolder xaResourceHolder)
          Enlist the XAResourceHolder in the current transaction or do nothing if there is no global transaction context for this thread.
 boolean XAResourceHolder.hasStateForXAResource(XAResourceHolder xaResourceHolder)
          Check if this XAResourceHolder contains a state for a specific XAResourceHolder.
 boolean AbstractXAResourceHolder.hasStateForXAResource(XAResourceHolder xaResourceHolder)
           
 

Constructors in bitronix.tm.resource.common with parameters of type XAResourceHolder
RecoveryXAResourceHolder(XAResourceHolder xaResourceHolder)
           
 

Uses of XAResourceHolder in bitronix.tm.resource.ehcache
 

Classes in bitronix.tm.resource.ehcache that implement XAResourceHolder
 class EhCacheXAResourceHolder
          Ehcache implementation of BTM's XAResourceHolder.
 

Methods in bitronix.tm.resource.ehcache that return XAResourceHolder
 XAResourceHolder EhCacheXAResourceProducer.findXAResourceHolder(XAResource xaResource)
          Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
 

Methods in bitronix.tm.resource.ehcache that return types with arguments of type XAResourceHolder
 List<XAResourceHolder> EhCacheXAResourceHolder.getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
 

Uses of XAResourceHolder in bitronix.tm.resource.jdbc
 

Classes in bitronix.tm.resource.jdbc that implement XAResourceHolder
 class JdbcPooledConnection
          Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
 

Methods in bitronix.tm.resource.jdbc that return XAResourceHolder
 XAResourceHolder PoolingDataSource.findXAResourceHolder(XAResource xaResource)
           
 

Methods in bitronix.tm.resource.jdbc that return types with arguments of type XAResourceHolder
 List<XAResourceHolder> JdbcPooledConnection.getXAResourceHolders()
           
 

Uses of XAResourceHolder in bitronix.tm.resource.jms
 

Classes in bitronix.tm.resource.jms that implement XAResourceHolder
 class DualSessionWrapper
          JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
 

Methods in bitronix.tm.resource.jms that return XAResourceHolder
 XAResourceHolder PoolingConnectionFactory.findXAResourceHolder(XAResource xaResource)
           
 

Methods in bitronix.tm.resource.jms that return types with arguments of type XAResourceHolder
 List<XAResourceHolder> JmsPooledConnection.getXAResourceHolders()
           
 List<XAResourceHolder> DualSessionWrapper.getXAResourceHolders()
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/package-summary.html0000644000175000017500000002727212215446622024712 0ustar tonytony bitronix.tm.resource.common (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.resource.common

Resource management code common across all resource types.

See:
          Description

Interface Summary
StateChangeListener XAStatefulHolder state change listener interface.
XAResourceHolder XAResource wrappers must implement this interface.
XAResourceProducer A XAResourceProducer is a XAStatefulHolder factory.
XAStatefulHolder Any pooled connection class must implement the XAStatefulHolder interface.
 

Class Summary
AbstractXAResourceHolder Implementation of all services required by a XAResourceHolder.
AbstractXAStatefulHolder Implementation of all services required by a XAStatefulHolder.
DeferredReleaseSynchronization Synchronization used to release a XAStatefulHolder object after 2PC has executed.
RecoveryXAResourceHolder XAResourceHolder created by an XAResourceProducer that is used to perform recovery.
ResourceBean Abstract javabean container for all common properties of a XAResourceProducer as configured in the resources configuration file.
TransactionContextHelper Helper class that contains static logic common accross all resource types.
XAPool Generic XA pool.
 

Package bitronix.tm.resource.common Description

Resource management code common across all resource types.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/RecoveryXAResourceHolder.html0000644000175000017500000006776412215446620026531 0ustar tonytony RecoveryXAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Class RecoveryXAResourceHolder

java.lang.Object
  extended by bitronix.tm.resource.common.AbstractXAStatefulHolder
      extended by bitronix.tm.resource.common.AbstractXAResourceHolder
          extended by bitronix.tm.resource.common.RecoveryXAResourceHolder
All Implemented Interfaces:
XAResourceHolder, XAStatefulHolder

public class RecoveryXAResourceHolder
extends AbstractXAResourceHolder

XAResourceHolder created by an XAResourceProducer that is used to perform recovery. Objects of this class cannot be used outside recovery scope.

Author:
lorban

Field Summary
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Constructor Summary
RecoveryXAResourceHolder(XAResourceHolder xaResourceHolder)
           
 
Method Summary
 void close()
          Close the physical connection that this XAStatefulHolder represents.
 Object getConnectionHandle()
          Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
 Date getLastReleaseDate()
          Get the date at which this object was last released to the pool.
 ResourceBean getResourceBean()
          Get the ResourceBean which created this XAResourceHolder.
 XAResource getXAResource()
          Get the vendor's XAResource implementation of the wrapped resource.
 List<XAResourceHolder> getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAResourceHolder
getXAResourceHolderStateGtrids, getXAResourceHolderStatesForGtrid, hasStateForXAResource, isParticipatingInActiveGlobalTransaction, putXAResourceHolderState, removeXAResourceHolderState
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 

Constructor Detail

RecoveryXAResourceHolder

public RecoveryXAResourceHolder(XAResourceHolder xaResourceHolder)
Method Detail

close

public void close()
           throws Exception
Description copied from interface: XAStatefulHolder
Close the physical connection that this XAStatefulHolder represents.

Throws:
Exception - a resource-specific exception thrown when there is an error closing the physical connection.

getLastReleaseDate

public Date getLastReleaseDate()
Description copied from interface: XAStatefulHolder
Get the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.

Returns:
the date at which this object was last released to the pool or null if it never left the pool.

getXAResource

public XAResource getXAResource()
Description copied from interface: XAResourceHolder
Get the vendor's XAResource implementation of the wrapped resource.

Returns:
the vendor's XAResource implementation.

getResourceBean

public ResourceBean getResourceBean()
Description copied from interface: XAResourceHolder
Get the ResourceBean which created this XAResourceHolder.

Returns:
the ResourceBean which created this XAResourceHolder.

getXAResourceHolders

public List<XAResourceHolder> getXAResourceHolders()
Description copied from interface: XAStatefulHolder
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.

This method is thread-safe.

Returns:
the list of XAResourceHolders created by this XAStatefulHolder that are still open.

getConnectionHandle

public Object getConnectionHandle()
                           throws Exception
Description copied from interface: XAStatefulHolder
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.

This method is thread-safe.

Returns:
a resource-specific disaposable connection object.
Throws:
Exception - a resource-specific exception thrown when the disaposable connection cannot be created.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/XAPool.html0000644000175000017500000007200312215446620022754 0ustar tonytony XAPool (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Class XAPool

java.lang.Object
  extended by bitronix.tm.resource.common.XAPool
All Implemented Interfaces:
StateChangeListener

public class XAPool
extends Object
implements StateChangeListener

Generic XA pool. XAStatefulHolder instances are created by the XAPool out of a XAResourceProducer. Those objects are then pooled and can be retrieved and/or recycled by the pool depending on the running XA transaction's and the XAStatefulHolder's states.

Author:
lorban

Constructor Summary
XAPool(XAResourceProducer xaResourceProducer, ResourceBean bean)
           
 
Method Summary
 void close()
           
 XAResourceHolder findXAResourceHolder(XAResource xaResource)
           
 Object getConnectionHandle()
           
 Object getConnectionHandle(boolean recycle)
           
 Date getNextShrinkDate()
           
 Object getXAFactory()
           
 long inPoolSize()
           
 boolean isFailed()
           
 void reset()
           
 void setFailed(boolean failed)
           
 void shrink()
           
 void stateChanged(XAStatefulHolder source, int oldState, int newState)
          Fired when the internal state of a XAStatefulHolder has changed.
 void stateChanging(XAStatefulHolder source, int currentState, int futureState)
          Fired before the internal state of a XAStatefulHolder has changed.
 String toString()
           
 long totalPoolSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XAPool

public XAPool(XAResourceProducer xaResourceProducer,
              ResourceBean bean)
       throws Exception
Throws:
Exception
Method Detail

getXAFactory

public Object getXAFactory()

setFailed

public void setFailed(boolean failed)

isFailed

public boolean isFailed()

getConnectionHandle

public Object getConnectionHandle()
                           throws Exception
Throws:
Exception

getConnectionHandle

public Object getConnectionHandle(boolean recycle)
                           throws Exception
Throws:
Exception

close

public void close()

totalPoolSize

public long totalPoolSize()

inPoolSize

public long inPoolSize()

stateChanged

public void stateChanged(XAStatefulHolder source,
                         int oldState,
                         int newState)
Description copied from interface: StateChangeListener
Fired when the internal state of a XAStatefulHolder has changed.

Specified by:
stateChanged in interface StateChangeListener
Parameters:
source - the XAStatefulHolder changing state.
oldState - the old state of the XAStatefulHolder.
newState - the new state of the XAStatefulHolder.

stateChanging

public void stateChanging(XAStatefulHolder source,
                          int currentState,
                          int futureState)
Description copied from interface: StateChangeListener
Fired before the internal state of a XAStatefulHolder has changed.

Specified by:
stateChanging in interface StateChangeListener
Parameters:
source - the XAStatefulHolder changing state.
currentState - the current state of the XAStatefulHolder.
futureState - the future state of the XAStatefulHolder.

findXAResourceHolder

public XAResourceHolder findXAResourceHolder(XAResource xaResource)

getNextShrinkDate

public Date getNextShrinkDate()

shrink

public void shrink()
            throws Exception
Throws:
Exception

reset

public void reset()
           throws Exception
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/XAResourceProducer.html0000644000175000017500000005551312215446620025345 0ustar tonytony XAResourceProducer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Interface XAResourceProducer

All Superinterfaces:
Referenceable, Serializable
All Known Implementing Classes:
EhCacheXAResourceProducer, PoolingConnectionFactory, PoolingDataSource

public interface XAResourceProducer
extends Referenceable, Serializable

A XAResourceProducer is a XAStatefulHolder factory. It must be implemented by any class that is able to produce pooled XA connections.

Author:
lorban

Method Summary
 void close()
          Release this XAResourceProducer's internal resources.
 XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 void endRecovery()
          Release internal resources held after call to startRecovery().
 XAResourceHolder findXAResourceHolder(XAResource xaResource)
          Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
 String getUniqueName()
          Get the resource name as registered in the transactions journal.
 void init()
          Initialize this XAResourceProducer's internal resources.
 void setFailed(boolean failed)
          Mark this resource producer as failed or not.
 XAResourceHolderState startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 
Methods inherited from interface javax.naming.Referenceable
getReference
 

Method Detail

getUniqueName

String getUniqueName()
Get the resource name as registered in the transactions journal.

Returns:
the unique name of the resource.

startRecovery

XAResourceHolderState startRecovery()
                                    throws RecoveryException
Prepare the recoverable XAResource producer for recovery.

Returns:
a XAResourceHolderState object that can be used to call recover().
Throws:
RecoveryException - thrown when a XAResourceHolderState cannot be acquired.

endRecovery

void endRecovery()
                 throws RecoveryException
Release internal resources held after call to startRecovery().

Throws:
RecoveryException - thrown when an error occured while releasing reserved resources.

setFailed

void setFailed(boolean failed)
Mark this resource producer as failed or not. A resource is considered failed if recovery fails to run on it.

Parameters:
failed - true is the resource must be considered failed, false it it must be considered sane.

findXAResourceHolder

XAResourceHolder findXAResourceHolder(XAResource xaResource)
Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.

Parameters:
xaResource - the XAResource to look for.
Returns:
the associated XAResourceHolder or null if the XAResource does not belong to this XAResourceProducer.

init

void init()
Initialize this XAResourceProducer's internal resources.


close

void close()
Release this XAResourceProducer's internal resources.


createPooledConnection

XAStatefulHolder createPooledConnection(Object xaFactory,
                                        ResourceBean bean)
                                        throws Exception
Create a XAStatefulHolder that will be placed in an XAPool.

Parameters:
xaFactory - the vendor's resource-specific XA factory.
bean - the resource-specific bean describing the resource parameters.
Returns:
a XAStatefulHolder that will be placed in an XAPool.
Throws:
Exception - thrown when the XAStatefulHolder cannot be created.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/TransactionContextHelper.html0000644000175000017500000005362112215446620026611 0ustar tonytony TransactionContextHelper (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Class TransactionContextHelper

java.lang.Object
  extended by bitronix.tm.resource.common.TransactionContextHelper

public class TransactionContextHelper
extends Object

Helper class that contains static logic common accross all resource types.

Author:
lorban

Constructor Summary
TransactionContextHelper()
           
 
Method Summary
static BitronixTransaction currentTransaction()
          Get the transaction running on the current thead context.
static void delistFromCurrentTransaction(XAResourceHolder xaResourceHolder)
          Delist the XAResourceHolder from the current transaction or do nothing if there is no global transaction context for this thread.
static void enlistInCurrentTransaction(XAResourceHolder xaResourceHolder)
          Enlist the XAResourceHolder in the current transaction or do nothing if there is no global transaction context for this thread.
static void recycle(XAStatefulHolder xaStatefulHolder)
          Ensure the XAStatefulHolder's release won't be deferred anymore (when appropriate) as it has been recycled.
static void requeue(XAStatefulHolder xaStatefulHolder, ResourceBean bean)
          Switch the XAStatefulHolder's state appropriately after the acquired resource handle has been closed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionContextHelper

public TransactionContextHelper()
Method Detail

enlistInCurrentTransaction

public static void enlistInCurrentTransaction(XAResourceHolder xaResourceHolder)
                                       throws SystemException,
                                              RollbackException
Enlist the XAResourceHolder in the current transaction or do nothing if there is no global transaction context for this thread.

Parameters:
xaResourceHolder - the XAResourceHolder to enlist.
Throws:
SystemException - if an internal error happens.
RollbackException - if the current transaction has been marked as rollback only.

delistFromCurrentTransaction

public static void delistFromCurrentTransaction(XAResourceHolder xaResourceHolder)
                                         throws SystemException
Delist the XAResourceHolder from the current transaction or do nothing if there is no global transaction context for this thread.

Parameters:
xaResourceHolder - the XAResourceHolder to delist.
Throws:
SystemException - if an internal error happens.

currentTransaction

public static BitronixTransaction currentTransaction()
Get the transaction running on the current thead context.

Returns:
null if there is no transaction on the current context or if the transaction manager is not running.

requeue

public static void requeue(XAStatefulHolder xaStatefulHolder,
                           ResourceBean bean)
                    throws BitronixSystemException
Switch the XAStatefulHolder's state appropriately after the acquired resource handle has been closed. The pooled resource will either be marked as closed or not accessible, depending on the value of the bean's deferConnectionRelease property and will be marked for release after 2PC execution in the latter case.

Parameters:
xaStatefulHolder - the XAStatefulHolder to requeue.
bean - the ResourceBean of the XAResourceHolder.
Throws:
BitronixSystemException - if an internal error happens.

recycle

public static void recycle(XAStatefulHolder xaStatefulHolder)
Ensure the XAStatefulHolder's release won't be deferred anymore (when appropriate) as it has been recycled.

Parameters:
xaStatefulHolder - the recycled XAStatefulHolder.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/AbstractXAStatefulHolder.html0000644000175000017500000005270212215446620026460 0ustar tonytony AbstractXAStatefulHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Class AbstractXAStatefulHolder

java.lang.Object
  extended by bitronix.tm.resource.common.AbstractXAStatefulHolder
All Implemented Interfaces:
XAStatefulHolder
Direct Known Subclasses:
AbstractXAResourceHolder, JmsPooledConnection

public abstract class AbstractXAStatefulHolder
extends Object
implements XAStatefulHolder

Implementation of all services required by a XAStatefulHolder.

Author:
lorban

Field Summary
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Constructor Summary
AbstractXAStatefulHolder()
           
 
Method Summary
 void addStateChangeEventListener(StateChangeListener listener)
          Register an implementation of StateChangeListener.
 int getState()
          Get the current resource state.
 void removeStateChangeEventListener(StateChangeListener listener)
          Unregister an implementation of StateChangeListener.
 void setState(int state)
          Set the current resource state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
close, getConnectionHandle, getLastReleaseDate, getXAResourceHolders
 

Constructor Detail

AbstractXAStatefulHolder

public AbstractXAStatefulHolder()
Method Detail

getState

public int getState()
Description copied from interface: XAStatefulHolder
Get the current resource state.

This method is thread-safe.

Specified by:
getState in interface XAStatefulHolder
Returns:
the current resource state.

setState

public void setState(int state)
Description copied from interface: XAStatefulHolder
Set the current resource state.

This method is thread-safe.

Specified by:
setState in interface XAStatefulHolder
Parameters:
state - the current resource state.

addStateChangeEventListener

public void addStateChangeEventListener(StateChangeListener listener)
Description copied from interface: XAStatefulHolder
Register an implementation of StateChangeListener.

Specified by:
addStateChangeEventListener in interface XAStatefulHolder
Parameters:
listener - the StateChangeListener implementation to register.

removeStateChangeEventListener

public void removeStateChangeEventListener(StateChangeListener listener)
Description copied from interface: XAStatefulHolder
Unregister an implementation of StateChangeListener.

Specified by:
removeStateChangeEventListener in interface XAStatefulHolder
Parameters:
listener - the StateChangeListener implementation to unregister.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/XAStatefulHolder.html0000644000175000017500000005773312215446620025005 0ustar tonytony XAStatefulHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Interface XAStatefulHolder

All Known Subinterfaces:
XAResourceHolder
All Known Implementing Classes:
AbstractXAResourceHolder, AbstractXAStatefulHolder, DualSessionWrapper, EhCacheXAResourceHolder, JdbcPooledConnection, JmsPooledConnection, RecoveryXAResourceHolder

public interface XAStatefulHolder

Any pooled connection class must implement the XAStatefulHolder interface. It defines all the services that must be implemented by the connection as well as the pooling lifecycle states. Instances of this interface have to create and manage XAResourceHolders.

Author:
lorban

Field Summary
static int STATE_ACCESSIBLE
          The state in which the resource is when it out of the pool but accessible by the application.
static int STATE_CLOSED
          The state in which the resource is when it is closed and unusable.
static int STATE_IN_POOL
          The state in which the resource is when it is available in the pool.
static int STATE_NOT_ACCESSIBLE
          The state in which the resource is when it out of the pool but not accessible by the application.
 
Method Summary
 void addStateChangeEventListener(StateChangeListener listener)
          Register an implementation of StateChangeListener.
 void close()
          Close the physical connection that this XAStatefulHolder represents.
 Object getConnectionHandle()
          Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
 Date getLastReleaseDate()
          Get the date at which this object was last released to the pool.
 int getState()
          Get the current resource state.
 List<XAResourceHolder> getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
 void removeStateChangeEventListener(StateChangeListener listener)
          Unregister an implementation of StateChangeListener.
 void setState(int state)
          Set the current resource state.
 

Field Detail

STATE_CLOSED

static final int STATE_CLOSED
The state in which the resource is when it is closed and unusable.

See Also:
Constant Field Values

STATE_IN_POOL

static final int STATE_IN_POOL
The state in which the resource is when it is available in the pool.

See Also:
Constant Field Values

STATE_ACCESSIBLE

static final int STATE_ACCESSIBLE
The state in which the resource is when it out of the pool but accessible by the application.

See Also:
Constant Field Values

STATE_NOT_ACCESSIBLE

static final int STATE_NOT_ACCESSIBLE
The state in which the resource is when it out of the pool but not accessible by the application.

See Also:
Constant Field Values
Method Detail

getState

int getState()
Get the current resource state.

This method is thread-safe.

Returns:
the current resource state.

setState

void setState(int state)
Set the current resource state.

This method is thread-safe.

Parameters:
state - the current resource state.

addStateChangeEventListener

void addStateChangeEventListener(StateChangeListener listener)
Register an implementation of StateChangeListener.

Parameters:
listener - the StateChangeListener implementation to register.

removeStateChangeEventListener

void removeStateChangeEventListener(StateChangeListener listener)
Unregister an implementation of StateChangeListener.

Parameters:
listener - the StateChangeListener implementation to unregister.

getXAResourceHolders

List<XAResourceHolder> getXAResourceHolders()
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.

This method is thread-safe.

Returns:
the list of XAResourceHolders created by this XAStatefulHolder that are still open.

getConnectionHandle

Object getConnectionHandle()
                           throws Exception
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.

This method is thread-safe.

Returns:
a resource-specific disaposable connection object.
Throws:
Exception - a resource-specific exception thrown when the disaposable connection cannot be created.

close

void close()
           throws Exception
Close the physical connection that this XAStatefulHolder represents.

Throws:
Exception - a resource-specific exception thrown when there is an error closing the physical connection.

getLastReleaseDate

Date getLastReleaseDate()
Get the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.

Returns:
the date at which this object was last released to the pool or null if it never left the pool.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/common/XAResourceHolder.html0000644000175000017500000005446312215446620025002 0ustar tonytony XAResourceHolder (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.common
Interface XAResourceHolder

All Superinterfaces:
XAStatefulHolder
All Known Implementing Classes:
AbstractXAResourceHolder, DualSessionWrapper, EhCacheXAResourceHolder, JdbcPooledConnection, RecoveryXAResourceHolder

public interface XAResourceHolder
extends XAStatefulHolder

XAResource wrappers must implement this interface. It defines a way to get access to the transactional state of this XAResourceHolder.

Author:
lorban
See Also:
XAResourceHolderState

Field Summary
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Method Summary
 ResourceBean getResourceBean()
          Get the ResourceBean which created this XAResourceHolder.
 XAResource getXAResource()
          Get the vendor's XAResource implementation of the wrapped resource.
 Map<Uid,XAResourceHolderState> getXAResourceHolderStatesForGtrid(Uid gtrid)
          Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.
 boolean hasStateForXAResource(XAResourceHolder xaResourceHolder)
          Check if this XAResourceHolder contains a state for a specific XAResourceHolder.
 void putXAResourceHolderState(BitronixXid xid, XAResourceHolderState xaResourceHolderState)
          Add a XAResourceHolderState of this wrapped resource.
 void removeXAResourceHolderState(BitronixXid xid)
          Remove all states related to a specific Xid from this wrapped resource.
 
Methods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
addStateChangeEventListener, close, getConnectionHandle, getLastReleaseDate, getState, getXAResourceHolders, removeStateChangeEventListener, setState
 

Method Detail

getXAResource

XAResource getXAResource()
Get the vendor's XAResource implementation of the wrapped resource.

Returns:
the vendor's XAResource implementation.

getXAResourceHolderStatesForGtrid

Map<Uid,XAResourceHolderState> getXAResourceHolderStatesForGtrid(Uid gtrid)
Get all the XAResourceHolderStates of this wrapped resource for a specific GTRID.

The returned Map is guaranteed to return states in order they were added when its values are iterated.

Parameters:
gtrid - the GTRID of the transaction state to add.
Returns:
the XAResourceHolderState.

putXAResourceHolderState

void putXAResourceHolderState(BitronixXid xid,
                              XAResourceHolderState xaResourceHolderState)
Add a XAResourceHolderState of this wrapped resource.

Parameters:
xid - the Xid of the transaction state to add.
xaResourceHolderState - the XAResourceHolderState to set.

removeXAResourceHolderState

void removeXAResourceHolderState(BitronixXid xid)
Remove all states related to a specific Xid from this wrapped resource.

Parameters:
xid - the Xid of the transaction state to remove.

hasStateForXAResource

boolean hasStateForXAResource(XAResourceHolder xaResourceHolder)
Check if this XAResourceHolder contains a state for a specific XAResourceHolder. In other words: has the XAResourceHolder's XAResource been enlisted in some transaction ?

Parameters:
xaResourceHolder - the XAResourceHolder to look for.
Returns:
true if the XAResourceHolder is enlisted in some transaction, false otherwise.

getResourceBean

ResourceBean getResourceBean()
Get the ResourceBean which created this XAResourceHolder.

Returns:
the ResourceBean which created this XAResourceHolder.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/package-use.html0000644000175000017500000001533512215446622022516 0ustar tonytony Uses of Package bitronix.tm.resource (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.resource

Packages that use bitronix.tm.resource
bitronix.tm JTA interfaces implementations and global services. 
 

Classes in bitronix.tm.resource used by bitronix.tm
ResourceLoader
          XA resources pools configurator & loader.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/0000755000175000017500000000000012215446622020225 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/MessageProducerWrapper.html0000644000175000017500000007305412215446622025555 0ustar tonytony MessageProducerWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class MessageProducerWrapper

java.lang.Object
  extended by bitronix.tm.resource.jms.MessageProducerWrapper
All Implemented Interfaces:
javax.jms.MessageProducer

public class MessageProducerWrapper
extends Object
implements javax.jms.MessageProducer

MessageProducer wrapper that adds XA enlistment semantics.

Author:
lorban

Field Summary
protected  DualSessionWrapper session
           
 
Constructor Summary
MessageProducerWrapper(javax.jms.MessageProducer messageProducer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
 
Method Summary
 void close()
           
protected  void enlistResource()
          Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource.
 int getDeliveryMode()
           
 javax.jms.Destination getDestination()
           
 boolean getDisableMessageID()
           
 boolean getDisableMessageTimestamp()
           
 javax.jms.MessageProducer getMessageProducer()
           
 int getPriority()
           
 long getTimeToLive()
           
 void send(javax.jms.Destination destination, javax.jms.Message message)
           
 void send(javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive)
           
 void send(javax.jms.Message message)
           
 void send(javax.jms.Message message, int deliveryMode, int priority, long timeToLive)
           
 void setDeliveryMode(int deliveryMode)
           
 void setDisableMessageID(boolean value)
           
 void setDisableMessageTimestamp(boolean value)
           
 void setPriority(int defaultPriority)
           
 void setTimeToLive(long timeToLive)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

session

protected final DualSessionWrapper session
Constructor Detail

MessageProducerWrapper

public MessageProducerWrapper(javax.jms.MessageProducer messageProducer,
                              DualSessionWrapper session,
                              PoolingConnectionFactory poolingConnectionFactory)
Method Detail

getMessageProducer

public javax.jms.MessageProducer getMessageProducer()

enlistResource

protected void enlistResource()
                       throws javax.jms.JMSException
Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource. If no transaction is running then this method does nothing.

Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object

send

public void send(javax.jms.Message message)
          throws javax.jms.JMSException
Specified by:
send in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

send

public void send(javax.jms.Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws javax.jms.JMSException
Specified by:
send in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message)
          throws javax.jms.JMSException
Specified by:
send in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws javax.jms.JMSException
Specified by:
send in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Specified by:
close in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

setDisableMessageID

public void setDisableMessageID(boolean value)
                         throws javax.jms.JMSException
Specified by:
setDisableMessageID in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

getDisableMessageID

public boolean getDisableMessageID()
                            throws javax.jms.JMSException
Specified by:
getDisableMessageID in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

setDisableMessageTimestamp

public void setDisableMessageTimestamp(boolean value)
                                throws javax.jms.JMSException
Specified by:
setDisableMessageTimestamp in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

getDisableMessageTimestamp

public boolean getDisableMessageTimestamp()
                                   throws javax.jms.JMSException
Specified by:
getDisableMessageTimestamp in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

setDeliveryMode

public void setDeliveryMode(int deliveryMode)
                     throws javax.jms.JMSException
Specified by:
setDeliveryMode in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

getDeliveryMode

public int getDeliveryMode()
                    throws javax.jms.JMSException
Specified by:
getDeliveryMode in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

setPriority

public void setPriority(int defaultPriority)
                 throws javax.jms.JMSException
Specified by:
setPriority in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

getPriority

public int getPriority()
                throws javax.jms.JMSException
Specified by:
getPriority in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

setTimeToLive

public void setTimeToLive(long timeToLive)
                   throws javax.jms.JMSException
Specified by:
setTimeToLive in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

getTimeToLive

public long getTimeToLive()
                   throws javax.jms.JMSException
Specified by:
getTimeToLive in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException

getDestination

public javax.jms.Destination getDestination()
                                     throws javax.jms.JMSException
Specified by:
getDestination in interface javax.jms.MessageProducer
Throws:
javax.jms.JMSException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/package-frame.html0000644000175000017500000000500512215446622023576 0ustar tonytony bitronix.tm.resource.jms (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.resource.jms
Interfaces 
JmsPooledConnectionMBean
PoolingConnectionFactoryMBean
Classes 
DualSessionWrapper
JmsConnectionHandle
JmsPooledConnection
JndiXAConnectionFactory
MessageConsumerWrapper
MessageProducerConsumerKey
MessageProducerWrapper
PoolingConnectionFactory
TopicSubscriberWrapper
btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/JmsPooledConnection.html0000644000175000017500000010027412215446622025033 0ustar tonytony JmsPooledConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class JmsPooledConnection

java.lang.Object
  extended by bitronix.tm.resource.common.AbstractXAStatefulHolder
      extended by bitronix.tm.resource.jms.JmsPooledConnection
All Implemented Interfaces:
XAStatefulHolder, JmsPooledConnectionMBean

public class JmsPooledConnection
extends AbstractXAStatefulHolder
implements JmsPooledConnectionMBean

Implementation of a JMS pooled connection wrapping vendor's XAConnection implementation.

Author:
lorban TODO: how can the JMS connection be accurately tested?

Field Summary
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Constructor Summary
protected JmsPooledConnection(PoolingConnectionFactory poolingConnectionFactory, javax.jms.XAConnection connection)
           
 
Method Summary
 void close()
          Close the physical connection that this XAStatefulHolder represents.
 RecoveryXAResourceHolder createRecoveryXAResourceHolder()
           
protected  javax.jms.Session createSession(boolean transacted, int acknowledgeMode)
           
 Date getAcquisitionDate()
           
 Object getConnectionHandle()
          Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
 Date getLastReleaseDate()
          Get the date at which this object was last released to the pool.
 PoolingConnectionFactory getPoolingConnectionFactory()
           
 String getStateDescription()
           
 Collection<String> getTransactionGtridsCurrentlyHoldingThis()
           
 javax.jms.XAConnection getXAConnection()
           
 List<XAResourceHolder> getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
protected  void release()
           
 String toString()
           
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JmsPooledConnection

protected JmsPooledConnection(PoolingConnectionFactory poolingConnectionFactory,
                              javax.jms.XAConnection connection)
Method Detail

getXAConnection

public javax.jms.XAConnection getXAConnection()

getPoolingConnectionFactory

public PoolingConnectionFactory getPoolingConnectionFactory()

createRecoveryXAResourceHolder

public RecoveryXAResourceHolder createRecoveryXAResourceHolder()
                                                        throws javax.jms.JMSException
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Description copied from interface: XAStatefulHolder
Close the physical connection that this XAStatefulHolder represents.

Specified by:
close in interface XAStatefulHolder
Throws:
javax.jms.JMSException

getXAResourceHolders

public List<XAResourceHolder> getXAResourceHolders()
Description copied from interface: XAStatefulHolder
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.

This method is thread-safe.

Specified by:
getXAResourceHolders in interface XAStatefulHolder
Returns:
the list of XAResourceHolders created by this XAStatefulHolder that are still open.

getConnectionHandle

public Object getConnectionHandle()
                           throws Exception
Description copied from interface: XAStatefulHolder
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.

This method is thread-safe.

Specified by:
getConnectionHandle in interface XAStatefulHolder
Returns:
a resource-specific disaposable connection object.
Throws:
Exception - a resource-specific exception thrown when the disaposable connection cannot be created.

release

protected void release()
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createSession

protected javax.jms.Session createSession(boolean transacted,
                                          int acknowledgeMode)
                                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getLastReleaseDate

public Date getLastReleaseDate()
Description copied from interface: XAStatefulHolder
Get the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.

Specified by:
getLastReleaseDate in interface XAStatefulHolder
Returns:
the date at which this object was last released to the pool or null if it never left the pool.

toString

public String toString()
Overrides:
toString in class Object

getStateDescription

public String getStateDescription()
Specified by:
getStateDescription in interface JmsPooledConnectionMBean

getAcquisitionDate

public Date getAcquisitionDate()
Specified by:
getAcquisitionDate in interface JmsPooledConnectionMBean

getTransactionGtridsCurrentlyHoldingThis

public Collection<String> getTransactionGtridsCurrentlyHoldingThis()
Specified by:
getTransactionGtridsCurrentlyHoldingThis in interface JmsPooledConnectionMBean


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/package-tree.html0000644000175000017500000002470412215446622023452 0ustar tonytony bitronix.tm.resource.jms Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.resource.jms

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/PoolingConnectionFactoryMBean.html0000644000175000017500000003052012215446622026775 0ustar tonytony PoolingConnectionFactoryMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Interface PoolingConnectionFactoryMBean

All Known Implementing Classes:
PoolingConnectionFactory

public interface PoolingConnectionFactoryMBean

Author:
lorban

Method Summary
 long getInPoolSize()
           
 int getMaxPoolSize()
           
 int getMinPoolSize()
           
 long getTotalPoolSize()
           
 boolean isDisabled()
           
 boolean isFailed()
           
 void reset()
           
 void setDisabled(boolean disabled)
           
 

Method Detail

getMinPoolSize

int getMinPoolSize()

getMaxPoolSize

int getMaxPoolSize()

getInPoolSize

long getInPoolSize()

getTotalPoolSize

long getTotalPoolSize()

isFailed

boolean isFailed()

reset

void reset()
           throws Exception
Throws:
Exception

isDisabled

boolean isDisabled()

setDisabled

void setDisabled(boolean disabled)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/package-use.html0000644000175000017500000002145512215446622023307 0ustar tonytony Uses of Package bitronix.tm.resource.jms (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.resource.jms

Packages that use bitronix.tm.resource.jms
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Classes in bitronix.tm.resource.jms used by bitronix.tm.resource.jms
DualSessionWrapper
          JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
JmsPooledConnection
          Implementation of a JMS pooled connection wrapping vendor's XAConnection implementation.
JmsPooledConnectionMBean
          JmsPooledConnection Management interface.
MessageConsumerWrapper
          MessageConsumer wrapper that adds XA enlistment semantics.
PoolingConnectionFactory
          Implementation of a JMS ConnectionFactory wrapping vendor's XAConnectionFactory implementation.
PoolingConnectionFactoryMBean
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/JndiXAConnectionFactory.html0000644000175000017500000012637312215446622025614 0ustar tonytony JndiXAConnectionFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class JndiXAConnectionFactory

java.lang.Object
  extended by bitronix.tm.resource.jms.JndiXAConnectionFactory
All Implemented Interfaces:
javax.jms.XAConnectionFactory

public class JndiXAConnectionFactory
extends Object
implements javax.jms.XAConnectionFactory

XAConnectionFactory implementation that wraps another XAConnectionFactory implementation available in some JNDI tree.

Author:
lorban

Constructor Summary
JndiXAConnectionFactory()
           
 
Method Summary
 javax.jms.XAConnection createXAConnection()
           
 javax.jms.XAConnection createXAConnection(String userName, String password)
           
 Properties getExtraJndiProperties()
          The extra JNDI environment properties added the the InitialContext's environment upon creation.
 String getInitialContextFactory()
          The Context.INITIAL_CONTEXT_FACTORY of the JNDI Context used to fetch the XAConnectionFactory.
 String getName()
          The JNDI name under which the XAConnectionFactory is available.
 String getProviderUrl()
          The Context.PROVIDER_URL of the JNDI Context used to fetch the XAConnectionFactory.
 String getSecurityCredentials()
          The Context.SECURITY_CREDENTIALS of the JNDI Context used to fetch the XAConnectionFactory.
 String getSecurityPrincipal()
          The Context.SECURITY_PRINCIPAL of the JNDI Context used to fetch the XAConnectionFactory.
 String getUrlPkgPrefixes()
          The Context.URL_PKG_PREFIXES of the JNDI Context used to fetch the XAConnectionFactory.
protected  void init()
           
 boolean isNarrowJndiObject()
          Should PortableRemoteObject.narrow(Object, Class) be applied on the object looked up from JNDI before trying to cast it to XAConnectionFactory ?
 void setExtraJndiProperties(Properties extraJndiProperties)
          Set the extra JNDI environment properties added the the InitialContext's environment upon creation.
 void setInitialContextFactory(String initialContextFactory)
          Set the Context.INITIAL_CONTEXT_FACTORY of the JNDI Context used to fetch the XAConnectionFactory.
 void setName(String name)
          Set the JNDI name under which the XAConnectionFactory is available.
 void setNarrowJndiObject(boolean narrowJndiObject)
          Set if PortableRemoteObject.narrow(Object, Class) should be applied on the object looked up from JNDI before trying to cast it to XAConnectionFactory ?
 void setProviderUrl(String providerUrl)
          Set the Context.PROVIDER_URL of the JNDI Context used to fetch the XAConnectionFactory.
 void setSecurityCredentials(String securityCredentials)
          Set the Context.SECURITY_CREDENTIALS of the JNDI Context used to fetch the XAConnectionFactory.
 void setSecurityPrincipal(String securityPrincipal)
          Set the Context.SECURITY_PRINCIPAL of the JNDI Context used to fetch the XAConnectionFactory.
 void setUrlPkgPrefixes(String urlPkgPrefixes)
          Set the Context.URL_PKG_PREFIXES of the JNDI Context used to fetch the XAConnectionFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JndiXAConnectionFactory

public JndiXAConnectionFactory()
Method Detail

getInitialContextFactory

public String getInitialContextFactory()
The Context.INITIAL_CONTEXT_FACTORY of the JNDI Context used to fetch the XAConnectionFactory.

Returns:
the Context.INITIAL_CONTEXT_FACTORY value.

setInitialContextFactory

public void setInitialContextFactory(String initialContextFactory)
Set the Context.INITIAL_CONTEXT_FACTORY of the JNDI Context used to fetch the XAConnectionFactory. If not set, the Context is created without the environment parameter, using the default constructor. This means all other properties (providerUrl, urlPkgPrefixes, extraJndiProperties...) are then ignored.

Parameters:
initialContextFactory - the Context.INITIAL_CONTEXT_FACTORY value.

getProviderUrl

public String getProviderUrl()
The Context.PROVIDER_URL of the JNDI Context used to fetch the XAConnectionFactory.

Returns:
the Context.PROVIDER_URL value.

setProviderUrl

public void setProviderUrl(String providerUrl)
Set the Context.PROVIDER_URL of the JNDI Context used to fetch the XAConnectionFactory.

Parameters:
providerUrl - the Context.PROVIDER_URL value.

getUrlPkgPrefixes

public String getUrlPkgPrefixes()
The Context.URL_PKG_PREFIXES of the JNDI Context used to fetch the XAConnectionFactory.

Returns:
the Context.URL_PKG_PREFIXES value.

setUrlPkgPrefixes

public void setUrlPkgPrefixes(String urlPkgPrefixes)
Set the Context.URL_PKG_PREFIXES of the JNDI Context used to fetch the XAConnectionFactory.

Parameters:
urlPkgPrefixes - the Context.URL_PKG_PREFIXES value.

getSecurityPrincipal

public String getSecurityPrincipal()
The Context.SECURITY_PRINCIPAL of the JNDI Context used to fetch the XAConnectionFactory.

Returns:
the Context.SECURITY_PRINCIPAL value.

setSecurityPrincipal

public void setSecurityPrincipal(String securityPrincipal)
Set the Context.SECURITY_PRINCIPAL of the JNDI Context used to fetch the XAConnectionFactory. If Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER_URL are not set, this value is ignored.

Parameters:
securityPrincipal - the Context.SECURITY_PRINCIPAL value.

getSecurityCredentials

public String getSecurityCredentials()
The Context.SECURITY_CREDENTIALS of the JNDI Context used to fetch the XAConnectionFactory.

Returns:
the Context.SECURITY_CREDENTIALS value.

setSecurityCredentials

public void setSecurityCredentials(String securityCredentials)
Set the Context.SECURITY_CREDENTIALS of the JNDI Context used to fetch the XAConnectionFactory. If Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER_URL are not set, this value is ignored.

Parameters:
securityCredentials - the Context.SECURITY_CREDENTIALS value.

getName

public String getName()
The JNDI name under which the XAConnectionFactory is available.

Returns:
The JNDI name.

setName

public void setName(String name)
Set the JNDI name under which the XAConnectionFactory is available.

Parameters:
name - the JNDI name.

getExtraJndiProperties

public Properties getExtraJndiProperties()
The extra JNDI environment properties added the the InitialContext's environment upon creation.

Returns:
The extra JNDI environment properties.

setExtraJndiProperties

public void setExtraJndiProperties(Properties extraJndiProperties)
Set the extra JNDI environment properties added the the InitialContext's environment upon creation.

Parameters:
extraJndiProperties - The extra JNDI environment properties.

isNarrowJndiObject

public boolean isNarrowJndiObject()
Should PortableRemoteObject.narrow(Object, Class) be applied on the object looked up from JNDI before trying to cast it to XAConnectionFactory ?

Returns:
true if the object should be narrowed, false otherwise.

setNarrowJndiObject

public void setNarrowJndiObject(boolean narrowJndiObject)
Set if PortableRemoteObject.narrow(Object, Class) should be applied on the object looked up from JNDI before trying to cast it to XAConnectionFactory ?

Parameters:
narrowJndiObject - true if the object should be narrowed, false otherwise.

init

protected void init()
             throws NamingException
Throws:
NamingException

createXAConnection

public javax.jms.XAConnection createXAConnection()
                                          throws javax.jms.JMSException
Specified by:
createXAConnection in interface javax.jms.XAConnectionFactory
Throws:
javax.jms.JMSException

createXAConnection

public javax.jms.XAConnection createXAConnection(String userName,
                                                 String password)
                                          throws javax.jms.JMSException
Specified by:
createXAConnection in interface javax.jms.XAConnectionFactory
Throws:
javax.jms.JMSException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/0000755000175000017500000000000012215446622021005 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/LrcXASession.html0000644000175000017500000012712112215446622024214 0ustar tonytony LrcXASession (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms.lrc
Class LrcXASession

java.lang.Object
  extended by bitronix.tm.resource.jms.lrc.LrcXASession
All Implemented Interfaces:
Runnable, javax.jms.Session, javax.jms.XASession

public class LrcXASession
extends Object
implements javax.jms.XASession

XASession implementation for a non-XA JMS resource emulating XA with Last Resource Commit.

Author:
lorban

Field Summary
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Constructor Summary
LrcXASession(javax.jms.Session session)
           
 
Method Summary
 void close()
           
 void commit()
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, String messageSelector)
           
 javax.jms.BytesMessage createBytesMessage()
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector, boolean noLocal)
           
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name)
           
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name, String messageSelector, boolean noLocal)
           
 javax.jms.MapMessage createMapMessage()
           
 javax.jms.Message createMessage()
           
 javax.jms.ObjectMessage createObjectMessage()
           
 javax.jms.ObjectMessage createObjectMessage(Serializable serializable)
           
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
           
 javax.jms.Queue createQueue(String queueName)
           
 javax.jms.StreamMessage createStreamMessage()
           
 javax.jms.TemporaryQueue createTemporaryQueue()
           
 javax.jms.TemporaryTopic createTemporaryTopic()
           
 javax.jms.TextMessage createTextMessage()
           
 javax.jms.TextMessage createTextMessage(String text)
           
 javax.jms.Topic createTopic(String topicName)
           
 int getAcknowledgeMode()
           
 javax.jms.MessageListener getMessageListener()
           
 javax.jms.Session getSession()
           
 boolean getTransacted()
           
 XAResource getXAResource()
           
 void recover()
           
 void rollback()
           
 void run()
           
 void setMessageListener(javax.jms.MessageListener messageListener)
           
 String toString()
           
 void unsubscribe(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LrcXASession

public LrcXASession(javax.jms.Session session)
Method Detail

getSession

public javax.jms.Session getSession()
                             throws javax.jms.JMSException
Specified by:
getSession in interface javax.jms.XASession
Throws:
javax.jms.JMSException

getXAResource

public XAResource getXAResource()
Specified by:
getXAResource in interface javax.jms.XASession

createBytesMessage

public javax.jms.BytesMessage createBytesMessage()
                                          throws javax.jms.JMSException
Specified by:
createBytesMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createMapMessage

public javax.jms.MapMessage createMapMessage()
                                      throws javax.jms.JMSException
Specified by:
createMapMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createMessage

public javax.jms.Message createMessage()
                                throws javax.jms.JMSException
Specified by:
createMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createObjectMessage

public javax.jms.ObjectMessage createObjectMessage()
                                            throws javax.jms.JMSException
Specified by:
createObjectMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createObjectMessage

public javax.jms.ObjectMessage createObjectMessage(Serializable serializable)
                                            throws javax.jms.JMSException
Specified by:
createObjectMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createStreamMessage

public javax.jms.StreamMessage createStreamMessage()
                                            throws javax.jms.JMSException
Specified by:
createStreamMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTextMessage

public javax.jms.TextMessage createTextMessage()
                                        throws javax.jms.JMSException
Specified by:
createTextMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTextMessage

public javax.jms.TextMessage createTextMessage(String text)
                                        throws javax.jms.JMSException
Specified by:
createTextMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

getTransacted

public boolean getTransacted()
                      throws javax.jms.JMSException
Specified by:
getTransacted in interface javax.jms.Session
Specified by:
getTransacted in interface javax.jms.XASession
Throws:
javax.jms.JMSException

getAcknowledgeMode

public int getAcknowledgeMode()
                       throws javax.jms.JMSException
Specified by:
getAcknowledgeMode in interface javax.jms.Session
Throws:
javax.jms.JMSException

commit

public void commit()
            throws javax.jms.JMSException
Specified by:
commit in interface javax.jms.Session
Specified by:
commit in interface javax.jms.XASession
Throws:
javax.jms.JMSException

rollback

public void rollback()
              throws javax.jms.JMSException
Specified by:
rollback in interface javax.jms.Session
Specified by:
rollback in interface javax.jms.XASession
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Specified by:
close in interface javax.jms.Session
Throws:
javax.jms.JMSException

recover

public void recover()
             throws javax.jms.JMSException
Specified by:
recover in interface javax.jms.Session
Throws:
javax.jms.JMSException

getMessageListener

public javax.jms.MessageListener getMessageListener()
                                             throws javax.jms.JMSException
Specified by:
getMessageListener in interface javax.jms.Session
Throws:
javax.jms.JMSException

setMessageListener

public void setMessageListener(javax.jms.MessageListener messageListener)
                        throws javax.jms.JMSException
Specified by:
setMessageListener in interface javax.jms.Session
Throws:
javax.jms.JMSException

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in interface javax.jms.Session

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Specified by:
createProducer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                String messageSelector)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                String messageSelector,
                                                boolean noLocal)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createQueue

public javax.jms.Queue createQueue(String queueName)
                            throws javax.jms.JMSException
Specified by:
createQueue in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTopic

public javax.jms.Topic createTopic(String topicName)
                            throws javax.jms.JMSException
Specified by:
createTopic in interface javax.jms.Session
Throws:
javax.jms.JMSException

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         String name)
                                                  throws javax.jms.JMSException
Specified by:
createDurableSubscriber in interface javax.jms.Session
Throws:
javax.jms.JMSException

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         String name,
                                                         String messageSelector,
                                                         boolean noLocal)
                                                  throws javax.jms.JMSException
Specified by:
createDurableSubscriber in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
                                     throws javax.jms.JMSException
Specified by:
createBrowser in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue,
                                            String messageSelector)
                                     throws javax.jms.JMSException
Specified by:
createBrowser in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTemporaryQueue

public javax.jms.TemporaryQueue createTemporaryQueue()
                                              throws javax.jms.JMSException
Specified by:
createTemporaryQueue in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTemporaryTopic

public javax.jms.TemporaryTopic createTemporaryTopic()
                                              throws javax.jms.JMSException
Specified by:
createTemporaryTopic in interface javax.jms.Session
Throws:
javax.jms.JMSException

unsubscribe

public void unsubscribe(String name)
                 throws javax.jms.JMSException
Specified by:
unsubscribe in interface javax.jms.Session
Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/package-frame.html0000644000175000017500000000257612215446622024370 0ustar tonytony bitronix.tm.resource.jms.lrc (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.resource.jms.lrc
Classes 
LrcXAConnection
LrcXAConnectionFactory
LrcXAResource
LrcXASession
btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/package-tree.html0000644000175000017500000001646312215446622024235 0ustar tonytony bitronix.tm.resource.jms.lrc Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.resource.jms.lrc

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/package-use.html0000644000175000017500000001334512215446622024066 0ustar tonytony Uses of Package bitronix.tm.resource.jms.lrc (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.resource.jms.lrc

No usage of bitronix.tm.resource.jms.lrc



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/class-use/0000755000175000017500000000000012215446622022704 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/class-use/LrcXASession.html0000644000175000017500000001415412215446622026114 0ustar tonytony Uses of Class bitronix.tm.resource.jms.lrc.LrcXASession (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.lrc.LrcXASession

No usage of bitronix.tm.resource.jms.lrc.LrcXASession



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/class-use/LrcXAConnectionFactory.html0000644000175000017500000001432012215446622030113 0ustar tonytony Uses of Class bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory

No usage of bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/class-use/LrcXAResource.html0000644000175000017500000001416612215446622026263 0ustar tonytony Uses of Class bitronix.tm.resource.jms.lrc.LrcXAResource (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.lrc.LrcXAResource

No usage of bitronix.tm.resource.jms.lrc.LrcXAResource



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/class-use/LrcXAConnection.html0000644000175000017500000001421212215446622026563 0ustar tonytony Uses of Class bitronix.tm.resource.jms.lrc.LrcXAConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.lrc.LrcXAConnection

No usage of bitronix.tm.resource.jms.lrc.LrcXAConnection



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/LrcXAConnectionFactory.html0000644000175000017500000004520312215446622026220 0ustar tonytony LrcXAConnectionFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms.lrc
Class LrcXAConnectionFactory

java.lang.Object
  extended by bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory
All Implemented Interfaces:
javax.jms.XAConnectionFactory

public class LrcXAConnectionFactory
extends Object
implements javax.jms.XAConnectionFactory

XAConnectionFactory implementation for a non-XA JMS resource emulating XA with Last Resource Commit.

Author:
lorban

Constructor Summary
LrcXAConnectionFactory()
           
 
Method Summary
 javax.jms.XAConnection createXAConnection()
           
 javax.jms.XAConnection createXAConnection(String user, String password)
           
 String getConnectionFactoryClassName()
           
 Properties getProperties()
           
 void setConnectionFactoryClassName(String connectionFactoryClassName)
           
 void setProperties(Properties properties)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LrcXAConnectionFactory

public LrcXAConnectionFactory()
Method Detail

getConnectionFactoryClassName

public String getConnectionFactoryClassName()

setConnectionFactoryClassName

public void setConnectionFactoryClassName(String connectionFactoryClassName)

getProperties

public Properties getProperties()

setProperties

public void setProperties(Properties properties)

createXAConnection

public javax.jms.XAConnection createXAConnection()
                                          throws javax.jms.JMSException
Specified by:
createXAConnection in interface javax.jms.XAConnectionFactory
Throws:
javax.jms.JMSException

createXAConnection

public javax.jms.XAConnection createXAConnection(String user,
                                                 String password)
                                          throws javax.jms.JMSException
Specified by:
createXAConnection in interface javax.jms.XAConnectionFactory
Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/LrcXAResource.html0000644000175000017500000011027312215446622024360 0ustar tonytony LrcXAResource (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms.lrc
Class LrcXAResource

java.lang.Object
  extended by bitronix.tm.resource.jms.lrc.LrcXAResource
All Implemented Interfaces:
XAResource

public class LrcXAResource
extends Object
implements XAResource

XAResource implementation for a non-XA JMS connection emulating XA with Last Resource Commit.

The XA protocol flow is implemented by this state machine:

 NO_TX
   |
   | start(TMNOFLAGS)
   |
   |       end(TMFAIL)
 STARTED -------------- NO_TX
   |
   | end(TMSUCCESS)
   |
   |    start(TMJOIN)
 ENDED ---------------- STARTED
   |\
   | \  commit (one phase)
   |  ----------------- NO_TX
   |
   | prepare()
   |
   |       commit() or
   |       rollback()
 PREPARED ------------- NO_TX
 
XAResource.TMSUSPEND and XAResource.TMRESUME are not supported.

Author:
lorban

Field Summary
static int ENDED
           
static int NO_TX
           
static int PREPARED
           
static int STARTED
           
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
LrcXAResource(javax.jms.Session session)
           
 
Method Summary
 void commit(Xid xid, boolean onePhase)
           
 void end(Xid xid, int flag)
           
 void forget(Xid xid)
           
 int getState()
           
 int getTransactionTimeout()
           
 boolean isSameRM(XAResource xaResource)
           
 int prepare(Xid xid)
           
 Xid[] recover(int flags)
           
 void rollback(Xid xid)
           
 boolean setTransactionTimeout(int seconds)
           
 void start(Xid xid, int flag)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_TX

public static final int NO_TX
See Also:
Constant Field Values

STARTED

public static final int STARTED
See Also:
Constant Field Values

ENDED

public static final int ENDED
See Also:
Constant Field Values

PREPARED

public static final int PREPARED
See Also:
Constant Field Values
Constructor Detail

LrcXAResource

public LrcXAResource(javax.jms.Session session)
Method Detail

getState

public int getState()

getTransactionTimeout

public int getTransactionTimeout()
                          throws XAException
Specified by:
getTransactionTimeout in interface XAResource
Throws:
XAException

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)
                              throws XAException
Specified by:
setTransactionTimeout in interface XAResource
Throws:
XAException

forget

public void forget(Xid xid)
            throws XAException
Specified by:
forget in interface XAResource
Throws:
XAException

recover

public Xid[] recover(int flags)
              throws XAException
Specified by:
recover in interface XAResource
Throws:
XAException

isSameRM

public boolean isSameRM(XAResource xaResource)
                 throws XAException
Specified by:
isSameRM in interface XAResource
Throws:
XAException

start

public void start(Xid xid,
                  int flag)
           throws XAException
Specified by:
start in interface XAResource
Throws:
XAException

end

public void end(Xid xid,
                int flag)
         throws XAException
Specified by:
end in interface XAResource
Throws:
XAException

prepare

public int prepare(Xid xid)
            throws XAException
Specified by:
prepare in interface XAResource
Throws:
XAException

commit

public void commit(Xid xid,
                   boolean onePhase)
            throws XAException
Specified by:
commit in interface XAResource
Throws:
XAException

rollback

public void rollback(Xid xid)
              throws XAException
Specified by:
rollback in interface XAResource
Throws:
XAException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/package-summary.html0000644000175000017500000002035612215446622024767 0ustar tonytony bitronix.tm.resource.jms.lrc (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.resource.jms.lrc

XAConnectionFactory emulator using Last Resource Commit on an underlying non-XA ConnectionFactory.

See:
          Description

Class Summary
LrcXAConnection XAConnection implementation for a non-XA JMS resource emulating XA with Last Resource Commit.
LrcXAConnectionFactory XAConnectionFactory implementation for a non-XA JMS resource emulating XA with Last Resource Commit.
LrcXAResource XAResource implementation for a non-XA JMS connection emulating XA with Last Resource Commit.
LrcXASession XASession implementation for a non-XA JMS resource emulating XA with Last Resource Commit.
 

Package bitronix.tm.resource.jms.lrc Description

XAConnectionFactory emulator using Last Resource Commit on an underlying non-XA ConnectionFactory. Note that if you use the classes of this package you have accepted the heuristic hazard. A crash during commit of a connection returned by this connection factory could lead to an inconsistent global state. This is a limitation of the Last Resource Commit technique, not of BTM.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/lrc/LrcXAConnection.html0000644000175000017500000006163512215446622024677 0ustar tonytony LrcXAConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms.lrc
Class LrcXAConnection

java.lang.Object
  extended by bitronix.tm.resource.jms.lrc.LrcXAConnection
All Implemented Interfaces:
javax.jms.Connection, javax.jms.XAConnection

public class LrcXAConnection
extends Object
implements javax.jms.XAConnection

XAConnection implementation for a non-XA JMS resource emulating XA with Last Resource Commit.

Author:
lorban

Constructor Summary
LrcXAConnection(javax.jms.Connection connection)
           
 
Method Summary
 void close()
           
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, String messageSelector, javax.jms.ServerSessionPool serverSessionPool, int maxMessages)
           
 javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, String subscriptionName, String messageSelector, javax.jms.ServerSessionPool serverSessionPool, int maxMessages)
           
 javax.jms.Session createSession(boolean transacted, int acknowledgeMode)
           
 javax.jms.XASession createXASession()
           
 String getClientID()
           
 javax.jms.ExceptionListener getExceptionListener()
           
 javax.jms.ConnectionMetaData getMetaData()
           
 void setClientID(String clientID)
           
 void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LrcXAConnection

public LrcXAConnection(javax.jms.Connection connection)
Method Detail

createXASession

public javax.jms.XASession createXASession()
                                    throws javax.jms.JMSException
Specified by:
createXASession in interface javax.jms.XAConnection
Throws:
javax.jms.JMSException

createSession

public javax.jms.Session createSession(boolean transacted,
                                       int acknowledgeMode)
                                throws javax.jms.JMSException
Specified by:
createSession in interface javax.jms.Connection
Specified by:
createSession in interface javax.jms.XAConnection
Throws:
javax.jms.JMSException

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                             String messageSelector,
                                                             javax.jms.ServerSessionPool serverSessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Specified by:
createConnectionConsumer in interface javax.jms.Connection
Throws:
javax.jms.JMSException

createDurableConnectionConsumer

public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic,
                                                                    String subscriptionName,
                                                                    String messageSelector,
                                                                    javax.jms.ServerSessionPool serverSessionPool,
                                                                    int maxMessages)
                                                             throws javax.jms.JMSException
Specified by:
createDurableConnectionConsumer in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getClientID

public String getClientID()
                   throws javax.jms.JMSException
Specified by:
getClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

setClientID

public void setClientID(String clientID)
                 throws javax.jms.JMSException
Specified by:
setClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getMetaData

public javax.jms.ConnectionMetaData getMetaData()
                                         throws javax.jms.JMSException
Specified by:
getMetaData in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
                                                 throws javax.jms.JMSException
Specified by:
getExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
                          throws javax.jms.JMSException
Specified by:
setExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

start

public void start()
           throws javax.jms.JMSException
Specified by:
start in interface javax.jms.Connection
Throws:
javax.jms.JMSException

stop

public void stop()
          throws javax.jms.JMSException
Specified by:
stop in interface javax.jms.Connection
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Specified by:
close in interface javax.jms.Connection
Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/0000755000175000017500000000000012215446622022124 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/MessageProducerWrapper.html0000644000175000017500000001416512215446622027452 0ustar tonytony Uses of Class bitronix.tm.resource.jms.MessageProducerWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.MessageProducerWrapper

No usage of bitronix.tm.resource.jms.MessageProducerWrapper



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/JmsPooledConnection.html0000644000175000017500000002321112215446622026725 0ustar tonytony Uses of Class bitronix.tm.resource.jms.JmsPooledConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.JmsPooledConnection

Packages that use JmsPooledConnection
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of JmsPooledConnection in bitronix.tm.resource.jms
 

Methods in bitronix.tm.resource.jms that return JmsPooledConnection
 JmsPooledConnection JmsConnectionHandle.getPooledConnection()
           
 

Constructors in bitronix.tm.resource.jms with parameters of type JmsPooledConnection
DualSessionWrapper(JmsPooledConnection pooledConnection, boolean transacted, int acknowledgeMode)
           
JmsConnectionHandle(JmsPooledConnection pooledConnection, javax.jms.XAConnection xaConnection)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/PoolingConnectionFactoryMBean.html0000644000175000017500000002033112215446622030673 0ustar tonytony Uses of Interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.jms.PoolingConnectionFactoryMBean

Packages that use PoolingConnectionFactoryMBean
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of PoolingConnectionFactoryMBean in bitronix.tm.resource.jms
 

Classes in bitronix.tm.resource.jms that implement PoolingConnectionFactoryMBean
 class PoolingConnectionFactory
          Implementation of a JMS ConnectionFactory wrapping vendor's XAConnectionFactory implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/JndiXAConnectionFactory.html0000644000175000017500000001417712215446622027511 0ustar tonytony Uses of Class bitronix.tm.resource.jms.JndiXAConnectionFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.JndiXAConnectionFactory

No usage of bitronix.tm.resource.jms.JndiXAConnectionFactory



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/DualSessionWrapper.html0000644000175000017500000002666212215446622026620 0ustar tonytony Uses of Class bitronix.tm.resource.jms.DualSessionWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.DualSessionWrapper

Packages that use DualSessionWrapper
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of DualSessionWrapper in bitronix.tm.resource.jms
 

Fields in bitronix.tm.resource.jms declared as DualSessionWrapper
protected  DualSessionWrapper MessageProducerWrapper.session
           
protected  DualSessionWrapper MessageConsumerWrapper.session
           
 

Constructors in bitronix.tm.resource.jms with parameters of type DualSessionWrapper
MessageConsumerWrapper(javax.jms.MessageConsumer messageConsumer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
MessageProducerWrapper(javax.jms.MessageProducer messageProducer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
TopicSubscriberWrapper(javax.jms.TopicSubscriber topicSubscriber, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/MessageProducerConsumerKey.html0000644000175000017500000001423512215446622030274 0ustar tonytony Uses of Class bitronix.tm.resource.jms.MessageProducerConsumerKey (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.MessageProducerConsumerKey

No usage of bitronix.tm.resource.jms.MessageProducerConsumerKey



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/JmsPooledConnectionMBean.html0000644000175000017500000002016012215446622027630 0ustar tonytony Uses of Interface bitronix.tm.resource.jms.JmsPooledConnectionMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.jms.JmsPooledConnectionMBean

Packages that use JmsPooledConnectionMBean
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of JmsPooledConnectionMBean in bitronix.tm.resource.jms
 

Classes in bitronix.tm.resource.jms that implement JmsPooledConnectionMBean
 class JmsPooledConnection
          Implementation of a JMS pooled connection wrapping vendor's XAConnection implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/PoolingConnectionFactory.html0000644000175000017500000003026212215446622027774 0ustar tonytony Uses of Class bitronix.tm.resource.jms.PoolingConnectionFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.PoolingConnectionFactory

Packages that use PoolingConnectionFactory
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of PoolingConnectionFactory in bitronix.tm.resource.jms
 

Methods in bitronix.tm.resource.jms that return PoolingConnectionFactory
 PoolingConnectionFactory JmsPooledConnection.getPoolingConnectionFactory()
           
 PoolingConnectionFactory DualSessionWrapper.getPoolingConnectionFactory()
           
 

Constructors in bitronix.tm.resource.jms with parameters of type PoolingConnectionFactory
JmsPooledConnection(PoolingConnectionFactory poolingConnectionFactory, javax.jms.XAConnection connection)
           
MessageConsumerWrapper(javax.jms.MessageConsumer messageConsumer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
MessageProducerWrapper(javax.jms.MessageProducer messageProducer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
TopicSubscriberWrapper(javax.jms.TopicSubscriber topicSubscriber, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/TopicSubscriberWrapper.html0000644000175000017500000001416512215446622027464 0ustar tonytony Uses of Class bitronix.tm.resource.jms.TopicSubscriberWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.TopicSubscriberWrapper

No usage of bitronix.tm.resource.jms.TopicSubscriberWrapper



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/MessageConsumerWrapper.html0000644000175000017500000002002112215446622027446 0ustar tonytony Uses of Class bitronix.tm.resource.jms.MessageConsumerWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.MessageConsumerWrapper

Packages that use MessageConsumerWrapper
bitronix.tm.resource.jms Synchronous JMS specific resource management code. 
 

Uses of MessageConsumerWrapper in bitronix.tm.resource.jms
 

Subclasses of MessageConsumerWrapper in bitronix.tm.resource.jms
 class TopicSubscriberWrapper
          TopicSubscriber wrapper that adds XA enlistment semantics.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/class-use/JmsConnectionHandle.html0000644000175000017500000001412712215446622026704 0ustar tonytony Uses of Class bitronix.tm.resource.jms.JmsConnectionHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jms.JmsConnectionHandle

No usage of bitronix.tm.resource.jms.JmsConnectionHandle



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/DualSessionWrapper.html0000644000175000017500000020623512215446622024715 0ustar tonytony DualSessionWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class DualSessionWrapper

java.lang.Object
  extended by bitronix.tm.resource.common.AbstractXAStatefulHolder
      extended by bitronix.tm.resource.common.AbstractXAResourceHolder
          extended by bitronix.tm.resource.jms.DualSessionWrapper
All Implemented Interfaces:
StateChangeListener, XAResourceHolder, XAStatefulHolder, Runnable, javax.jms.Session

public class DualSessionWrapper
extends AbstractXAResourceHolder
implements javax.jms.Session, StateChangeListener

JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.

Author:
lorban

Field Summary
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Constructor Summary
DualSessionWrapper(JmsPooledConnection pooledConnection, boolean transacted, int acknowledgeMode)
           
 
Method Summary
 void close()
          Close the physical connection that this XAStatefulHolder represents.
 void commit()
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, String messageSelector)
           
 javax.jms.BytesMessage createBytesMessage()
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector, boolean noLocal)
           
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name)
           
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name, String messageSelector, boolean noLocal)
           
 javax.jms.MapMessage createMapMessage()
           
 javax.jms.Message createMessage()
           
 javax.jms.ObjectMessage createObjectMessage()
           
 javax.jms.ObjectMessage createObjectMessage(Serializable serializable)
           
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
           
 javax.jms.Queue createQueue(String queueName)
           
 javax.jms.StreamMessage createStreamMessage()
           
 javax.jms.TemporaryQueue createTemporaryQueue()
           
 javax.jms.TemporaryTopic createTemporaryTopic()
           
 javax.jms.TextMessage createTextMessage()
           
 javax.jms.TextMessage createTextMessage(String text)
           
 javax.jms.Topic createTopic(String topicName)
           
protected  void enlistResource()
          Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource.
 int getAcknowledgeMode()
           
 Object getConnectionHandle()
          Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
 Date getLastReleaseDate()
          Get the date at which this object was last released to the pool.
 javax.jms.MessageListener getMessageListener()
           
 PoolingConnectionFactory getPoolingConnectionFactory()
           
 ResourceBean getResourceBean()
          Get the ResourceBean which created this XAResourceHolder.
 javax.jms.Session getSession()
           
 javax.jms.Session getSession(boolean forceXa)
           
 boolean getTransacted()
           
 XAResource getXAResource()
          Get the vendor's XAResource implementation of the wrapped resource.
 List<XAResourceHolder> getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
 void recover()
           
 void rollback()
           
 void run()
           
 void setMessageListener(javax.jms.MessageListener listener)
           
 void stateChanged(XAStatefulHolder source, int oldState, int newState)
          Fired when the internal state of a XAStatefulHolder has changed.
 void stateChanging(XAStatefulHolder source, int currentState, int futureState)
          Fired before the internal state of a XAStatefulHolder has changed.
 String toString()
           
 void unsubscribe(String name)
           
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAResourceHolder
getXAResourceHolderStateGtrids, getXAResourceHolderStatesForGtrid, hasStateForXAResource, isParticipatingInActiveGlobalTransaction, putXAResourceHolderState, removeXAResourceHolderState
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 

Constructor Detail

DualSessionWrapper

public DualSessionWrapper(JmsPooledConnection pooledConnection,
                          boolean transacted,
                          int acknowledgeMode)
Method Detail

getPoolingConnectionFactory

public PoolingConnectionFactory getPoolingConnectionFactory()

getSession

public javax.jms.Session getSession()
                             throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getSession

public javax.jms.Session getSession(boolean forceXa)
                             throws javax.jms.JMSException
Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object

close

public void close()
           throws javax.jms.JMSException
Description copied from interface: XAStatefulHolder
Close the physical connection that this XAStatefulHolder represents.

Specified by:
close in interface XAStatefulHolder
Specified by:
close in interface javax.jms.Session
Throws:
javax.jms.JMSException

getLastReleaseDate

public Date getLastReleaseDate()
Description copied from interface: XAStatefulHolder
Get the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.

Specified by:
getLastReleaseDate in interface XAStatefulHolder
Returns:
the date at which this object was last released to the pool or null if it never left the pool.

stateChanged

public void stateChanged(XAStatefulHolder source,
                         int oldState,
                         int newState)
Description copied from interface: StateChangeListener
Fired when the internal state of a XAStatefulHolder has changed.

Specified by:
stateChanged in interface StateChangeListener
Parameters:
source - the XAStatefulHolder changing state.
oldState - the old state of the XAStatefulHolder.
newState - the new state of the XAStatefulHolder.

stateChanging

public void stateChanging(XAStatefulHolder source,
                          int currentState,
                          int futureState)
Description copied from interface: StateChangeListener
Fired before the internal state of a XAStatefulHolder has changed.

Specified by:
stateChanging in interface StateChangeListener
Parameters:
source - the XAStatefulHolder changing state.
currentState - the current state of the XAStatefulHolder.
futureState - the future state of the XAStatefulHolder.

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Specified by:
createProducer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                String messageSelector)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                String messageSelector,
                                                boolean noLocal)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         String name)
                                                  throws javax.jms.JMSException
Specified by:
createDurableSubscriber in interface javax.jms.Session
Throws:
javax.jms.JMSException

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         String name,
                                                         String messageSelector,
                                                         boolean noLocal)
                                                  throws javax.jms.JMSException
Specified by:
createDurableSubscriber in interface javax.jms.Session
Throws:
javax.jms.JMSException

getMessageListener

public javax.jms.MessageListener getMessageListener()
                                             throws javax.jms.JMSException
Specified by:
getMessageListener in interface javax.jms.Session
Throws:
javax.jms.JMSException

setMessageListener

public void setMessageListener(javax.jms.MessageListener listener)
                        throws javax.jms.JMSException
Specified by:
setMessageListener in interface javax.jms.Session
Throws:
javax.jms.JMSException

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in interface javax.jms.Session

getXAResource

public XAResource getXAResource()
Description copied from interface: XAResourceHolder
Get the vendor's XAResource implementation of the wrapped resource.

Specified by:
getXAResource in interface XAResourceHolder
Returns:
the vendor's XAResource implementation.

getResourceBean

public ResourceBean getResourceBean()
Description copied from interface: XAResourceHolder
Get the ResourceBean which created this XAResourceHolder.

Specified by:
getResourceBean in interface XAResourceHolder
Returns:
the ResourceBean which created this XAResourceHolder.

getXAResourceHolders

public List<XAResourceHolder> getXAResourceHolders()
Description copied from interface: XAStatefulHolder
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.

This method is thread-safe.

Specified by:
getXAResourceHolders in interface XAStatefulHolder
Returns:
the list of XAResourceHolders created by this XAStatefulHolder that are still open.

getConnectionHandle

public Object getConnectionHandle()
                           throws Exception
Description copied from interface: XAStatefulHolder
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.

This method is thread-safe.

Specified by:
getConnectionHandle in interface XAStatefulHolder
Returns:
a resource-specific disaposable connection object.
Throws:
Exception - a resource-specific exception thrown when the disaposable connection cannot be created.

getTransacted

public boolean getTransacted()
                      throws javax.jms.JMSException
Specified by:
getTransacted in interface javax.jms.Session
Throws:
javax.jms.JMSException

getAcknowledgeMode

public int getAcknowledgeMode()
                       throws javax.jms.JMSException
Specified by:
getAcknowledgeMode in interface javax.jms.Session
Throws:
javax.jms.JMSException

commit

public void commit()
            throws javax.jms.JMSException
Specified by:
commit in interface javax.jms.Session
Throws:
javax.jms.JMSException

rollback

public void rollback()
              throws javax.jms.JMSException
Specified by:
rollback in interface javax.jms.Session
Throws:
javax.jms.JMSException

recover

public void recover()
             throws javax.jms.JMSException
Specified by:
recover in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
                                     throws javax.jms.JMSException
Specified by:
createBrowser in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue,
                                            String messageSelector)
                                     throws javax.jms.JMSException
Specified by:
createBrowser in interface javax.jms.Session
Throws:
javax.jms.JMSException

createBytesMessage

public javax.jms.BytesMessage createBytesMessage()
                                          throws javax.jms.JMSException
Specified by:
createBytesMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createMapMessage

public javax.jms.MapMessage createMapMessage()
                                      throws javax.jms.JMSException
Specified by:
createMapMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createMessage

public javax.jms.Message createMessage()
                                throws javax.jms.JMSException
Specified by:
createMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createObjectMessage

public javax.jms.ObjectMessage createObjectMessage()
                                            throws javax.jms.JMSException
Specified by:
createObjectMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createObjectMessage

public javax.jms.ObjectMessage createObjectMessage(Serializable serializable)
                                            throws javax.jms.JMSException
Specified by:
createObjectMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createStreamMessage

public javax.jms.StreamMessage createStreamMessage()
                                            throws javax.jms.JMSException
Specified by:
createStreamMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTextMessage

public javax.jms.TextMessage createTextMessage()
                                        throws javax.jms.JMSException
Specified by:
createTextMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTextMessage

public javax.jms.TextMessage createTextMessage(String text)
                                        throws javax.jms.JMSException
Specified by:
createTextMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createQueue

public javax.jms.Queue createQueue(String queueName)
                            throws javax.jms.JMSException
Specified by:
createQueue in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTopic

public javax.jms.Topic createTopic(String topicName)
                            throws javax.jms.JMSException
Specified by:
createTopic in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTemporaryQueue

public javax.jms.TemporaryQueue createTemporaryQueue()
                                              throws javax.jms.JMSException
Specified by:
createTemporaryQueue in interface javax.jms.Session
Throws:
javax.jms.JMSException

createTemporaryTopic

public javax.jms.TemporaryTopic createTemporaryTopic()
                                              throws javax.jms.JMSException
Specified by:
createTemporaryTopic in interface javax.jms.Session
Throws:
javax.jms.JMSException

unsubscribe

public void unsubscribe(String name)
                 throws javax.jms.JMSException
Specified by:
unsubscribe in interface javax.jms.Session
Throws:
javax.jms.JMSException

enlistResource

protected void enlistResource()
                       throws javax.jms.JMSException
Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource. If no transaction is running then this method does nothing.

Throws:
javax.jms.JMSException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/package-summary.html0000644000175000017500000002447412215446622024214 0ustar tonytony bitronix.tm.resource.jms (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.resource.jms

Synchronous JMS specific resource management code.

See:
          Description

Interface Summary
JmsPooledConnectionMBean JmsPooledConnection Management interface.
PoolingConnectionFactoryMBean  
 

Class Summary
DualSessionWrapper JMS Session wrapper that will send calls to either a XASession or to a non-XA Session depending on the calling context.
JmsConnectionHandle Disposable Connection handle.
JmsPooledConnection Implementation of a JMS pooled connection wrapping vendor's XAConnection implementation.
JndiXAConnectionFactory XAConnectionFactory implementation that wraps another XAConnectionFactory implementation available in some JNDI tree.
MessageConsumerWrapper MessageConsumer wrapper that adds XA enlistment semantics.
MessageProducerConsumerKey JMS destination wrapper optimized for use with hashed collections where it is the key and a MessageProducer or a MessageConsumer is the value.
MessageProducerWrapper MessageProducer wrapper that adds XA enlistment semantics.
PoolingConnectionFactory Implementation of a JMS ConnectionFactory wrapping vendor's XAConnectionFactory implementation.
TopicSubscriberWrapper TopicSubscriber wrapper that adds XA enlistment semantics.
 

Package bitronix.tm.resource.jms Description

Synchronous JMS specific resource management code.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/MessageProducerConsumerKey.html0000644000175000017500000004105012215446622026370 0ustar tonytony MessageProducerConsumerKey (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class MessageProducerConsumerKey

java.lang.Object
  extended by bitronix.tm.resource.jms.MessageProducerConsumerKey

public class MessageProducerConsumerKey
extends Object

JMS destination wrapper optimized for use with hashed collections where it is the key and a MessageProducer or a MessageConsumer is the value.

Author:
lorban

Constructor Summary
MessageProducerConsumerKey(javax.jms.Destination destination)
           
MessageProducerConsumerKey(javax.jms.Destination destination, String messageSelector)
           
MessageProducerConsumerKey(javax.jms.Destination destination, String messageSelector, boolean noLocal)
           
 
Method Summary
 boolean equals(Object obj)
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageProducerConsumerKey

public MessageProducerConsumerKey(javax.jms.Destination destination)

MessageProducerConsumerKey

public MessageProducerConsumerKey(javax.jms.Destination destination,
                                  String messageSelector)

MessageProducerConsumerKey

public MessageProducerConsumerKey(javax.jms.Destination destination,
                                  String messageSelector,
                                  boolean noLocal)
Method Detail

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/JmsPooledConnectionMBean.html0000644000175000017500000002563012215446622025740 0ustar tonytony JmsPooledConnectionMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Interface JmsPooledConnectionMBean

All Known Implementing Classes:
JmsPooledConnection

public interface JmsPooledConnectionMBean

JmsPooledConnection Management interface.

Author:
lorban

Method Summary
 Date getAcquisitionDate()
           
 String getStateDescription()
           
 Collection<String> getTransactionGtridsCurrentlyHoldingThis()
           
 

Method Detail

getStateDescription

String getStateDescription()

getAcquisitionDate

Date getAcquisitionDate()

getTransactionGtridsCurrentlyHoldingThis

Collection<String> getTransactionGtridsCurrentlyHoldingThis()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/PoolingConnectionFactory.html0000644000175000017500000014340112215446622026075 0ustar tonytony PoolingConnectionFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class PoolingConnectionFactory

java.lang.Object
  extended by bitronix.tm.resource.common.ResourceBean
      extended by bitronix.tm.resource.jms.PoolingConnectionFactory
All Implemented Interfaces:
XAResourceProducer, PoolingConnectionFactoryMBean, Serializable, javax.jms.ConnectionFactory, Referenceable

public class PoolingConnectionFactory
extends ResourceBean
implements javax.jms.ConnectionFactory, XAResourceProducer, PoolingConnectionFactoryMBean

Implementation of a JMS ConnectionFactory wrapping vendor's XAConnectionFactory implementation.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
PoolingConnectionFactory()
           
 
Method Summary
 void close()
          Release this XAResourceProducer's internal resources.
 javax.jms.Connection createConnection()
           
 javax.jms.Connection createConnection(String userName, String password)
           
 XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 void endRecovery()
          Release internal resources held after call to startRecovery().
 XAResourceHolder findXAResourceHolder(XAResource xaResource)
          Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
 boolean getCacheProducersConsumers()
           
 long getInPoolSize()
           
 String getPassword()
           
 Reference getReference()
          PoolingConnectionFactory must alway have a unique name so this method builds a reference to this object using the unique name as RefAddr.
 boolean getTestConnections()
           
 long getTotalPoolSize()
           
 String getUser()
           
 void init()
          Initialize the pool by creating the initial amount of connections.
 boolean isFailed()
           
 void reset()
           
 void setCacheProducersConsumers(boolean cacheProducersConsumers)
           
 void setFailed(boolean failed)
          Mark this resource producer as failed or not.
 void setPassword(String password)
           
 void setTestConnections(boolean testConnections)
           
 void setUser(String user)
           
 XAResourceHolderState startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 String toString()
           
 
Methods inherited from class bitronix.tm.resource.common.ResourceBean
getAcquireIncrement, getAcquisitionInterval, getAcquisitionTimeout, getAllowLocalTransactions, getApplyTransactionTimeout, getAutomaticEnlistingEnabled, getClassName, getDeferConnectionRelease, getDriverProperties, getIgnoreRecoveryFailures, getMaxIdleTime, getMaxPoolSize, getMinPoolSize, getShareTransactionConnections, getTwoPcOrderingPosition, getUniqueName, getUseTmJoin, incCreatedResourcesCounter, isDisabled, setAcquireIncrement, setAcquisitionInterval, setAcquisitionTimeout, setAllowLocalTransactions, setApplyTransactionTimeout, setAutomaticEnlistingEnabled, setClassName, setDeferConnectionRelease, setDisabled, setDriverProperties, setIgnoreRecoveryFailures, setMaxIdleTime, setMaxPoolSize, setMinPoolSize, setShareTransactionConnections, setTwoPcOrderingPosition, setUniqueName, setUseTmJoin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAResourceProducer
getUniqueName
 
Methods inherited from interface bitronix.tm.resource.jms.PoolingConnectionFactoryMBean
getMaxPoolSize, getMinPoolSize, isDisabled, setDisabled
 

Constructor Detail

PoolingConnectionFactory

public PoolingConnectionFactory()
Method Detail

init

public void init()
Initialize the pool by creating the initial amount of connections.

Specified by:
init in interface XAResourceProducer

getCacheProducersConsumers

public boolean getCacheProducersConsumers()

setCacheProducersConsumers

public void setCacheProducersConsumers(boolean cacheProducersConsumers)

getTestConnections

public boolean getTestConnections()

setTestConnections

public void setTestConnections(boolean testConnections)

getUser

public String getUser()

setUser

public void setUser(String user)

getPassword

public String getPassword()

setPassword

public void setPassword(String password)

createConnection

public javax.jms.Connection createConnection()
                                      throws javax.jms.JMSException
Specified by:
createConnection in interface javax.jms.ConnectionFactory
Throws:
javax.jms.JMSException

createConnection

public javax.jms.Connection createConnection(String userName,
                                             String password)
                                      throws javax.jms.JMSException
Specified by:
createConnection in interface javax.jms.ConnectionFactory
Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object

startRecovery

public XAResourceHolderState startRecovery()
                                    throws RecoveryException
Description copied from interface: XAResourceProducer
Prepare the recoverable XAResource producer for recovery.

Specified by:
startRecovery in interface XAResourceProducer
Returns:
a XAResourceHolderState object that can be used to call recover().
Throws:
RecoveryException - thrown when a XAResourceHolderState cannot be acquired.

endRecovery

public void endRecovery()
                 throws RecoveryException
Description copied from interface: XAResourceProducer
Release internal resources held after call to startRecovery().

Specified by:
endRecovery in interface XAResourceProducer
Throws:
RecoveryException - thrown when an error occured while releasing reserved resources.

setFailed

public void setFailed(boolean failed)
Description copied from interface: XAResourceProducer
Mark this resource producer as failed or not. A resource is considered failed if recovery fails to run on it.

Specified by:
setFailed in interface XAResourceProducer
Parameters:
failed - true is the resource must be considered failed, false it it must be considered sane.

isFailed

public boolean isFailed()
Specified by:
isFailed in interface PoolingConnectionFactoryMBean

close

public void close()
Description copied from interface: XAResourceProducer
Release this XAResourceProducer's internal resources.

Specified by:
close in interface XAResourceProducer

createPooledConnection

public XAStatefulHolder createPooledConnection(Object xaFactory,
                                               ResourceBean bean)
                                        throws Exception
Description copied from interface: XAResourceProducer
Create a XAStatefulHolder that will be placed in an XAPool.

Specified by:
createPooledConnection in interface XAResourceProducer
Parameters:
xaFactory - the vendor's resource-specific XA factory.
bean - the resource-specific bean describing the resource parameters.
Returns:
a XAStatefulHolder that will be placed in an XAPool.
Throws:
Exception - thrown when the XAStatefulHolder cannot be created.

findXAResourceHolder

public XAResourceHolder findXAResourceHolder(XAResource xaResource)
Description copied from interface: XAResourceProducer
Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.

Specified by:
findXAResourceHolder in interface XAResourceProducer
Parameters:
xaResource - the XAResource to look for.
Returns:
the associated XAResourceHolder or null if the XAResource does not belong to this XAResourceProducer.

getReference

public Reference getReference()
                       throws NamingException
PoolingConnectionFactory must alway have a unique name so this method builds a reference to this object using the unique name as RefAddr.

Specified by:
getReference in interface Referenceable
Returns:
a reference to this PoolingConnectionFactory.
Throws:
NamingException

getInPoolSize

public long getInPoolSize()
Specified by:
getInPoolSize in interface PoolingConnectionFactoryMBean

getTotalPoolSize

public long getTotalPoolSize()
Specified by:
getTotalPoolSize in interface PoolingConnectionFactoryMBean

reset

public void reset()
           throws Exception
Specified by:
reset in interface PoolingConnectionFactoryMBean
Throws:
Exception


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/TopicSubscriberWrapper.html0000644000175000017500000004435612215446622025572 0ustar tonytony TopicSubscriberWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class TopicSubscriberWrapper

java.lang.Object
  extended by bitronix.tm.resource.jms.MessageConsumerWrapper
      extended by bitronix.tm.resource.jms.TopicSubscriberWrapper
All Implemented Interfaces:
javax.jms.MessageConsumer, javax.jms.TopicSubscriber

public class TopicSubscriberWrapper
extends MessageConsumerWrapper
implements javax.jms.TopicSubscriber

TopicSubscriber wrapper that adds XA enlistment semantics.

Author:
lorban

Field Summary
 
Fields inherited from class bitronix.tm.resource.jms.MessageConsumerWrapper
session
 
Constructor Summary
TopicSubscriberWrapper(javax.jms.TopicSubscriber topicSubscriber, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
 
Method Summary
 boolean getNoLocal()
           
 javax.jms.Topic getTopic()
           
 String toString()
           
 
Methods inherited from class bitronix.tm.resource.jms.MessageConsumerWrapper
close, enlistResource, getMessageConsumer, getMessageListener, getMessageSelector, receive, receive, receiveNoWait, setMessageListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jms.MessageConsumer
close, getMessageListener, getMessageSelector, receive, receive, receiveNoWait, setMessageListener
 

Constructor Detail

TopicSubscriberWrapper

public TopicSubscriberWrapper(javax.jms.TopicSubscriber topicSubscriber,
                              DualSessionWrapper session,
                              PoolingConnectionFactory poolingConnectionFactory)
Method Detail

getTopic

public javax.jms.Topic getTopic()
                         throws javax.jms.JMSException
Specified by:
getTopic in interface javax.jms.TopicSubscriber
Throws:
javax.jms.JMSException

getNoLocal

public boolean getNoLocal()
                   throws javax.jms.JMSException
Specified by:
getNoLocal in interface javax.jms.TopicSubscriber
Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class MessageConsumerWrapper


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/MessageConsumerWrapper.html0000644000175000017500000005471012215446622025563 0ustar tonytony MessageConsumerWrapper (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class MessageConsumerWrapper

java.lang.Object
  extended by bitronix.tm.resource.jms.MessageConsumerWrapper
All Implemented Interfaces:
javax.jms.MessageConsumer
Direct Known Subclasses:
TopicSubscriberWrapper

public class MessageConsumerWrapper
extends Object
implements javax.jms.MessageConsumer

MessageConsumer wrapper that adds XA enlistment semantics.

Author:
lorban

Field Summary
protected  DualSessionWrapper session
           
 
Constructor Summary
MessageConsumerWrapper(javax.jms.MessageConsumer messageConsumer, DualSessionWrapper session, PoolingConnectionFactory poolingConnectionFactory)
           
 
Method Summary
 void close()
           
protected  void enlistResource()
          Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource.
 javax.jms.MessageConsumer getMessageConsumer()
           
 javax.jms.MessageListener getMessageListener()
           
 String getMessageSelector()
           
 javax.jms.Message receive()
           
 javax.jms.Message receive(long timeout)
           
 javax.jms.Message receiveNoWait()
           
 void setMessageListener(javax.jms.MessageListener listener)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

session

protected final DualSessionWrapper session
Constructor Detail

MessageConsumerWrapper

public MessageConsumerWrapper(javax.jms.MessageConsumer messageConsumer,
                              DualSessionWrapper session,
                              PoolingConnectionFactory poolingConnectionFactory)
Method Detail

getMessageConsumer

public javax.jms.MessageConsumer getMessageConsumer()

enlistResource

protected void enlistResource()
                       throws javax.jms.JMSException
Enlist this session into the current transaction if automaticEnlistingEnabled = true for this resource. If no transaction is running then this method does nothing.

Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object

receive

public javax.jms.Message receive()
                          throws javax.jms.JMSException
Specified by:
receive in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

receive

public javax.jms.Message receive(long timeout)
                          throws javax.jms.JMSException
Specified by:
receive in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

receiveNoWait

public javax.jms.Message receiveNoWait()
                                throws javax.jms.JMSException
Specified by:
receiveNoWait in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Specified by:
close in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

getMessageSelector

public String getMessageSelector()
                          throws javax.jms.JMSException
Specified by:
getMessageSelector in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

getMessageListener

public javax.jms.MessageListener getMessageListener()
                                             throws javax.jms.JMSException
Specified by:
getMessageListener in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException

setMessageListener

public void setMessageListener(javax.jms.MessageListener listener)
                        throws javax.jms.JMSException
Specified by:
setMessageListener in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jms/JmsConnectionHandle.html0000644000175000017500000006401712215446622025010 0ustar tonytony JmsConnectionHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jms
Class JmsConnectionHandle

java.lang.Object
  extended by bitronix.tm.resource.jms.JmsConnectionHandle
All Implemented Interfaces:
javax.jms.Connection

public class JmsConnectionHandle
extends Object
implements javax.jms.Connection

Disposable Connection handle.

Author:
lorban

Constructor Summary
JmsConnectionHandle(JmsPooledConnection pooledConnection, javax.jms.XAConnection xaConnection)
           
 
Method Summary
 void close()
           
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
           
 javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, String subscriptionName, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
           
 javax.jms.Session createSession(boolean transacted, int acknowledgeMode)
           
 String getClientID()
           
 javax.jms.ExceptionListener getExceptionListener()
           
 javax.jms.ConnectionMetaData getMetaData()
           
 JmsPooledConnection getPooledConnection()
           
 javax.jms.XAConnection getXAConnection()
           
 void setClientID(String jndiName)
           
 void setExceptionListener(javax.jms.ExceptionListener listener)
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JmsConnectionHandle

public JmsConnectionHandle(JmsPooledConnection pooledConnection,
                           javax.jms.XAConnection xaConnection)
Method Detail

getXAConnection

public javax.jms.XAConnection getXAConnection()
                                       throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getPooledConnection

public JmsPooledConnection getPooledConnection()

createSession

public javax.jms.Session createSession(boolean transacted,
                                       int acknowledgeMode)
                                throws javax.jms.JMSException
Specified by:
createSession in interface javax.jms.Connection
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Specified by:
close in interface javax.jms.Connection
Throws:
javax.jms.JMSException

toString

public String toString()
Overrides:
toString in class Object

getClientID

public String getClientID()
                   throws javax.jms.JMSException
Specified by:
getClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

setClientID

public void setClientID(String jndiName)
                 throws javax.jms.JMSException
Specified by:
setClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getMetaData

public javax.jms.ConnectionMetaData getMetaData()
                                         throws javax.jms.JMSException
Specified by:
getMetaData in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
                                                 throws javax.jms.JMSException
Specified by:
getExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener listener)
                          throws javax.jms.JMSException
Specified by:
setExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

start

public void start()
           throws javax.jms.JMSException
Specified by:
start in interface javax.jms.Connection
Throws:
javax.jms.JMSException

stop

public void stop()
          throws javax.jms.JMSException
Specified by:
stop in interface javax.jms.Connection
Throws:
javax.jms.JMSException

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                             String messageSelector,
                                                             javax.jms.ServerSessionPool sessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Specified by:
createConnectionConsumer in interface javax.jms.Connection
Throws:
javax.jms.JMSException

createDurableConnectionConsumer

public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic,
                                                                    String subscriptionName,
                                                                    String messageSelector,
                                                                    javax.jms.ServerSessionPool sessionPool,
                                                                    int maxMessages)
                                                             throws javax.jms.JMSException
Specified by:
createDurableConnectionConsumer in interface javax.jms.Connection
Throws:
javax.jms.JMSException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ResourceLoader.html0000644000175000017500000004006212215446622023242 0ustar tonytony ResourceLoader (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource
Class ResourceLoader

java.lang.Object
  extended by bitronix.tm.resource.ResourceLoader
All Implemented Interfaces:
Service

public class ResourceLoader
extends Object
implements Service

XA resources pools configurator & loader.

ResourceLoader relies on the optional bitronix.tm.resource.configuration propery to load the JDBC datasources (PoolingDataSource) and JMS connection factories (PoolingConnectionFactory) configuration file and create the resources.

When bitronix.tm.resource.configuration is not specified, ResourceLoader is disabled and resources should be manually created.

Author:
lorban

Constructor Summary
ResourceLoader()
           
 
Method Summary
 Map<String,XAResourceProducer> getResources()
          Get a Map with the configured uniqueName as key and XAResourceProducer as value.
 int init()
          Initialize the ResourceLoader and load the resources configuration file specified in bitronix.tm.resource.configuration property.
 void shutdown()
          Shutdown the service and free all held resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLoader

public ResourceLoader()
Method Detail

getResources

public Map<String,XAResourceProducer> getResources()
Get a Map with the configured uniqueName as key and XAResourceProducer as value.

Returns:
a Map using the uniqueName as key and XAResourceProducer as value.

init

public int init()
Initialize the ResourceLoader and load the resources configuration file specified in bitronix.tm.resource.configuration property.

Returns:
the number of resources which failed to initialize.

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/class-use/0000755000175000017500000000000012215446622021333 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/class-use/ResourceRegistrar.html0000644000175000017500000001375012215446622025701 0ustar tonytony Uses of Class bitronix.tm.resource.ResourceRegistrar (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.ResourceRegistrar

No usage of bitronix.tm.resource.ResourceRegistrar



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/class-use/ResourceObjectFactory.html0000644000175000017500000001402012215446622026464 0ustar tonytony Uses of Class bitronix.tm.resource.ResourceObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.ResourceObjectFactory

No usage of bitronix.tm.resource.ResourceObjectFactory



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/class-use/ResourceLoader.html0000644000175000017500000001742012215446622025143 0ustar tonytony Uses of Class bitronix.tm.resource.ResourceLoader (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.ResourceLoader

Packages that use ResourceLoader
bitronix.tm JTA interfaces implementations and global services. 
 

Uses of ResourceLoader in bitronix.tm
 

Methods in bitronix.tm that return ResourceLoader
static ResourceLoader TransactionManagerServices.getResourceLoader()
          Create the resource loader.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/class-use/ResourceConfigurationException.html0000644000175000017500000001415212215446622030422 0ustar tonytony Uses of Class bitronix.tm.resource.ResourceConfigurationException (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.ResourceConfigurationException

No usage of bitronix.tm.resource.ResourceConfigurationException



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/package-summary.html0000644000175000017500000001775612215446622023430 0ustar tonytony bitronix.tm.resource (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.resource

Transaction Manager's resource management services.

See:
          Description

Class Summary
ResourceLoader XA resources pools configurator & loader.
ResourceObjectFactory XAResourceProducer object factory for JNDI references.
ResourceRegistrar Collection of initialized XAResourceProducers.
 

Exception Summary
ResourceConfigurationException Thrown when a resource cannot be created due to a configuration error.
 

Package bitronix.tm.resource Description

Transaction Manager's resource management services.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/ResourceConfigurationException.html0000644000175000017500000003752412215446622026533 0ustar tonytony ResourceConfigurationException (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource
Class ResourceConfigurationException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by bitronix.tm.resource.ResourceConfigurationException
All Implemented Interfaces:
Serializable

public class ResourceConfigurationException
extends RuntimeException

Thrown when a resource cannot be created due to a configuration error.

Author:
lorban
See Also:
Serialized Form

Constructor Summary
ResourceConfigurationException(String s)
           
ResourceConfigurationException(String message, Throwable cause)
           
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceConfigurationException

public ResourceConfigurationException(String message,
                                      Throwable cause)

ResourceConfigurationException

public ResourceConfigurationException(String s)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/0000755000175000017500000000000012215446622020336 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/LruEvictionListener.html0000644000175000017500000002140212215446622025174 0ustar tonytony LruEvictionListener (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Interface LruEvictionListener


public interface LruEvictionListener

Eviction listener interface for LruStatementCache.

Author:
lorban

Method Summary
 void onEviction(Object value)
           
 

Method Detail

onEviction

void onEviction(Object value)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/package-frame.html0000644000175000017500000000565412215446622023721 0ustar tonytony bitronix.tm.resource.jdbc (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.resource.jdbc
Interfaces 
ConnectionCustomizer
JdbcPooledConnectionMBean
LruEvictionListener
PoolingDataSourceMBean
Classes 
BaseProxyHandlerClass
JdbcCallableStatementHandle
JdbcConnectionHandle
JdbcPooledConnection
JdbcPreparedStatementHandle
JdbcResultSetHandle
JdbcStatementHandle
JdbcUncachedPreparedStatementHandle
LruStatementCache
PoolingDataSource
btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcPooledConnectionMBean.html0000644000175000017500000002523712215446622026165 0ustar tonytony JdbcPooledConnectionMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Interface JdbcPooledConnectionMBean

All Known Implementing Classes:
JdbcPooledConnection

public interface JdbcPooledConnectionMBean

JdbcPooledConnection Management interface.

Author:
lorban

Method Summary
 Date getAcquisitionDate()
           
 String getStateDescription()
           
 Collection getTransactionGtridsCurrentlyHoldingThis()
           
 

Method Detail

getStateDescription

String getStateDescription()

getAcquisitionDate

Date getAcquisitionDate()

getTransactionGtridsCurrentlyHoldingThis

Collection getTransactionGtridsCurrentlyHoldingThis()


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcPooledConnection.html0000644000175000017500000014155712215446622025266 0ustar tonytony JdbcPooledConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class JdbcPooledConnection

java.lang.Object
  extended by bitronix.tm.resource.common.AbstractXAStatefulHolder
      extended by bitronix.tm.resource.common.AbstractXAResourceHolder
          extended by bitronix.tm.resource.jdbc.JdbcPooledConnection
All Implemented Interfaces:
StateChangeListener, XAResourceHolder, XAStatefulHolder, JdbcPooledConnectionMBean

public class JdbcPooledConnection
extends AbstractXAResourceHolder
implements StateChangeListener, JdbcPooledConnectionMBean

Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.

Author:
lorban, brettw

Field Summary
 
Fields inherited from interface bitronix.tm.resource.common.XAStatefulHolder
STATE_ACCESSIBLE, STATE_CLOSED, STATE_IN_POOL, STATE_NOT_ACCESSIBLE
 
Constructor Summary
JdbcPooledConnection(PoolingDataSource poolingDataSource, XAConnection xaConnection)
           
 
Method Summary
 void close()
          Close the physical connection that this XAStatefulHolder represents.
 RecoveryXAResourceHolder createRecoveryXAResourceHolder()
           
 Date getAcquisitionDate()
           
protected  JdbcPreparedStatementHandle getCachedStatement(JdbcPreparedStatementHandle stmt)
          Get a PreparedStatement from cache.
 Object getConnectionHandle()
          Create a disposable handler used to drive a pooled instance of XAStatefulHolder.
 Date getLastReleaseDate()
          Get the date at which this object was last released to the pool.
 PoolingDataSource getPoolingDataSource()
           
 ResourceBean getResourceBean()
          Get the ResourceBean which created this XAResourceHolder.
 String getStateDescription()
           
 Collection getTransactionGtridsCurrentlyHoldingThis()
           
 XAResource getXAResource()
          Get the vendor's XAResource implementation of the wrapped resource.
 List<XAResourceHolder> getXAResourceHolders()
          Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.
protected  JdbcPreparedStatementHandle putCachedStatement(JdbcPreparedStatementHandle stmt)
          Put a PreparedStatement in the cache.
protected  Statement registerUncachedStatement(Statement stmt)
          Register uncached statement so that it can be closed when the connection is put back in the pool.
protected  void release()
           
 void stateChanged(XAStatefulHolder source, int oldState, int newState)
          Fired when the internal state of a XAStatefulHolder has changed.
 void stateChanging(XAStatefulHolder source, int currentState, int futureState)
          Fired before the internal state of a XAStatefulHolder has changed.
 String toString()
           
protected  void unregisterUncachedStatement(Statement stmt)
           
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAResourceHolder
getXAResourceHolderStateGtrids, getXAResourceHolderStatesForGtrid, hasStateForXAResource, isParticipatingInActiveGlobalTransaction, putXAResourceHolderState, removeXAResourceHolderState
 
Methods inherited from class bitronix.tm.resource.common.AbstractXAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAStatefulHolder
addStateChangeEventListener, getState, removeStateChangeEventListener, setState
 

Constructor Detail

JdbcPooledConnection

public JdbcPooledConnection(PoolingDataSource poolingDataSource,
                            XAConnection xaConnection)
                     throws SQLException
Throws:
SQLException
Method Detail

close

public void close()
           throws SQLException
Description copied from interface: XAStatefulHolder
Close the physical connection that this XAStatefulHolder represents.

Specified by:
close in interface XAStatefulHolder
Throws:
SQLException

createRecoveryXAResourceHolder

public RecoveryXAResourceHolder createRecoveryXAResourceHolder()

release

protected void release()
                throws SQLException
Throws:
SQLException

getXAResource

public XAResource getXAResource()
Description copied from interface: XAResourceHolder
Get the vendor's XAResource implementation of the wrapped resource.

Specified by:
getXAResource in interface XAResourceHolder
Returns:
the vendor's XAResource implementation.

getResourceBean

public ResourceBean getResourceBean()
Description copied from interface: XAResourceHolder
Get the ResourceBean which created this XAResourceHolder.

Specified by:
getResourceBean in interface XAResourceHolder
Returns:
the ResourceBean which created this XAResourceHolder.

getPoolingDataSource

public PoolingDataSource getPoolingDataSource()

getXAResourceHolders

public List<XAResourceHolder> getXAResourceHolders()
Description copied from interface: XAStatefulHolder
Get the list of XAResourceHolders created by this XAStatefulHolder that are still open.

This method is thread-safe.

Specified by:
getXAResourceHolders in interface XAStatefulHolder
Returns:
the list of XAResourceHolders created by this XAStatefulHolder that are still open.

getConnectionHandle

public Object getConnectionHandle()
                           throws Exception
Description copied from interface: XAStatefulHolder
Create a disposable handler used to drive a pooled instance of XAStatefulHolder.

This method is thread-safe.

Specified by:
getConnectionHandle in interface XAStatefulHolder
Returns:
a resource-specific disaposable connection object.
Throws:
Exception - a resource-specific exception thrown when the disaposable connection cannot be created.

stateChanged

public void stateChanged(XAStatefulHolder source,
                         int oldState,
                         int newState)
Description copied from interface: StateChangeListener
Fired when the internal state of a XAStatefulHolder has changed.

Specified by:
stateChanged in interface StateChangeListener
Parameters:
source - the XAStatefulHolder changing state.
oldState - the old state of the XAStatefulHolder.
newState - the new state of the XAStatefulHolder.

stateChanging

public void stateChanging(XAStatefulHolder source,
                          int currentState,
                          int futureState)
Description copied from interface: StateChangeListener
Fired before the internal state of a XAStatefulHolder has changed.

Specified by:
stateChanging in interface StateChangeListener
Parameters:
source - the XAStatefulHolder changing state.
currentState - the current state of the XAStatefulHolder.
futureState - the future state of the XAStatefulHolder.

getCachedStatement

protected JdbcPreparedStatementHandle getCachedStatement(JdbcPreparedStatementHandle stmt)
Get a PreparedStatement from cache.

Parameters:
stmt - the key that has been used to cache the statement.
Returns:
the cached statement corresponding to the key or null if no statement is cached under that key.

putCachedStatement

protected JdbcPreparedStatementHandle putCachedStatement(JdbcPreparedStatementHandle stmt)
Put a PreparedStatement in the cache.

Parameters:
stmt - the statement to cache.
Returns:
the cached statement.

registerUncachedStatement

protected Statement registerUncachedStatement(Statement stmt)
Register uncached statement so that it can be closed when the connection is put back in the pool.

Parameters:
stmt - the statement to register.
Returns:
the registered statement.

unregisterUncachedStatement

protected void unregisterUncachedStatement(Statement stmt)

toString

public String toString()
Overrides:
toString in class Object

getStateDescription

public String getStateDescription()
Specified by:
getStateDescription in interface JdbcPooledConnectionMBean

getAcquisitionDate

public Date getAcquisitionDate()
Specified by:
getAcquisitionDate in interface JdbcPooledConnectionMBean

getLastReleaseDate

public Date getLastReleaseDate()
Description copied from interface: XAStatefulHolder
Get the date at which this object was last released to the pool. This is required to check if it is eligible for discard when the containing pool needs to shrink.

Specified by:
getLastReleaseDate in interface XAStatefulHolder
Returns:
the date at which this object was last released to the pool or null if it never left the pool.

getTransactionGtridsCurrentlyHoldingThis

public Collection getTransactionGtridsCurrentlyHoldingThis()
Specified by:
getTransactionGtridsCurrentlyHoldingThis in interface JdbcPooledConnectionMBean


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/ConnectionCustomizer.html0000644000175000017500000002543312215446620025415 0ustar tonytony ConnectionCustomizer (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Interface ConnectionCustomizer


public interface ConnectionCustomizer

Listener of connections created by a PoolingDataSource. Implementations of this class must be serializable and are handed raw, physical database Connections

Author:
Ludovic Orban

Method Summary
 void onAcquire(Connection connection, String uniqueName)
          Called when the physical connection is created.
 void onDestroy(Connection connection, String uniqueName)
          Called when the physical connection is destroyed.
 

Method Detail

onAcquire

void onAcquire(Connection connection,
               String uniqueName)
Called when the physical connection is created.

Parameters:
connection - the physical connection.
uniqueName - the PoolingDataSource unique name.

onDestroy

void onDestroy(Connection connection,
               String uniqueName)
Called when the physical connection is destroyed.

Parameters:
connection - the physical connection.
uniqueName - the PoolingDataSource unique name.


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcConnectionHandle.html0000644000175000017500000014270112215446622025227 0ustar tonytony JdbcConnectionHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class JdbcConnectionHandle

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.JdbcConnectionHandle
All Implemented Interfaces:
InvocationHandler

public class JdbcConnectionHandle
extends BaseProxyHandlerClass

Disposable Connection handle.

Author:
lorban, brettw

Constructor Summary
JdbcConnectionHandle(JdbcPooledConnection jdbcPooledConnection, Connection connection)
           
 
Method Summary
 void close()
           
 void commit()
           
 Statement createStatement()
           
 Statement createStatement(int resultSetType, int resultSetConcurrency)
           
 Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 boolean getAutoCommit()
           
 Connection getConnection()
           
 JdbcPooledConnection getPooledConnection()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 boolean isClosed()
           
 boolean isWrapperFor(Class<?> iface)
           
 CallableStatement prepareCall(String sql)
           
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
           
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 PreparedStatement prepareStatement(String sql)
           
 PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
           
 PreparedStatement prepareStatement(String sql, int[] columnIndexes)
           
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
           
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 PreparedStatement prepareStatement(String sql, String[] columnNames)
           
 void releaseSavepoint(Savepoint savepoint)
           
 void rollback()
           
 void rollback(Savepoint savepoint)
           
 void setAutoCommit(boolean autoCommit)
           
 Savepoint setSavepoint()
           
 Savepoint setSavepoint(String name)
           
 String toString()
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JdbcConnectionHandle

public JdbcConnectionHandle(JdbcPooledConnection jdbcPooledConnection,
                            Connection connection)
Method Detail

getPooledConnection

public JdbcPooledConnection getPooledConnection()

getConnection

public Connection getConnection()

toString

public String toString()
Overrides:
toString in class Object

close

public void close()
           throws SQLException
Throws:
SQLException

commit

public void commit()
            throws SQLException
Throws:
SQLException

rollback

public void rollback()
              throws SQLException
Throws:
SQLException

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint()
                       throws SQLException
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Throws:
SQLException

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
                      throws SQLException
Throws:
SQLException

getAutoCommit

public boolean getAutoCommit()
                      throws SQLException
Throws:
SQLException

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Throws:
SQLException

isClosed

public boolean isClosed()
                 throws SQLException
Throws:
SQLException

createStatement

public Statement createStatement()
                          throws SQLException
Throws:
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency)
                          throws SQLException
Throws:
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency,
                                 int resultSetHoldability)
                          throws SQLException
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql)
                              throws SQLException
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency)
                              throws SQLException
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLException
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql)
                                   throws SQLException
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
                                   throws SQLException
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency)
                                   throws SQLException
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws SQLException
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
                                   throws SQLException
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
                                   throws SQLException
Throws:
SQLException

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Throws:
SQLException

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/package-tree.html0000644000175000017500000002623112215446622023560 0ustar tonytony bitronix.tm.resource.jdbc Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.resource.jdbc

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/package-use.html0000644000175000017500000002603712215446622023421 0ustar tonytony Uses of Package bitronix.tm.resource.jdbc (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.resource.jdbc

Packages that use bitronix.tm.resource.jdbc
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jdbc.lrc XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource. 
 

Classes in bitronix.tm.resource.jdbc used by bitronix.tm.resource.jdbc
BaseProxyHandlerClass
          Base class for Proxy InvocationHandlers.
ConnectionCustomizer
          Listener of connections created by a PoolingDataSource.
JdbcPooledConnection
          Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
JdbcPooledConnectionMBean
          JdbcPooledConnection Management interface.
JdbcPreparedStatementHandle
          Caching PreparedStatement wrapper.
LruEvictionListener
          Eviction listener interface for LruStatementCache.
PoolingDataSource
          Implementation of a JDBC DataSource wrapping vendor's XADataSource implementation.
PoolingDataSourceMBean
           
 

Classes in bitronix.tm.resource.jdbc used by bitronix.tm.resource.jdbc.lrc
BaseProxyHandlerClass
          Base class for Proxy InvocationHandlers.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/LruStatementCache.html0000644000175000017500000004261112215446622024603 0ustar tonytony LruStatementCache (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class LruStatementCache

java.lang.Object
  extended by bitronix.tm.resource.jdbc.LruStatementCache

public class LruStatementCache
extends Object

Last Recently Used PreparedStatement cache with eviction listeners support implementation.

Author:
lorban, brettw

Constructor Summary
LruStatementCache(int maxSize)
           
 
Method Summary
 void addEvictionListener(LruEvictionListener listener)
           
protected  void clear()
          Evict all statements from the cache.
 JdbcPreparedStatementHandle get(JdbcPreparedStatementHandle key)
          The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes in with no actual 'delegate' PreparedStatement.
 JdbcPreparedStatementHandle put(JdbcPreparedStatementHandle key)
          A statement is put into the cache.
 void removeEvictionListener(LruEvictionListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LruStatementCache

public LruStatementCache(int maxSize)
Method Detail

get

public JdbcPreparedStatementHandle get(JdbcPreparedStatementHandle key)
The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes in with no actual 'delegate' PreparedStatement. However, it contains all other pertinent information such as SQL statement, autogeneratedkeys flag, cursor holdability, etc. See the equals() method in the JdbcPreparedStatementHandle class. It is a complete key for a cached statement. If there is a matching cached PreparedStatement, it will be set as the delegate in the provided JdbcPreparedStatementHandle.

Parameters:
key - the cache key
Returns:
the cached JdbcPreparedStatementHandle statement, or null

put

public JdbcPreparedStatementHandle put(JdbcPreparedStatementHandle key)
A statement is put into the cache. This is called when a statement is first prepared and also when a statement is closed (by the client). A "closed" statement has it's usage counter decremented in the cache.

Parameters:
key - a prepared statement handle
Returns:
a prepared statement

clear

protected void clear()
Evict all statements from the cache. This likely happens on connection close.


addEvictionListener

public void addEvictionListener(LruEvictionListener listener)

removeEvictionListener

public void removeEvictionListener(LruEvictionListener listener)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcPreparedStatementHandle.html0000644000175000017500000007663212215446622026570 0ustar tonytony JdbcPreparedStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class JdbcPreparedStatementHandle

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle
All Implemented Interfaces:
InvocationHandler

public class JdbcPreparedStatementHandle
extends BaseProxyHandlerClass

Caching PreparedStatement wrapper.

This class is a proxy handler for a PreparedStatement. It does not implement the PreparedStatement interface or extend a class directly, but you methods implemented here will override those of the underlying delegate. Simply implement a method with the same signature, and the local method will be called rather than the delegate.

Author:
lorban, brettw

Constructor Summary
JdbcPreparedStatementHandle(String sql)
           
JdbcPreparedStatementHandle(String sql, int autoGeneratedKeys)
           
JdbcPreparedStatementHandle(String sql, int[] columnIndexes)
           
JdbcPreparedStatementHandle(String sql, int resultSetType, int resultSetConcurrency)
           
JdbcPreparedStatementHandle(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
JdbcPreparedStatementHandle(String sql, String[] columnNames)
           
 
Method Summary
 void close()
           
 boolean equals(Object obj)
          Overridden equals() that takes all PreparedStatement attributes into account.
protected  PreparedStatement getDelegateUnchecked()
           
protected  JdbcPooledConnection getPooledConnection()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 int hashCode()
           
 boolean isClosed()
           
 boolean isWrapperFor(Class<?> iface)
           
protected  void setDelegate(PreparedStatement delegate)
           
protected  void setPooledConnection(JdbcPooledConnection pooledConnection)
          Set the parent connection that created this statement.
 String toString()
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JdbcPreparedStatementHandle

public JdbcPreparedStatementHandle(String sql)

JdbcPreparedStatementHandle

public JdbcPreparedStatementHandle(String sql,
                                   int autoGeneratedKeys)

JdbcPreparedStatementHandle

public JdbcPreparedStatementHandle(String sql,
                                   int resultSetType,
                                   int resultSetConcurrency)

JdbcPreparedStatementHandle

public JdbcPreparedStatementHandle(String sql,
                                   int resultSetType,
                                   int resultSetConcurrency,
                                   int resultSetHoldability)

JdbcPreparedStatementHandle

public JdbcPreparedStatementHandle(String sql,
                                   int[] columnIndexes)

JdbcPreparedStatementHandle

public JdbcPreparedStatementHandle(String sql,
                                   String[] columnNames)
Method Detail

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Throws:
SQLException

setPooledConnection

protected void setPooledConnection(JdbcPooledConnection pooledConnection)
Set the parent connection that created this statement. We need this to return the PreparedStatement to the pool.

Parameters:
pooledConnection - the parent JdbcPooledConnection

getPooledConnection

protected JdbcPooledConnection getPooledConnection()

getDelegateUnchecked

protected PreparedStatement getDelegateUnchecked()

setDelegate

protected void setDelegate(PreparedStatement delegate)

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired

equals

public boolean equals(Object obj)
Overridden equals() that takes all PreparedStatement attributes into account.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

close

public void close()
           throws SQLException
Throws:
SQLException

isClosed

public boolean isClosed()
                 throws SQLException
Throws:
SQLException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/0000755000175000017500000000000012215446622021116 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/package-frame.html0000644000175000017500000000260512215446622024472 0ustar tonytony bitronix.tm.resource.jdbc.lrc (Bitronix Transaction Manager :: Core 2.1.4 API) bitronix.tm.resource.jdbc.lrc
Classes 
LrcConnectionHandle
LrcXAConnection
LrcXADataSource
LrcXAResource
btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/LrcXADataSource.html0000644000175000017500000007201012215446622024730 0ustar tonytony LrcXADataSource (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc.lrc
Class LrcXADataSource

java.lang.Object
  extended by bitronix.tm.resource.jdbc.lrc.LrcXADataSource
All Implemented Interfaces:
CommonDataSource, XADataSource

public class LrcXADataSource
extends Object
implements XADataSource

XADataSource implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.

Author:
lorban, brettw

Constructor Summary
LrcXADataSource()
           
 
Method Summary
 String getDriverClassName()
           
 int getLoginTimeout()
           
 PrintWriter getLogWriter()
           
 String getPassword()
           
 String getUrl()
           
 String getUser()
           
 XAConnection getXAConnection()
           
 XAConnection getXAConnection(String user, String password)
           
 void setDriverClassName(String driverClassName)
           
 void setLoginTimeout(int seconds)
           
 void setLogWriter(PrintWriter out)
           
 void setPassword(String password)
           
 void setUrl(String url)
           
 void setUser(String user)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LrcXADataSource

public LrcXADataSource()
Method Detail

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException
Specified by:
getLoginTimeout in interface CommonDataSource
Throws:
SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws SQLException
Specified by:
setLoginTimeout in interface CommonDataSource
Throws:
SQLException

getDriverClassName

public String getDriverClassName()

setDriverClassName

public void setDriverClassName(String driverClassName)

getUrl

public String getUrl()

setUrl

public void setUrl(String url)

getUser

public String getUser()

setUser

public void setUser(String user)

getPassword

public String getPassword()

setPassword

public void setPassword(String password)

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException
Specified by:
getLogWriter in interface CommonDataSource
Throws:
SQLException

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws SQLException
Specified by:
setLogWriter in interface CommonDataSource
Throws:
SQLException

getXAConnection

public XAConnection getXAConnection()
                             throws SQLException
Specified by:
getXAConnection in interface XADataSource
Throws:
SQLException

getXAConnection

public XAConnection getXAConnection(String user,
                                    String password)
                             throws SQLException
Specified by:
getXAConnection in interface XADataSource
Throws:
SQLException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/package-tree.html0000644000175000017500000001746312215446622024347 0ustar tonytony bitronix.tm.resource.jdbc.lrc Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For Package bitronix.tm.resource.jdbc.lrc

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/LrcConnectionHandle.html0000644000175000017500000005461412215446622025672 0ustar tonytony LrcConnectionHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc.lrc
Class LrcConnectionHandle

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle
All Implemented Interfaces:
InvocationHandler

public class LrcConnectionHandle
extends BaseProxyHandlerClass

Connection handle implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.

Author:
lorban, brettw

Constructor Summary
LrcConnectionHandle(LrcXAResource xaResource, Connection delegate)
           
 
Method Summary
 void close()
           
 void commit()
           
 Connection getConnection()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 boolean isClosed()
           
 void rollback()
           
 void rollback(Savepoint savepoint)
           
 void setAutoCommit(boolean autoCommit)
           
 String toString()
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LrcConnectionHandle

public LrcConnectionHandle(LrcXAResource xaResource,
                           Connection delegate)
Method Detail

getConnection

public Connection getConnection()

close

public void close()
           throws SQLException
Throws:
SQLException

isClosed

public boolean isClosed()
                 throws SQLException
Throws:
SQLException

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Throws:
SQLException

commit

public void commit()
            throws SQLException
Throws:
SQLException

rollback

public void rollback()
              throws SQLException
Throws:
SQLException

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Throws:
SQLException

toString

public String toString()
Overrides:
toString in class Object

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/package-use.html0000644000175000017500000001615112215446622024175 0ustar tonytony Uses of Package bitronix.tm.resource.jdbc.lrc (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Package
bitronix.tm.resource.jdbc.lrc

Packages that use bitronix.tm.resource.jdbc.lrc
bitronix.tm.resource.jdbc.lrc XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource. 
 

Classes in bitronix.tm.resource.jdbc.lrc used by bitronix.tm.resource.jdbc.lrc
LrcXAResource
          XAResource implementation for a non-XA JDBC connection emulating XA with Last Resource Commit.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/class-use/0000755000175000017500000000000012215446622023015 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/class-use/LrcXADataSource.html0000644000175000017500000001422412215446622026632 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.lrc.LrcXADataSource (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.lrc.LrcXADataSource

No usage of bitronix.tm.resource.jdbc.lrc.LrcXADataSource



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/class-use/LrcConnectionHandle.html0000644000175000017500000001427412215446622027567 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle

No usage of bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/class-use/LrcXAResource.html0000644000175000017500000002052412215446622026367 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.lrc.LrcXAResource (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.lrc.LrcXAResource

Packages that use LrcXAResource
bitronix.tm.resource.jdbc.lrc XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource. 
 

Uses of LrcXAResource in bitronix.tm.resource.jdbc.lrc
 

Constructors in bitronix.tm.resource.jdbc.lrc with parameters of type LrcXAResource
LrcConnectionHandle(LrcXAResource xaResource, Connection delegate)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/class-use/LrcXAConnection.html0000644000175000017500000001422412215446622026677 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.lrc.LrcXAConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.lrc.LrcXAConnection

No usage of bitronix.tm.resource.jdbc.lrc.LrcXAConnection



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/LrcXAResource.html0000644000175000017500000011032312215446622024465 0ustar tonytony LrcXAResource (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc.lrc
Class LrcXAResource

java.lang.Object
  extended by bitronix.tm.resource.jdbc.lrc.LrcXAResource
All Implemented Interfaces:
XAResource

public class LrcXAResource
extends Object
implements XAResource

XAResource implementation for a non-XA JDBC connection emulating XA with Last Resource Commit.

The XA protocol flow is implemented by this state machine:

 NO_TX
   |
   | start(TMNOFLAGS)
   |
   |       end(TMFAIL)
 STARTED -------------- NO_TX
   |
   | end(TMSUCCESS)
   |
   |    start(TMJOIN)
 ENDED ---------------- STARTED
   |\
   | \  commit (one phase)
   |  ----------------- NO_TX
   |
   | prepare()
   |
   |       commit() or
   |       rollback()
 PREPARED ------------- NO_TX
 
XAResource.TMSUSPEND and XAResource.TMRESUME are not supported.

Author:
lorban

Field Summary
static int ENDED
           
static int NO_TX
           
static int PREPARED
           
static int STARTED
           
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
LrcXAResource(Connection connection)
           
 
Method Summary
 void commit(Xid xid, boolean onePhase)
           
 void end(Xid xid, int flag)
           
 void forget(Xid xid)
           
 int getState()
           
 int getTransactionTimeout()
           
 boolean isSameRM(XAResource xaResource)
           
 int prepare(Xid xid)
           
 Xid[] recover(int flags)
           
 void rollback(Xid xid)
           
 boolean setTransactionTimeout(int seconds)
           
 void start(Xid xid, int flag)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_TX

public static final int NO_TX
See Also:
Constant Field Values

STARTED

public static final int STARTED
See Also:
Constant Field Values

ENDED

public static final int ENDED
See Also:
Constant Field Values

PREPARED

public static final int PREPARED
See Also:
Constant Field Values
Constructor Detail

LrcXAResource

public LrcXAResource(Connection connection)
Method Detail

getState

public int getState()

getTransactionTimeout

public int getTransactionTimeout()
                          throws XAException
Specified by:
getTransactionTimeout in interface XAResource
Throws:
XAException

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)
                              throws XAException
Specified by:
setTransactionTimeout in interface XAResource
Throws:
XAException

forget

public void forget(Xid xid)
            throws XAException
Specified by:
forget in interface XAResource
Throws:
XAException

recover

public Xid[] recover(int flags)
              throws XAException
Specified by:
recover in interface XAResource
Throws:
XAException

isSameRM

public boolean isSameRM(XAResource xaResource)
                 throws XAException
Specified by:
isSameRM in interface XAResource
Throws:
XAException

start

public void start(Xid xid,
                  int flag)
           throws XAException
Specified by:
start in interface XAResource
Throws:
XAException

end

public void end(Xid xid,
                int flag)
         throws XAException
Specified by:
end in interface XAResource
Throws:
XAException

prepare

public int prepare(Xid xid)
            throws XAException
Specified by:
prepare in interface XAResource
Throws:
XAException

commit

public void commit(Xid xid,
                   boolean onePhase)
            throws XAException
Specified by:
commit in interface XAResource
Throws:
XAException

rollback

public void rollback(Xid xid)
              throws XAException
Specified by:
rollback in interface XAResource
Throws:
XAException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/package-summary.html0000644000175000017500000002035612215446622025100 0ustar tonytony bitronix.tm.resource.jdbc.lrc (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.resource.jdbc.lrc

XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource.

See:
          Description

Class Summary
LrcConnectionHandle Connection handle implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
LrcXAConnection XAConnection implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
LrcXADataSource XADataSource implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
LrcXAResource XAResource implementation for a non-XA JDBC connection emulating XA with Last Resource Commit.
 

Package bitronix.tm.resource.jdbc.lrc Description

XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource. Note that if you use the classes of this package you have accepted the heuristic hazard. A crash during commit of a connection returned by this datasource could lead to an inconsistent global state. This is a limitation of the Last Resource Commit technique, not of BTM.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/lrc/LrcXAConnection.html0000644000175000017500000005546412215446622025013 0ustar tonytony LrcXAConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc.lrc
Class LrcXAConnection

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.lrc.LrcXAConnection
All Implemented Interfaces:
InvocationHandler

public class LrcXAConnection
extends BaseProxyHandlerClass

XAConnection implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.

Author:
lorban, brettw

Constructor Summary
LrcXAConnection(Connection connection)
           
 
Method Summary
 void addConnectionEventListener(ConnectionEventListener listener)
           
 void close()
           
 boolean equals(Object obj)
           
 Connection getConnection()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 XAResource getXAResource()
           
 int hashCode()
           
 void removeConnectionEventListener(ConnectionEventListener listener)
           
 String toString()
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LrcXAConnection

public LrcXAConnection(Connection connection)
Method Detail

getXAResource

public XAResource getXAResource()
                         throws SQLException
Throws:
SQLException

close

public void close()
           throws SQLException
Throws:
SQLException

getConnection

public Connection getConnection()
                         throws SQLException
Throws:
SQLException

addConnectionEventListener

public void addConnectionEventListener(ConnectionEventListener listener)

removeConnectionEventListener

public void removeConnectionEventListener(ConnectionEventListener listener)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/0000755000175000017500000000000012215446622022235 5ustar tonytonybtm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/LruEvictionListener.html0000644000175000017500000002141012215446622027072 0ustar tonytony Uses of Interface bitronix.tm.resource.jdbc.LruEvictionListener (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.jdbc.LruEvictionListener

Packages that use LruEvictionListener
bitronix.tm.resource.jdbc JDBC specific resource management code. 
 

Uses of LruEvictionListener in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc with parameters of type LruEvictionListener
 void LruStatementCache.addEvictionListener(LruEvictionListener listener)
           
 void LruStatementCache.removeEvictionListener(LruEvictionListener listener)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcPooledConnectionMBean.html0000644000175000017500000002043212215446622030054 0ustar tonytony Uses of Interface bitronix.tm.resource.jdbc.JdbcPooledConnectionMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.jdbc.JdbcPooledConnectionMBean

Packages that use JdbcPooledConnectionMBean
bitronix.tm.resource.jdbc JDBC specific resource management code. 
 

Uses of JdbcPooledConnectionMBean in bitronix.tm.resource.jdbc
 

Classes in bitronix.tm.resource.jdbc that implement JdbcPooledConnectionMBean
 class JdbcPooledConnection
          Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcPooledConnection.html0000644000175000017500000003210612215446622027152 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.JdbcPooledConnection (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.JdbcPooledConnection

Packages that use JdbcPooledConnection
bitronix.tm.resource.jdbc JDBC specific resource management code. 
 

Uses of JdbcPooledConnection in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc that return JdbcPooledConnection
protected  JdbcPooledConnection JdbcPreparedStatementHandle.getPooledConnection()
           
 JdbcPooledConnection JdbcConnectionHandle.getPooledConnection()
           
 

Methods in bitronix.tm.resource.jdbc with parameters of type JdbcPooledConnection
protected  void JdbcPreparedStatementHandle.setPooledConnection(JdbcPooledConnection pooledConnection)
          Set the parent connection that created this statement.
 

Constructors in bitronix.tm.resource.jdbc with parameters of type JdbcPooledConnection
JdbcCallableStatementHandle(CallableStatement delegate, JdbcPooledConnection pooledConnection)
           
JdbcConnectionHandle(JdbcPooledConnection jdbcPooledConnection, Connection connection)
           
JdbcStatementHandle(Statement delegate, JdbcPooledConnection pooledConnection)
           
JdbcUncachedPreparedStatementHandle(PreparedStatement delegate, JdbcPooledConnection pooledConnection)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/ConnectionCustomizer.html0000644000175000017500000002150512215446622027312 0ustar tonytony Uses of Interface bitronix.tm.resource.jdbc.ConnectionCustomizer (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.jdbc.ConnectionCustomizer

Packages that use ConnectionCustomizer
bitronix.tm.resource.jdbc JDBC specific resource management code. 
 

Uses of ConnectionCustomizer in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc with parameters of type ConnectionCustomizer
 void PoolingDataSource.addConnectionCustomizer(ConnectionCustomizer connectionCustomizer)
           
 void PoolingDataSource.removeConnectionCustomizer(ConnectionCustomizer connectionCustomizer)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcConnectionHandle.html0000644000175000017500000001415312215446622027125 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.JdbcConnectionHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.JdbcConnectionHandle

No usage of bitronix.tm.resource.jdbc.JdbcConnectionHandle



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/LruStatementCache.html0000644000175000017500000001411512215446622026500 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.LruStatementCache (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.LruStatementCache

No usage of bitronix.tm.resource.jdbc.LruStatementCache



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcPreparedStatementHandle.html0000644000175000017500000003472712215446622030466 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle

Packages that use JdbcPreparedStatementHandle
bitronix.tm.resource.jdbc JDBC specific resource management code. 
 

Uses of JdbcPreparedStatementHandle in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc that return JdbcPreparedStatementHandle
 JdbcPreparedStatementHandle LruStatementCache.get(JdbcPreparedStatementHandle key)
          The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes in with no actual 'delegate' PreparedStatement.
protected  JdbcPreparedStatementHandle JdbcPooledConnection.getCachedStatement(JdbcPreparedStatementHandle stmt)
          Get a PreparedStatement from cache.
 JdbcPreparedStatementHandle LruStatementCache.put(JdbcPreparedStatementHandle key)
          A statement is put into the cache.
protected  JdbcPreparedStatementHandle JdbcPooledConnection.putCachedStatement(JdbcPreparedStatementHandle stmt)
          Put a PreparedStatement in the cache.
 

Methods in bitronix.tm.resource.jdbc with parameters of type JdbcPreparedStatementHandle
 JdbcPreparedStatementHandle LruStatementCache.get(JdbcPreparedStatementHandle key)
          The provided key is just a 'shell' JdbcPreparedStatementHandle, it comes in with no actual 'delegate' PreparedStatement.
protected  JdbcPreparedStatementHandle JdbcPooledConnection.getCachedStatement(JdbcPreparedStatementHandle stmt)
          Get a PreparedStatement from cache.
 JdbcPreparedStatementHandle LruStatementCache.put(JdbcPreparedStatementHandle key)
          A statement is put into the cache.
protected  JdbcPreparedStatementHandle JdbcPooledConnection.putCachedStatement(JdbcPreparedStatementHandle stmt)
          Put a PreparedStatement in the cache.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/PoolingDataSourceMBean.html0000644000175000017500000002056612215446622027421 0ustar tonytony Uses of Interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Interface
bitronix.tm.resource.jdbc.PoolingDataSourceMBean

Packages that use PoolingDataSourceMBean
bitronix.tm.resource.jdbc JDBC specific resource management code. 
 

Uses of PoolingDataSourceMBean in bitronix.tm.resource.jdbc
 

Classes in bitronix.tm.resource.jdbc that implement PoolingDataSourceMBean
 class PoolingDataSource
          Implementation of a JDBC DataSource wrapping vendor's XADataSource implementation.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcStatementHandle.html0000644000175000017500000001414112215446622026767 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.JdbcStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.JdbcStatementHandle

No usage of bitronix.tm.resource.jdbc.JdbcStatementHandle



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/PoolingDataSource.html0000644000175000017500000002227112215446622026511 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.PoolingDataSource (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.PoolingDataSource

Packages that use PoolingDataSource
bitronix.tm.resource.jdbc JDBC specific resource management code. 
 

Uses of PoolingDataSource in bitronix.tm.resource.jdbc
 

Methods in bitronix.tm.resource.jdbc that return PoolingDataSource
 PoolingDataSource JdbcPooledConnection.getPoolingDataSource()
           
 

Constructors in bitronix.tm.resource.jdbc with parameters of type PoolingDataSource
JdbcPooledConnection(PoolingDataSource poolingDataSource, XAConnection xaConnection)
           
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/BaseProxyHandlerClass.html0000644000175000017500000003366612215446622027341 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.BaseProxyHandlerClass (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.BaseProxyHandlerClass

Packages that use BaseProxyHandlerClass
bitronix.tm.resource.jdbc JDBC specific resource management code. 
bitronix.tm.resource.jdbc.lrc XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource. 
 

Uses of BaseProxyHandlerClass in bitronix.tm.resource.jdbc
 

Subclasses of BaseProxyHandlerClass in bitronix.tm.resource.jdbc
 class JdbcCallableStatementHandle
          CallableStatement Statement wrapper.
 class JdbcConnectionHandle
          Disposable Connection handle.
 class JdbcPreparedStatementHandle
          Caching PreparedStatement wrapper.
 class JdbcResultSetHandle
          ResultSet ResultSet wrapper.
 class JdbcStatementHandle
          Statement Statement wrapper.
 class JdbcUncachedPreparedStatementHandle
           
 

Constructors in bitronix.tm.resource.jdbc with parameters of type BaseProxyHandlerClass
JdbcResultSetHandle(ResultSet delegate, BaseProxyHandlerClass statementHandle)
           
 

Uses of BaseProxyHandlerClass in bitronix.tm.resource.jdbc.lrc
 

Subclasses of BaseProxyHandlerClass in bitronix.tm.resource.jdbc.lrc
 class LrcConnectionHandle
          Connection handle implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
 class LrcXAConnection
          XAConnection implementation for a non-XA JDBC resource emulating XA with Last Resource Commit.
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcResultSetHandle.html0000644000175000017500000001414112215446622026755 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.JdbcResultSetHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.JdbcResultSetHandle

No usage of bitronix.tm.resource.jdbc.JdbcResultSetHandle



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcCallableStatementHandle.html0000644000175000017500000001426112215446622030412 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.JdbcCallableStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.JdbcCallableStatementHandle

No usage of bitronix.tm.resource.jdbc.JdbcCallableStatementHandle



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/class-use/JdbcUncachedPreparedStatementHandle.html0000644000175000017500000001440112215446622032104 0ustar tonytony Uses of Class bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

Uses of Class
bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle

No usage of bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/PoolingDataSourceMBean.html0000644000175000017500000002770712215446622025526 0ustar tonytony PoolingDataSourceMBean (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Interface PoolingDataSourceMBean

All Known Implementing Classes:
PoolingDataSource

public interface PoolingDataSourceMBean

Author:
lorban

Method Summary
 long getInPoolSize()
           
 int getMaxPoolSize()
           
 int getMinPoolSize()
           
 long getTotalPoolSize()
           
 boolean isDisabled()
           
 boolean isFailed()
           
 void reset()
           
 void setDisabled(boolean disabled)
           
 

Method Detail

getMinPoolSize

int getMinPoolSize()

getMaxPoolSize

int getMaxPoolSize()

getInPoolSize

long getInPoolSize()

getTotalPoolSize

long getTotalPoolSize()

isFailed

boolean isFailed()

reset

void reset()
           throws Exception
Throws:
Exception

isDisabled

boolean isDisabled()

setDisabled

void setDisabled(boolean disabled)


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/package-summary.html0000644000175000017500000002752112215446622024321 0ustar tonytony bitronix.tm.resource.jdbc (Bitronix Transaction Manager :: Core 2.1.4 API)

Package bitronix.tm.resource.jdbc

JDBC specific resource management code.

See:
          Description

Interface Summary
ConnectionCustomizer Listener of connections created by a PoolingDataSource.
JdbcPooledConnectionMBean JdbcPooledConnection Management interface.
LruEvictionListener Eviction listener interface for LruStatementCache.
PoolingDataSourceMBean  
 

Class Summary
BaseProxyHandlerClass Base class for Proxy InvocationHandlers.
JdbcCallableStatementHandle CallableStatement Statement wrapper.
JdbcConnectionHandle Disposable Connection handle.
JdbcPooledConnection Implementation of a JDBC pooled connection wrapping vendor's XAConnection implementation.
JdbcPreparedStatementHandle Caching PreparedStatement wrapper.
JdbcResultSetHandle ResultSet ResultSet wrapper.
JdbcStatementHandle Statement Statement wrapper.
JdbcUncachedPreparedStatementHandle  
LruStatementCache Last Recently Used PreparedStatement cache with eviction listeners support implementation.
PoolingDataSource Implementation of a JDBC DataSource wrapping vendor's XADataSource implementation.
 

Package bitronix.tm.resource.jdbc Description

JDBC specific resource management code.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcStatementHandle.html0000644000175000017500000005757312215446622025110 0ustar tonytony JdbcStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class JdbcStatementHandle

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.JdbcStatementHandle
All Implemented Interfaces:
InvocationHandler

public class JdbcStatementHandle
extends BaseProxyHandlerClass

Statement Statement wrapper.

This class is a proxy handler for a Statement. It does not implement the Statement interface or extend a class directly, but you methods implemented here will override those of the underlying delegate. Simply implement a method with the same signature, and the local method will be called rather than the delegate.

Author:
brettw

Constructor Summary
JdbcStatementHandle(Statement delegate, JdbcPooledConnection pooledConnection)
           
 
Method Summary
 void close()
           
 boolean equals(Object object)
           
 ResultSet executeQuery(String sql)
           
 ResultSet getGeneratedKeys()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 ResultSet getResultSet()
           
 boolean isWrapperFor(Class<?> iface)
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcStatementHandle

public JdbcStatementHandle(Statement delegate,
                           JdbcPooledConnection pooledConnection)
Method Detail

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Throws:
SQLException

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired

close

public void close()
           throws SQLException
Throws:
SQLException

executeQuery

public ResultSet executeQuery(String sql)
                       throws SQLException
Throws:
SQLException

getGeneratedKeys

public ResultSet getGeneratedKeys()
                           throws SQLException
Throws:
SQLException

getResultSet

public ResultSet getResultSet()
                       throws SQLException
Throws:
SQLException

equals

public boolean equals(Object object)
Overrides:
equals in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/PoolingDataSource.html0000644000175000017500000021070612215446622024614 0ustar tonytony PoolingDataSource (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class PoolingDataSource

java.lang.Object
  extended by bitronix.tm.resource.common.ResourceBean
      extended by bitronix.tm.resource.jdbc.PoolingDataSource
All Implemented Interfaces:
XAResourceProducer, PoolingDataSourceMBean, Serializable, Wrapper, Referenceable, CommonDataSource, DataSource

public class PoolingDataSource
extends ResourceBean
implements DataSource, XAResourceProducer, PoolingDataSourceMBean

Implementation of a JDBC DataSource wrapping vendor's XADataSource implementation.

Author:
lorban, brettw
See Also:
Serialized Form

Constructor Summary
PoolingDataSource()
           
 
Method Summary
 void addConnectionCustomizer(ConnectionCustomizer connectionCustomizer)
           
 void close()
          Release this XAResourceProducer's internal resources.
 XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean)
          Create a XAStatefulHolder that will be placed in an XAPool.
 void endRecovery()
          Release internal resources held after call to startRecovery().
 XAResourceHolder findXAResourceHolder(XAResource xaResource)
          Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.
 Connection getConnection()
           
 Connection getConnection(String username, String password)
           
 String getCursorHoldability()
           
 long getInPoolSize()
           
 String getIsolationLevel()
           
 String getLocalAutoCommit()
           
 int getLoginTimeout()
           
 PrintWriter getLogWriter()
           
 int getPreparedStatementCacheSize()
           
 Reference getReference()
          PoolingDataSource must alway have a unique name so this method builds a reference to this object using the unique name as RefAddr.
 String getTestQuery()
           
 long getTotalPoolSize()
           
 void init()
          Initializes the pool by creating the initial amount of connections.
 boolean isEnableJdbc4ConnectionTest()
           
 boolean isFailed()
           
 boolean isWrapperFor(Class<?> iface)
           
 void removeConnectionCustomizer(ConnectionCustomizer connectionCustomizer)
           
 void reset()
           
 void setCursorHoldability(String cursorHoldability)
          Set the default cursor holdability for connections.
 void setEnableJdbc4ConnectionTest(boolean enableJdbc4ConnectionTest)
          When set and the underlying JDBC driver supports JDBC 4 isValid(), a Connection.isValid() call is performed to test the connection before handing it to the caller.
 void setFailed(boolean failed)
          Mark this resource producer as failed or not.
 void setIsolationLevel(String isolationLevel)
          Set the default isolation level for connections.
 void setLocalAutoCommit(String localAutoCommit)
          Set the default local transactions autocommit mode.
 void setLoginTimeout(int seconds)
           
 void setLogWriter(PrintWriter out)
           
 void setPreparedStatementCacheSize(int preparedStatementCacheSize)
          Set the target maximum size of the prepared statement cache.
 void setTestQuery(String testQuery)
          When set, the specified query will be executed on the connection acquired from the pool before being handed to the caller.
 XAResourceHolderState startRecovery()
          Prepare the recoverable XAResource producer for recovery.
 String toString()
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class bitronix.tm.resource.common.ResourceBean
getAcquireIncrement, getAcquisitionInterval, getAcquisitionTimeout, getAllowLocalTransactions, getApplyTransactionTimeout, getAutomaticEnlistingEnabled, getClassName, getDeferConnectionRelease, getDriverProperties, getIgnoreRecoveryFailures, getMaxIdleTime, getMaxPoolSize, getMinPoolSize, getShareTransactionConnections, getTwoPcOrderingPosition, getUniqueName, getUseTmJoin, incCreatedResourcesCounter, isDisabled, setAcquireIncrement, setAcquisitionInterval, setAcquisitionTimeout, setAllowLocalTransactions, setApplyTransactionTimeout, setAutomaticEnlistingEnabled, setClassName, setDeferConnectionRelease, setDisabled, setDriverProperties, setIgnoreRecoveryFailures, setMaxIdleTime, setMaxPoolSize, setMinPoolSize, setShareTransactionConnections, setTwoPcOrderingPosition, setUniqueName, setUseTmJoin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bitronix.tm.resource.common.XAResourceProducer
getUniqueName
 
Methods inherited from interface bitronix.tm.resource.jdbc.PoolingDataSourceMBean
getMaxPoolSize, getMinPoolSize, isDisabled, setDisabled
 

Constructor Detail

PoolingDataSource

public PoolingDataSource()
Method Detail

init

public void init()
Initializes the pool by creating the initial amount of connections.

Specified by:
init in interface XAResourceProducer

getTestQuery

public String getTestQuery()
Returns:
the query that will be used to test connections.

setTestQuery

public void setTestQuery(String testQuery)
When set, the specified query will be executed on the connection acquired from the pool before being handed to the caller. The connections won't be tested when not set. Default value is null.

Parameters:
testQuery - the query that will be used to test connections.

setEnableJdbc4ConnectionTest

public void setEnableJdbc4ConnectionTest(boolean enableJdbc4ConnectionTest)
When set and the underlying JDBC driver supports JDBC 4 isValid(), a Connection.isValid() call is performed to test the connection before handing it to the caller. If both testQuery and enableJdbc4ConnectionTest are set, enableJdbc4ConnectionTest takes precedence.

Parameters:
enableJdbc4ConnectionTest - true if JDBC 4 isValid() testing should be performed, false otherwise.

isEnableJdbc4ConnectionTest

public boolean isEnableJdbc4ConnectionTest()
Returns:
true if JDBC 4 isValid() testing should be performed, false otherwise.

getPreparedStatementCacheSize

public int getPreparedStatementCacheSize()
Returns:
the target maximum prepared statement cache size.

setPreparedStatementCacheSize

public void setPreparedStatementCacheSize(int preparedStatementCacheSize)
Set the target maximum size of the prepared statement cache. In reality under certain unusual conditions the cache may temporarily drift higher in size.

Parameters:
preparedStatementCacheSize - the target maximum prepared statement cache size.

getIsolationLevel

public String getIsolationLevel()
Returns:
the default isolation level.

setIsolationLevel

public void setIsolationLevel(String isolationLevel)
Set the default isolation level for connections.

Parameters:
isolationLevel - the default isolation level.

getCursorHoldability

public String getCursorHoldability()
Returns:
cursorHoldability the default cursor holdability.

setCursorHoldability

public void setCursorHoldability(String cursorHoldability)
Set the default cursor holdability for connections.

Parameters:
cursorHoldability - the default cursor holdability.

getLocalAutoCommit

public String getLocalAutoCommit()
Returns:
localAutoCommit the default local transactions autocommit mode.

setLocalAutoCommit

public void setLocalAutoCommit(String localAutoCommit)
Set the default local transactions autocommit mode.

Parameters:
localAutoCommit - the default local transactions autocommit mode.

addConnectionCustomizer

public void addConnectionCustomizer(ConnectionCustomizer connectionCustomizer)

removeConnectionCustomizer

public void removeConnectionCustomizer(ConnectionCustomizer connectionCustomizer)

getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException

toString

public String toString()
Overrides:
toString in class Object

startRecovery

public XAResourceHolderState startRecovery()
                                    throws RecoveryException
Description copied from interface: XAResourceProducer
Prepare the recoverable XAResource producer for recovery.

Specified by:
startRecovery in interface XAResourceProducer
Returns:
a XAResourceHolderState object that can be used to call recover().
Throws:
RecoveryException - thrown when a XAResourceHolderState cannot be acquired.

endRecovery

public void endRecovery()
                 throws RecoveryException
Description copied from interface: XAResourceProducer
Release internal resources held after call to startRecovery().

Specified by:
endRecovery in interface XAResourceProducer
Throws:
RecoveryException - thrown when an error occured while releasing reserved resources.

setFailed

public void setFailed(boolean failed)
Description copied from interface: XAResourceProducer
Mark this resource producer as failed or not. A resource is considered failed if recovery fails to run on it.

Specified by:
setFailed in interface XAResourceProducer
Parameters:
failed - true is the resource must be considered failed, false it it must be considered sane.

isFailed

public boolean isFailed()
Specified by:
isFailed in interface PoolingDataSourceMBean

close

public void close()
Description copied from interface: XAResourceProducer
Release this XAResourceProducer's internal resources.

Specified by:
close in interface XAResourceProducer

createPooledConnection

public XAStatefulHolder createPooledConnection(Object xaFactory,
                                               ResourceBean bean)
                                        throws Exception
Description copied from interface: XAResourceProducer
Create a XAStatefulHolder that will be placed in an XAPool.

Specified by:
createPooledConnection in interface XAResourceProducer
Parameters:
xaFactory - the vendor's resource-specific XA factory.
bean - the resource-specific bean describing the resource parameters.
Returns:
a XAStatefulHolder that will be placed in an XAPool.
Throws:
Exception - thrown when the XAStatefulHolder cannot be created.

findXAResourceHolder

public XAResourceHolder findXAResourceHolder(XAResource xaResource)
Description copied from interface: XAResourceProducer
Find in the XAResourceHolders created by this XAResourceProducer the one which this XAResource belongs to.

Specified by:
findXAResourceHolder in interface XAResourceProducer
Parameters:
xaResource - the XAResource to look for.
Returns:
the associated XAResourceHolder or null if the XAResource does not belong to this XAResourceProducer.

getReference

public Reference getReference()
                       throws NamingException
PoolingDataSource must alway have a unique name so this method builds a reference to this object using the unique name as RefAddr.

Specified by:
getReference in interface Referenceable
Returns:
a reference to this PoolingDataSource.
Throws:
NamingException

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException
Specified by:
getLoginTimeout in interface CommonDataSource
Throws:
SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws SQLException
Specified by:
setLoginTimeout in interface CommonDataSource
Throws:
SQLException

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException
Specified by:
getLogWriter in interface CommonDataSource
Throws:
SQLException

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws SQLException
Specified by:
setLogWriter in interface CommonDataSource
Throws:
SQLException

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Specified by:
isWrapperFor in interface Wrapper
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Specified by:
unwrap in interface Wrapper
Throws:
SQLException

getInPoolSize

public long getInPoolSize()
Specified by:
getInPoolSize in interface PoolingDataSourceMBean

getTotalPoolSize

public long getTotalPoolSize()
Specified by:
getTotalPoolSize in interface PoolingDataSourceMBean

reset

public void reset()
           throws Exception
Specified by:
reset in interface PoolingDataSourceMBean
Throws:
Exception


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/BaseProxyHandlerClass.html0000644000175000017500000004317512215446620025434 0ustar tonytony BaseProxyHandlerClass (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class BaseProxyHandlerClass

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
All Implemented Interfaces:
InvocationHandler
Direct Known Subclasses:
JdbcCallableStatementHandle, JdbcConnectionHandle, JdbcPreparedStatementHandle, JdbcResultSetHandle, JdbcStatementHandle, JdbcUncachedPreparedStatementHandle, LrcConnectionHandle, LrcXAConnection

public abstract class BaseProxyHandlerClass
extends Object
implements InvocationHandler

Base class for Proxy InvocationHandlers. Maintains a method cache for swift delegation to either the overridden methods (implemented in a sub-class of this class) or the underlying delegate class' methods. Makes proxying an interface almost completely painless.

Author:
brettw

Constructor Summary
BaseProxyHandlerClass()
           
 
Method Summary
abstract  Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 Object invoke(Object proxy, Method method, Object[] args)
          Implementation of the InvocationHandler interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseProxyHandlerClass

public BaseProxyHandlerClass()
Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Implementation of the InvocationHandler interface.

Specified by:
invoke in interface InvocationHandler
Throws:
Throwable
See Also:
InvocationHandler

getProxiedDelegate

public abstract Object getProxiedDelegate()
                                   throws Exception
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcResultSetHandle.html0000644000175000017500000005044312215446622025063 0ustar tonytony JdbcResultSetHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class JdbcResultSetHandle

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.JdbcResultSetHandle
All Implemented Interfaces:
InvocationHandler

public class JdbcResultSetHandle
extends BaseProxyHandlerClass

ResultSet ResultSet wrapper.

This class is a proxy handler for a ResultSet. It does not implement the ResultSet interface or extend a class directly, but you methods implemented here will override those of the underlying delegate. Simply implement a method with the same signature, and the local method will be called rather than the delegate.

Author:
brettw

Constructor Summary
JdbcResultSetHandle(ResultSet delegate, BaseProxyHandlerClass statementHandle)
           
 
Method Summary
 void close()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 Statement getStatement()
           
 boolean isWrapperFor(Class<?> iface)
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcResultSetHandle

public JdbcResultSetHandle(ResultSet delegate,
                           BaseProxyHandlerClass statementHandle)
Method Detail

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Throws:
SQLException

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired

close

public void close()
           throws SQLException
Throws:
SQLException

getStatement

public Statement getStatement()
                       throws SQLException
Throws:
SQLException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcCallableStatementHandle.html0000644000175000017500000004664612215446620026525 0ustar tonytony JdbcCallableStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class JdbcCallableStatementHandle

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.JdbcCallableStatementHandle
All Implemented Interfaces:
InvocationHandler

public class JdbcCallableStatementHandle
extends BaseProxyHandlerClass

CallableStatement Statement wrapper.

This class is a proxy handler for a CallableStatement. It does not implement the CallableStatement interface or extend a class directly, but you methods implemented here will override those of the underlying delegate. Simply implement a method with the same signature, and the local method will be called rather than the delegate.

Author:
brettw

Constructor Summary
JdbcCallableStatementHandle(CallableStatement delegate, JdbcPooledConnection pooledConnection)
           
 
Method Summary
 void close()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 boolean isWrapperFor(Class<?> iface)
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcCallableStatementHandle

public JdbcCallableStatementHandle(CallableStatement delegate,
                                   JdbcPooledConnection pooledConnection)
Method Detail

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Throws:
SQLException

close

public void close()
           throws SQLException
Throws:
SQLException


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/resource/jdbc/JdbcUncachedPreparedStatementHandle.html0000644000175000017500000006161412215446622030215 0ustar tonytony JdbcUncachedPreparedStatementHandle (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm.resource.jdbc
Class JdbcUncachedPreparedStatementHandle

java.lang.Object
  extended by bitronix.tm.resource.jdbc.BaseProxyHandlerClass
      extended by bitronix.tm.resource.jdbc.JdbcUncachedPreparedStatementHandle
All Implemented Interfaces:
InvocationHandler

public class JdbcUncachedPreparedStatementHandle
extends BaseProxyHandlerClass


Constructor Summary
JdbcUncachedPreparedStatementHandle(PreparedStatement delegate, JdbcPooledConnection pooledConnection)
           
 
Method Summary
 void close()
           
 boolean equals(Object object)
           
 ResultSet executeQuery()
           
 ResultSet executeQuery(String sql)
           
 ResultSet getGeneratedKeys()
           
 Object getProxiedDelegate()
          Must be implemented by the sub-class of this class.
 ResultSet getResultSet()
           
 boolean isWrapperFor(Class<?> iface)
           
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class bitronix.tm.resource.jdbc.BaseProxyHandlerClass
invoke
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcUncachedPreparedStatementHandle

public JdbcUncachedPreparedStatementHandle(PreparedStatement delegate,
                                           JdbcPooledConnection pooledConnection)
Method Detail

getProxiedDelegate

public Object getProxiedDelegate()
                          throws Exception
Description copied from class: BaseProxyHandlerClass
Must be implemented by the sub-class of this class. This method should return the "true" object to be delegated to in the case that the method is not overridden by the sub-class.

Specified by:
getProxiedDelegate in class BaseProxyHandlerClass
Returns:
the true delegate object
Throws:
Exception - can throw any exception if desired

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Throws:
SQLException

close

public void close()
           throws SQLException
Throws:
SQLException

executeQuery

public ResultSet executeQuery(String sql)
                       throws SQLException
Throws:
SQLException

getGeneratedKeys

public ResultSet getGeneratedKeys()
                           throws SQLException
Throws:
SQLException

getResultSet

public ResultSet getResultSet()
                       throws SQLException
Throws:
SQLException

executeQuery

public ResultSet executeQuery()
                       throws SQLException
Throws:
SQLException

equals

public boolean equals(Object object)
Overrides:
equals in class Object


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/bitronix/tm/BitronixTransactionManagerObjectFactory.html0000644000175000017500000003774112215446620026463 0ustar tonytony BitronixTransactionManagerObjectFactory (Bitronix Transaction Manager :: Core 2.1.4 API)

bitronix.tm
Class BitronixTransactionManagerObjectFactory

java.lang.Object
  extended by bitronix.tm.BitronixTransactionManagerObjectFactory
All Implemented Interfaces:
ObjectFactory
Direct Known Subclasses:
BitronixUserTransactionObjectFactory

public class BitronixTransactionManagerObjectFactory
extends Object
implements ObjectFactory

BitronixTransactionManager object factory for JNDI references.

Author:
lorban

Constructor Summary
BitronixTransactionManagerObjectFactory()
           
 
Method Summary
 Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
          Since there can be only one transaction manager per VM instance, this method always returns a reference to the unique BitronixTransactionManager object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitronixTransactionManagerObjectFactory

public BitronixTransactionManagerObjectFactory()
Method Detail

getObjectInstance

public Object getObjectInstance(Object obj,
                                Name name,
                                Context nameCtx,
                                Hashtable<?,?> environment)
                         throws Exception
Since there can be only one transaction manager per VM instance, this method always returns a reference to the unique BitronixTransactionManager object.

Specified by:
getObjectInstance in interface ObjectFactory
Returns:
the unique transaction manager instance.
Throws:
Exception
See Also:
BitronixTransactionManager


Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/index.html0000644000175000017500000000515712215446622015334 0ustar tonytony Bitronix Transaction Manager :: Core 2.1.4 API <H2> Frame Alert</H2> <P> This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. <BR> Link to<A HREF="overview-summary.html">Non-frame version.</A> btm-dist-2.1.4/doc/api/deprecated-list.html0000644000175000017500000001424712215446622017276 0ustar tonytony Deprecated List (Bitronix Transaction Manager :: Core 2.1.4 API)

Deprecated API


Contents
Deprecated Methods
bitronix.tm.Configuration.getBackgroundRecoveryInterval()
          superceded by #getBackgroundRecoveryIntervalSeconds(). 
bitronix.tm.Configuration.setBackgroundRecoveryInterval(int)
          superceded by #setBackgroundRecoveryIntervalSeconds(int). 
 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/overview-summary.html0000644000175000017500000002206612215446622017564 0ustar tonytony Overview (Bitronix Transaction Manager :: Core 2.1.4 API)

Bitronix Transaction Manager 2.1.4 API

Packages
bitronix.tm JTA interfaces implementations and global services.
bitronix.tm.gui GUI admin console.
bitronix.tm.internal Internal implementation details.
bitronix.tm.jndi JNDI provider implementation that allows looking up transaction manager and resources.
bitronix.tm.journal Transactions disk journal.
bitronix.tm.recovery Recovery logic.
bitronix.tm.resource Transaction Manager's resource management services.
bitronix.tm.resource.common Resource management code common across all resource types.
bitronix.tm.resource.ehcache Ehcache specific resource management code.
bitronix.tm.resource.jdbc JDBC specific resource management code.
bitronix.tm.resource.jdbc.lrc XADataSource emulator using Last Resource Commit on an underlying non-XA DataSource.
bitronix.tm.resource.jms Synchronous JMS specific resource management code.
bitronix.tm.resource.jms.lrc XAConnectionFactory emulator using Last Resource Commit on an underlying non-XA ConnectionFactory.
bitronix.tm.timer Timed tasks scheduler.
bitronix.tm.twopc Two-phase commit logic.
bitronix.tm.twopc.executor Two-phase commit commands executors.
bitronix.tm.utils Misc utility classes.

 



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/serialized-form.html0000644000175000017500000013036712215446622017323 0ustar tonytony Serialized Form (Bitronix Transaction Manager :: Core 2.1.4 API)

Serialized Form


Package bitronix.tm.gui

Class bitronix.tm.gui.Console extends JFrame implements Serializable

Serialized Fields

tabbedPane

JTabbedPane tabbedPane

rawViewTransactionsTable

JTable rawViewTransactionsTable

pendingViewTransactionsTable

JTable pendingViewTransactionsTable

rawTransactionsTableScrollpane

JScrollPane rawTransactionsTableScrollpane

pendingTransactionsTableScrollpane

JScrollPane pendingTransactionsTableScrollpane

resourcesPanel

ResourcesPanel resourcesPanel

statusBarPanel

JPanel statusBarPanel

statusLabel

JLabel statusLabel

transactionLogHeaderPanel1

TransactionLogHeaderPanel transactionLogHeaderPanel1

transactionLogHeaderPanel2

TransactionLogHeaderPanel transactionLogHeaderPanel2

menuBar

JMenuBar menuBar

activeLogFile

File activeLogFile

passiveLogFile

File passiveLogFile

realActiveLogFile

File realActiveLogFile

Class bitronix.tm.gui.DuplicatedGtridTableModel extends DefaultTableModel implements Serializable

Serialized Fields

duplicatedGtrids

Map<K,V> duplicatedGtrids

Class bitronix.tm.gui.ResourcesPanel extends JPanel implements Serializable

Serialized Fields

splitPane

JSplitPane splitPane

resourcesTree

JTree resourcesTree

resourcesTreeScrollpane

JScrollPane resourcesTreeScrollpane

activeResource

JTextArea activeResource

Class bitronix.tm.gui.TransactionLogDialog extends JDialog implements Serializable

Serialized Fields

labelPanel

JPanel labelPanel

statusLabel

JLabel statusLabel

recordLengthLabel

JLabel recordLengthLabel

headerLengthLabel

JLabel headerLengthLabel

timeLabel

JLabel timeLabel

sequenceNumberLabel

JLabel sequenceNumberLabel

crc32Label

JLabel crc32Label

gtridLabel

JLabel gtridLabel

uniqueNamesLabel

JLabel uniqueNamesLabel

fieldPanel

JPanel fieldPanel

statusField

JTextField statusField

recordLengthField

JTextField recordLengthField

headerLengthField

JTextField headerLengthField

timeField

JTextField timeField

sequenceNumberField

JTextField sequenceNumberField

crc32Field

JTextField crc32Field

gtridField

JTextField gtridField

uniqueNamesField

JTextField uniqueNamesField

Class bitronix.tm.gui.TransactionLogHeaderPanel extends JPanel implements Serializable

Serialized Fields

logFileField

JTextField logFileField

timestampField

JTextField timestampField

stateField

JTextField stateField

positionField

JTextField positionField

Class bitronix.tm.gui.TransactionTableCellRenderer extends DefaultTableCellRenderer implements Serializable


Package bitronix.tm.internal

Class bitronix.tm.internal.BitronixHeuristicCommitException extends HeuristicCommitException implements Serializable

Class bitronix.tm.internal.BitronixHeuristicMixedException extends HeuristicMixedException implements Serializable

Class bitronix.tm.internal.BitronixHeuristicRollbackException extends HeuristicRollbackException implements Serializable

Class bitronix.tm.internal.BitronixMultiSystemException extends BitronixSystemException implements Serializable

Serialized Fields

exceptions

List<E> exceptions

resourceStates

List<E> resourceStates

Class bitronix.tm.internal.BitronixRollbackException extends RollbackException implements Serializable

Class bitronix.tm.internal.BitronixRollbackSystemException extends BitronixSystemException implements Serializable

Class bitronix.tm.internal.BitronixRuntimeException extends RuntimeException implements Serializable

Class bitronix.tm.internal.BitronixSystemException extends SystemException implements Serializable

Class bitronix.tm.internal.BitronixXAException extends XAException implements Serializable


Package bitronix.tm.journal

Class bitronix.tm.journal.CorruptedTransactionLogException extends IOException implements Serializable


Package bitronix.tm.recovery

Class bitronix.tm.recovery.RecoveryException extends Exception implements Serializable


Package bitronix.tm.resource

Class bitronix.tm.resource.ResourceConfigurationException extends RuntimeException implements Serializable


Package bitronix.tm.resource.common

Class bitronix.tm.resource.common.ResourceBean extends Object implements Serializable

Serialized Fields

className

String className

uniqueName

String uniqueName

automaticEnlistingEnabled

boolean automaticEnlistingEnabled

useTmJoin

boolean useTmJoin

driverProperties

Properties driverProperties

maxPoolSize

int maxPoolSize

minPoolSize

int minPoolSize

maxIdleTime

int maxIdleTime

acquireIncrement

int acquireIncrement

acquisitionTimeout

int acquisitionTimeout

deferConnectionRelease

boolean deferConnectionRelease

acquisitionInterval

int acquisitionInterval

allowLocalTransactions

boolean allowLocalTransactions

twoPcOrderingPosition

int twoPcOrderingPosition

applyTransactionTimeout

boolean applyTransactionTimeout

shareTransactionConnections

boolean shareTransactionConnections

disabled

boolean disabled

ignoreRecoveryFailures

boolean ignoreRecoveryFailures

Package bitronix.tm.resource.ehcache

Class bitronix.tm.resource.ehcache.EhCacheXAResourceProducer extends ResourceBean implements Serializable

Serialized Fields

xaResourceHolders

ConcurrentMap<K,V> xaResourceHolders

xaResourceHolderCounter

AtomicInteger xaResourceHolderCounter

recoveryXAResourceHolder

RecoveryXAResourceHolder recoveryXAResourceHolder

Package bitronix.tm.resource.jdbc

Class bitronix.tm.resource.jdbc.PoolingDataSource extends ResourceBean implements Serializable

Serialized Fields

testQuery

String testQuery

enableJdbc4ConnectionTest

boolean enableJdbc4ConnectionTest

preparedStatementCacheSize

int preparedStatementCacheSize

isolationLevel

String isolationLevel

cursorHoldability

String cursorHoldability

localAutoCommit

String localAutoCommit

jmxName

String jmxName

connectionCustomizers

List<E> connectionCustomizers

Package bitronix.tm.resource.jms

Class bitronix.tm.resource.jms.PoolingConnectionFactory extends ResourceBean implements Serializable

Serialized Fields

cacheProducersConsumers

boolean cacheProducersConsumers

testConnections

boolean testConnections

user

String user

password

String password

recoveryConnectionHandle

JmsConnectionHandle recoveryConnectionHandle

jmxName

String jmxName

Package bitronix.tm.timer

Class bitronix.tm.timer.TaskException extends Exception implements Serializable


Package bitronix.tm.twopc

Class bitronix.tm.twopc.PhaseException extends Exception implements Serializable

Serialized Fields

exceptions

List<E> exceptions

resourceStates

List<E> resourceStates

Package bitronix.tm.utils

Class bitronix.tm.utils.InitializationException extends RuntimeException implements Serializable

Class bitronix.tm.utils.PropertyException extends RuntimeException implements Serializable

Class bitronix.tm.utils.StackTrace extends Throwable implements Serializable



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/overview-frame.html0000644000175000017500000000635512215446622017164 0ustar tonytony Overview List (Bitronix Transaction Manager :: Core 2.1.4 API)
All Classes

Packages
bitronix.tm
bitronix.tm.gui
bitronix.tm.internal
bitronix.tm.jndi
bitronix.tm.journal
bitronix.tm.recovery
bitronix.tm.resource
bitronix.tm.resource.common
bitronix.tm.resource.ehcache
bitronix.tm.resource.jdbc
bitronix.tm.resource.jdbc.lrc
bitronix.tm.resource.jms
bitronix.tm.resource.jms.lrc
bitronix.tm.timer
bitronix.tm.twopc
bitronix.tm.twopc.executor
bitronix.tm.utils

  btm-dist-2.1.4/doc/api/help-doc.html0000644000175000017500000002336312215446622015717 0ustar tonytony API Help (Bitronix Transaction Manager :: Core 2.1.4 API)



How This API Document Is Organized

This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

Overview

The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

Package

Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types

Class/Interface

Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary

  • Field Detail
  • Constructor Detail
  • Method Detail
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

Annotation Type

Each annotation type has its own separate page with the following sections:

  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail

Enum

Each enum has its own separate page with the following sections:

  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail

Use

Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

Tree (Class Hierarchy)

There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.

Deprecated API

The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

Index

The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

Prev/Next

These links take you to the next or previous class, interface, package, or related page.

Frames/No Frames

These links show and hide the HTML frames. All pages are available with or without frames.

Serialized Form

Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

Constant Field Values

The Constant Field Values page lists the static final fields and their values.

This help file applies to API documentation generated using the standard doclet.



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/doc/api/overview-tree.html0000644000175000017500000013754312215446622017035 0ustar tonytony Class Hierarchy (Bitronix Transaction Manager :: Core 2.1.4 API)

Hierarchy For All Packages

Package Hierarchies:
bitronix.tm, bitronix.tm.gui, bitronix.tm.internal, bitronix.tm.jndi, bitronix.tm.journal, bitronix.tm.recovery, bitronix.tm.resource, bitronix.tm.resource.common, bitronix.tm.resource.ehcache, bitronix.tm.resource.jdbc, bitronix.tm.resource.jdbc.lrc, bitronix.tm.resource.jms, bitronix.tm.resource.jms.lrc, bitronix.tm.timer, bitronix.tm.twopc, bitronix.tm.twopc.executor, bitronix.tm.utils

Class Hierarchy

Interface Hierarchy



Copyright © 2006-2013 Bitronix Software. All Rights Reserved. btm-dist-2.1.4/integration/0000777000175000017500000000000012215446662014344 5ustar tonytonybtm-dist-2.1.4/release-notes-2.1.4.txt0000644000175000017500000000221412215444450015754 0ustar tonytonyBTM - Bitronix' JTA transaction manager ======================================= version 2.1.4, September 15, 2013 Getting started guide: http://docs.codehaus.org/display/BTM/NewUserGuide Best practices: http://docs.codehaus.org/display/BTM/JtaBestPractices API javadoc: http://btm.codehaus.org/api/2.1.4/ New features and bugs fixed in this release -------------------------------------------- Important note: starting with version 2.1.0, BTM does not support JDK 1.4 anymore. You have to use at least JDK 1.5. * BTM-126 Equality/wrapping of PreparedStatement * BTM-129 Crypting resource password with triple-DES (DES-EDE) does not work Using BTM --------- Required jars are distributed in the lib/ subdirectory. Latest Documentation: http://docs.codehaus.org/display/BTM/ Bug Reports: BTM JIRA (http://jira.codehaus.org/browse/BTM/) or BTM mailing list (http://www.nabble.com/Bitronix-Transaction-Manager-f25701.html) License ------- This software is distributed under the terms of the GNU Lesser General Public License (see license.txt). This product includes software developed by the Apache Software Foundation (http://www.apache.org/). btm-dist-2.1.4/test/0000777000175000017500000000000012215446662013000 5ustar tonytonybtm-dist-2.1.4/test/logback.xml0000644000175000017500000000250012147207062015106 0ustar tonytony OFF %d [%t] {%X{btm-gtrid}} [%p,%c{1}] %m%n target/tests.log %d [%-25.25t] {%-50X{btm-gtrid}} [%-5p] %m%n btm-gtrid N/A target/tests-${btm-gtrid}.log false %d [%-25.25t] [%-5p] %m%n btm-dist-2.1.4/test/oracle/0000755000175000017500000000000012136323160014226 5ustar tonytonybtm-dist-2.1.4/test/oracle/jdbc/0000755000175000017500000000000012136323160015130 5ustar tonytonybtm-dist-2.1.4/test/oracle/jdbc/xa/0000755000175000017500000000000012147207062015544 5ustar tonytonybtm-dist-2.1.4/test/oracle/jdbc/xa/OracleXAException.java0000644000175000017500000000070012147207062021721 0ustar tonytonypackage oracle.jdbc.xa; import javax.transaction.xa.XAException; public class OracleXAException extends XAException { private int oracleError; public OracleXAException(String msg, int oracleError) { super(msg); this.oracleError = oracleError; } public OracleXAException(int oracleError) { this.oracleError = oracleError; } public int getOracleError() { return oracleError; } } btm-dist-2.1.4/test/bitronix/0000755000175000017500000000000012136323160014617 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/0000755000175000017500000000000012147207062015243 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/timer/0000755000175000017500000000000012147207062016363 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/timer/TaskSchedulerTest.java0000644000175000017500000000602612147207062022633 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.timer; import bitronix.tm.recovery.Recoverer; import bitronix.tm.utils.MonotonicClock; import junit.framework.TestCase; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; /** * * @author lorban */ public class TaskSchedulerTest extends TestCase { private TaskScheduler ts; @Override protected void setUp() throws Exception { ts = new TaskScheduler(); ts.start(); } @Override protected void tearDown() throws Exception { assertEquals(0, ts.countTasksQueued()); ts.shutdown(); } public void testRecoveryTask() throws Exception { Recoverer recoverer = new Recoverer(); ts.scheduleRecovery(recoverer, new Date()); assertEquals(1, ts.countTasksQueued()); Thread.sleep(1100); assertEquals(1, ts.countTasksQueued()); ts.cancelRecovery(recoverer); assertEquals(0, ts.countTasksQueued()); Thread.sleep(1100); assertEquals(0, ts.countTasksQueued()); } public void testTaskOrdering() throws Exception { List result = Collections.synchronizedList(new ArrayList()); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 100), ts, 0, result)); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 200), ts, 1, result)); ts.addTask(new SimpleTask(new Date(MonotonicClock.currentTimeMillis() + 300), ts, 2, result)); ts.join(1000); assertEquals(0, result.get(0).getObject()); assertEquals(1, result.get(1).getObject()); assertEquals(2, result.get(2).getObject()); } private static class SimpleTask extends Task { private final Object obj; private final List result; protected SimpleTask(Date executionTime, TaskScheduler scheduler, Object obj, List result) { super(executionTime, scheduler); this.obj = obj; this.result = result; } @Override public Object getObject() { return obj; } @Override public void execute() throws TaskException { result.add(this); } } } btm-dist-2.1.4/test/bitronix/tm/RestartTest.java0000644000175000017500000000726512147207062020404 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import java.util.Iterator; import junit.framework.TestCase; import bitronix.tm.mock.resource.jdbc.MockitoXADataSource; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.jdbc.PoolingDataSource; /** * * @author lorban */ public class RestartTest extends TestCase { protected void setUp() throws Exception { Iterator it = ResourceRegistrar.getResourcesUniqueNames().iterator(); while (it.hasNext()) { String name = (String) it.next(); ResourceRegistrar.unregister(ResourceRegistrar.get(name)); } } public void testRestartWithoutLoaderNoReuseResource() throws Exception { for (int i=0; i<3 ;i++) { PoolingDataSource pds = new PoolingDataSource(); pds.setClassName(MockitoXADataSource.class.getName()); pds.setUniqueName("ds"); pds.setMaxPoolSize(1); pds.init(); try { ResourceRegistrar.register(pds); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException ex) { assertEquals("resource with uniqueName 'ds' has already been registered", ex.getMessage()); } BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.shutdown(); assertEquals(1, ResourceRegistrar.getResourcesUniqueNames().size()); pds.close(); } } public void testRestartWithoutLoaderReuseResource() throws Exception { PoolingDataSource pds = new PoolingDataSource(); pds.setClassName(MockitoXADataSource.class.getName()); pds.setUniqueName("ds"); pds.setMaxPoolSize(1); pds.init(); for (int i=0; i<3 ;i++) { try { ResourceRegistrar.register(pds); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException ex) { assertEquals("resource with uniqueName 'ds' has already been registered", ex.getMessage()); } BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.shutdown(); assertEquals(1, ResourceRegistrar.getResourcesUniqueNames().size()); } pds.close(); } public void testRestartWithLoader() throws Exception { for (int i=0; i<3 ;i++) { TransactionManagerServices.getConfiguration().setResourceConfigurationFilename(getClass().getResource("RestartTest.properties").getFile()); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); assertEquals("at loop iteration #" + (i+1), 1, ResourceRegistrar.getResourcesUniqueNames().size()); tm.shutdown(); assertEquals("at loop iteration #" + (i+1), 0, ResourceRegistrar.getResourcesUniqueNames().size()); } } } btm-dist-2.1.4/test/bitronix/tm/utils/0000755000175000017500000000000012215440314016376 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/utils/SchedulerTest.java0000644000175000017500000002764512147207062022042 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import junit.framework.TestCase; import bitronix.tm.resource.common.ResourceBean; import bitronix.tm.internal.XAResourceHolderState; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Set; import java.util.List; /** * * @author lorban */ public class SchedulerTest extends TestCase { public void testNaturalOrdering() throws Exception { Scheduler resourceScheduler = new Scheduler(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition()); assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString()); /* testing natural order priorities */ assertEquals(5, resourceScheduler.size()); Set priorities = resourceScheduler.getNaturalOrderPositions(); assertEquals(3, priorities.size()); Iterator it = priorities.iterator(); Integer key0 = it.next(); Integer key1 = it.next(); Integer key2 = it.next(); assertFalse(it.hasNext()); List list0 = resourceScheduler.getByNaturalOrderForPosition(key0); assertEquals(1, list0.size()); assertTrue(xarhs3 == list0.get(0)); List list1 = resourceScheduler.getByNaturalOrderForPosition(key1); assertEquals(3, list1.size()); assertTrue(xarhs0 == list1.get(0)); assertTrue(xarhs1 == list1.get(1)); assertTrue(xarhs2 == list1.get(2)); List list2 = resourceScheduler.getByNaturalOrderForPosition(key2); assertEquals(1, list2.size()); assertTrue(xarhs4 == list2.get(0)); } public void testReverseOrdering() throws Exception { Scheduler resourceScheduler = new Scheduler(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition()); assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString()); Set reverseOrderPriorities = resourceScheduler.getReverseOrderPositions(); assertEquals(3, reverseOrderPriorities.size()); Iterator itReverse = reverseOrderPriorities.iterator(); Integer key0r = itReverse.next(); Integer key1r = itReverse.next(); Integer key2r = itReverse.next(); assertFalse(itReverse.hasNext()); List list0r = resourceScheduler.getByReverseOrderForPosition(key0r); assertEquals(1, list0r.size()); assertTrue(xarhs4 == list0r.get(0)); List list1r = resourceScheduler.getByReverseOrderForPosition(key1r); assertEquals(3, list1r.size()); assertTrue(xarhs2 == list1r.get(0)); assertTrue(xarhs1 == list1r.get(1)); assertTrue(xarhs0 == list1r.get(2)); List list2r = resourceScheduler.getByReverseOrderForPosition(key2r); assertEquals(1, list2r.size()); assertTrue(xarhs3 == list2r.get(0)); } public void testIterator() { Scheduler resourceScheduler = new Scheduler(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition()); assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString()); Iterator it = resourceScheduler.iterator(); assertTrue(it.hasNext()); assertTrue(xarhs3 == it.next()); assertTrue(xarhs0 == it.next()); assertTrue(xarhs1 == it.next()); assertTrue(xarhs2 == it.next()); assertTrue(xarhs4 == it.next()); assertFalse(it.hasNext()); it = resourceScheduler.iterator(); assertTrue(it.hasNext()); assertTrue(xarhs3 == it.next()); it.remove(); assertTrue(xarhs0 == it.next()); it.remove(); assertTrue(xarhs1 == it.next()); it.remove(); assertTrue(xarhs2 == it.next()); it.remove(); assertTrue(xarhs4 == it.next()); it.remove(); assertFalse(it.hasNext()); assertEquals(0, resourceScheduler.size()); } public void testReverseIterator() { Scheduler resourceScheduler = new Scheduler(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs2 = new XAResourceHolderState(null, new MockResourceBean(1)); XAResourceHolderState xarhs3 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs4 = new XAResourceHolderState(null, new MockResourceBean(10)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs2, xarhs2.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs3, xarhs3.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs4, xarhs4.getTwoPcOrderingPosition()); assertEquals("a Scheduler with 5 object(s) in 3 position(s)", resourceScheduler.toString()); Iterator it = resourceScheduler.reverseIterator(); assertTrue(it.hasNext()); assertTrue(xarhs4 == it.next()); assertTrue(xarhs0 == it.next()); assertTrue(xarhs1 == it.next()); assertTrue(xarhs2 == it.next()); assertTrue(xarhs3 == it.next()); assertFalse(it.hasNext()); } public void testRemove() { Scheduler resourceScheduler = new Scheduler(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.remove(xarhs0); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); Iterator it = resourceScheduler.iterator(); assertTrue(it.hasNext()); assertTrue(xarhs0 == it.next()); it.remove(); assertTrue(xarhs1 == it.next()); it.remove(); } public void testReverseRemove() { Scheduler resourceScheduler = new Scheduler(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(1)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); resourceScheduler.remove(xarhs0); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); Iterator it = resourceScheduler.reverseIterator(); assertTrue(it.hasNext()); assertTrue(xarhs1 == it.next()); it.remove(); assertTrue(xarhs0 == it.next()); it.remove(); } public void testHasNext() { Scheduler resourceScheduler = new Scheduler(); XAResourceHolderState xarhs0 = new XAResourceHolderState(null, new MockResourceBean(0)); XAResourceHolderState xarhs1 = new XAResourceHolderState(null, new MockResourceBean(10)); resourceScheduler.add(xarhs0, xarhs0.getTwoPcOrderingPosition()); resourceScheduler.add(xarhs1, xarhs1.getTwoPcOrderingPosition()); Iterator it = resourceScheduler.iterator(); for (int i=0; i<10 ;i++) { assertTrue(it.hasNext()); } it.next(); for (int i=0; i<10 ;i++) { assertTrue(it.hasNext()); } it.next(); for (int i=0; i<10 ;i++) { assertFalse(it.hasNext()); } try { it.next(); fail("expected NoSuchElementException"); } catch (NoSuchElementException ex) { // expected } } private static int counter = 0; private static int incCounter() { return counter++; } private class MockResourceBean extends ResourceBean { private int number; private int commitOrderingPosition; private MockResourceBean(int commitOrderingPosition) { this.number = incCounter(); this.commitOrderingPosition = commitOrderingPosition; } public int getTwoPcOrderingPosition() { return commitOrderingPosition; } public String toString() { return "a MockResourceBean #" + number; } } } btm-dist-2.1.4/test/bitronix/tm/utils/DefaultExceptionAnalyzerTest.java0000644000175000017500000000121212147207062025053 0ustar tonytonypackage bitronix.tm.utils; import bitronix.tm.internal.BitronixXAException; import junit.framework.TestCase; import oracle.jdbc.xa.OracleXAException; import javax.transaction.xa.XAException; /** * @author lorban */ public class DefaultExceptionAnalyzerTest extends TestCase { public void testExtract() throws Exception { DefaultExceptionAnalyzer analyzer = new DefaultExceptionAnalyzer(); assertNull(analyzer.extractExtraXAExceptionDetails(new BitronixXAException("XA error", XAException.XA_HEURCOM))); assertEquals("ORA-1234", analyzer.extractExtraXAExceptionDetails(new OracleXAException(1234))); } } btm-dist-2.1.4/test/bitronix/tm/utils/EncoderTest.java0000644000175000017500000000421112147207062021463 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import junit.framework.TestCase; /** * * @author lorban */ public class EncoderTest extends TestCase { public void testLongEncodingDecoding() { byte[] longAsBytes; long result; longAsBytes = Encoder.longToBytes(Long.MAX_VALUE); result = Encoder.bytesToLong(longAsBytes, 0); assertEquals(Long.MAX_VALUE, result); longAsBytes = Encoder.longToBytes(Long.MIN_VALUE); result = Encoder.bytesToLong(longAsBytes, 0); assertEquals(Long.MIN_VALUE, result); longAsBytes = Encoder.longToBytes(-1L); result = Encoder.bytesToLong(longAsBytes, 0); assertEquals(-1L, result); long timestamp = System.currentTimeMillis(); longAsBytes = Encoder.longToBytes(timestamp); result = Encoder.bytesToLong(longAsBytes, 0); assertEquals(timestamp, result); byte[] intAsBytes = Encoder.intToBytes(-1); int resultAsInt = Encoder.bytesToInt(intAsBytes, 0); assertEquals(-1, resultAsInt); try { Encoder.bytesToLong(new byte[4], 0); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException ex) { assertEquals("a long can only be decoded from 8 bytes of an array (got a 4 byte(s) array, must start at position 0)", ex.getMessage()); } } } btm-dist-2.1.4/test/bitronix/tm/utils/PropertyUtilsTest.java0000644000175000017500000002156412147207062022763 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import junit.framework.TestCase; import java.util.Properties; import java.util.Map; /** * * @author lorban */ public class PropertyUtilsTest extends TestCase { public void testSetProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "props.key", "value"); assertEquals("value", destination.getProps().getProperty("key")); PropertyUtils.setProperty(destination, "subDestination.props.key", "value"); assertEquals("value", destination.getSubDestination().getProps().getProperty("key")); PropertyUtils.setProperty(destination, "anInteger", "10"); assertEquals(10, destination.getAnInteger()); PropertyUtils.setProperty(destination, "subDestination.anInteger", "20"); assertEquals(20, destination.getSubDestination().getAnInteger()); PropertyUtils.setProperty(destination, "aBoolean", "true"); assertEquals(true, destination.isABoolean()); PropertyUtils.setProperty(destination, "aWriteOnlyInt", "20"); PrivateDestination privateDestination = new PrivateDestination(); try { PropertyUtils.setProperty(privateDestination, "subDestination.props.key", "value"); fail("it is not possible to set the 'subDestination' property, PropertyException should have been thrown"); } catch (PropertyException ex) { assertEquals("cannot set property 'subDestination.props.key' - 'subDestination' is null and cannot be auto-filled", ex.getMessage()); } } public void testSetPropertiesObjectLongKey() throws Exception { PrivateDestination destination = new PrivateDestination(); PropertyUtils.setProperty(destination, "props.key", "value1"); PropertyUtils.setProperty(destination, "props.a.dotted.key", "value2"); assertEquals("value1", destination.getProps().get("key")); assertEquals("value2", destination.getProps().get("a.dotted.key")); } public void testSmartGetProperties() throws Exception { Destination destination = new Destination(); destination.setAnInteger(10); destination.setABoolean(true); Properties props = new Properties(); props.setProperty("number1", "one"); props.setProperty("number2", "two"); destination.setProps(props); Map map = PropertyUtils.getProperties(destination); assertEquals(12, map.size()); assertEquals("one", map.get("props.number1")); assertEquals("two", map.get("props.number2")); assertEquals(new Integer(10), map.get("anInteger")); assertEquals(new Boolean(true), map.get("aBoolean")); assertEquals(new Boolean(false), map.get("anotherBoolean")); assertNull(map.get("subDestination")); } public void testSetPrimitiveTypes() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "aString", "this is my string"); PropertyUtils.setProperty(destination, "aBoolean", "true"); PropertyUtils.setProperty(destination, "aByte", "100"); PropertyUtils.setProperty(destination, "aShort", "20000"); PropertyUtils.setProperty(destination, "anInteger", "300000"); PropertyUtils.setProperty(destination, "aLong", "4000000"); PropertyUtils.setProperty(destination, "aFloat", "3.14"); PropertyUtils.setProperty(destination, "aDouble", "0.654987"); assertEquals("this is my string", destination.getAString()); assertEquals(true, destination.isABoolean()); assertEquals(100, destination.getAByte()); assertEquals(20000, destination.getAShort()); assertEquals(300000, destination.getAnInteger()); assertEquals(4000000, destination.getALong()); assertEquals(3.14f, destination.getAFloat(), 0.01f); assertEquals(0.654987, destination.getADouble(), 0.000001); } public void testGetPrimitiveTypes() throws Exception { Destination destination = new Destination(); destination.setAString("this is my string"); destination.setABoolean(true); destination.setAByte((byte) 100); destination.setAShort((short) 20000); destination.setAnInteger(300000); destination.setALong(4000000L); destination.setAFloat(3.14f); destination.setADouble(0.654987); assertEquals("this is my string", PropertyUtils.getProperty(destination, "aString")); assertEquals(Boolean.TRUE, PropertyUtils.getProperty(destination, "aBoolean")); assertEquals(new Byte((byte) 100), PropertyUtils.getProperty(destination, "aByte")); assertEquals(new Short((short) 20000), PropertyUtils.getProperty(destination, "aShort")); assertEquals(new Integer(300000), PropertyUtils.getProperty(destination, "anInteger")); assertEquals(new Long(4000000L), PropertyUtils.getProperty(destination, "aLong")); assertEquals(new Float(3.14f), PropertyUtils.getProperty(destination, "aFloat")); assertEquals(new Double(0.654987), PropertyUtils.getProperty(destination, "aDouble")); } public static class Destination { private Properties props; private Destination subDestination; private int anInteger; private int aWriteOnlyInt; private boolean aBoolean; private boolean anotherBoolean; private String aString; private byte aByte; private short aShort; private long aLong; private float aFloat; private double aDouble; public Properties getProps() { return props; } public void setProps(Properties props) { this.props = props; } public Destination getSubDestination() { return subDestination; } public void setSubDestination(Destination subDestination) { this.subDestination = subDestination; } public int getAnInteger() { return anInteger; } public void setAnInteger(int anInteger) { this.anInteger = anInteger; } public void setAWriteOnlyInt(int aWriteOnlyInt) { this.aWriteOnlyInt = aWriteOnlyInt; } public boolean isABoolean() { return aBoolean; } public void setABoolean(boolean aBoolean) { this.aBoolean = aBoolean; } public boolean isAnotherBoolean() { return anotherBoolean; } public void setAnotherBoolean(boolean anotherBoolean) { this.anotherBoolean = anotherBoolean; } public String getAString() { return aString; } public void setAString(String aString) { this.aString = aString; } public byte getAByte() { return aByte; } public void setAByte(byte aByte) { this.aByte = aByte; } public short getAShort() { return aShort; } public void setAShort(short aShort) { this.aShort = aShort; } public long getALong() { return aLong; } public void setALong(long aLong) { this.aLong = aLong; } public float getAFloat() { return aFloat; } public void setAFloat(float aFloat) { this.aFloat = aFloat; } public double getADouble() { return aDouble; } public void setADouble(double aDouble) { this.aDouble = aDouble; } } private class PrivateDestination { private Properties props; private PrivateDestination subDestination; public Properties getProps() { return props; } public void setProps(Properties props) { this.props = props; } public PrivateDestination getSubDestination() { return subDestination; } public void setSubDestination(PrivateDestination subDestination) { this.subDestination = subDestination; } } } btm-dist-2.1.4/test/bitronix/tm/utils/CryptoEngineTest.java0000644000175000017500000000301512215440314022506 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import junit.framework.TestCase; /** * * @author lorban */ public class CryptoEngineTest extends TestCase { public void testCryptDES() throws Exception { String textToCrypt = "java and bitronix will rule the earth"; String cypherText = CryptoEngine.crypt("DES", textToCrypt); String decryptedText = CryptoEngine.decrypt("DES", cypherText); assertEquals(textToCrypt, decryptedText); } public void testCrypt3DES() throws Exception { String textToCrypt = "java"; String cypherText = CryptoEngine.crypt("DESede", textToCrypt); String decryptedText = CryptoEngine.decrypt("DESede", cypherText); assertEquals(textToCrypt, decryptedText); } } btm-dist-2.1.4/test/bitronix/tm/utils/UidGeneratorTest.java0000644000175000017500000000571512147207062022506 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.utils; import junit.framework.TestCase; import java.util.Arrays; import java.util.HashSet; /** * * @author lorban */ public class UidGeneratorTest extends TestCase { public void testHexaStringEncoder() throws Exception { byte[] result = Encoder.intToBytes(0x80); String hexString = new Uid(result).toString(); assertEquals("00000080", hexString); result = Encoder.longToBytes(0x81); hexString = new Uid(result).toString(); assertEquals("0000000000000081", hexString); result = Encoder.shortToBytes((short)0xff); hexString = new Uid(result).toString(); assertEquals("00FF", hexString); } public void testUniqueness() throws Exception { final int count = 10000; HashSet uids = new HashSet(2048); for (int i=0; i recoverer presumes they have aborted and rolls * them back. * @throws Exception */ public void testRecoverPresumedAbort() throws Exception { byte[] gtrid = UidGenerator.generateUid().getArray(); xaResource.addInDoubtXid(new MockXid(0, gtrid, BitronixXid.FORMAT_ID)); xaResource.addInDoubtXid(new MockXid(1, gtrid, BitronixXid.FORMAT_ID)); xaResource.addInDoubtXid(new MockXid(2, gtrid, BitronixXid.FORMAT_ID)); TransactionManagerServices.getRecoverer().run(); assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount()); assertEquals(3, TransactionManagerServices.getRecoverer().getRolledbackCount()); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); } /** * Create 3 XIDs on the resource that are not in the journal -> recoverer presumes they have aborted and rolls * them back. * @throws Exception */ public void testIncrementalRecoverPresumedAbort() throws Exception { byte[] gtrid = UidGenerator.generateUid().getArray(); xaResource.addInDoubtXid(new MockXid(0, gtrid, BitronixXid.FORMAT_ID)); xaResource.addInDoubtXid(new MockXid(1, gtrid, BitronixXid.FORMAT_ID)); xaResource.addInDoubtXid(new MockXid(2, gtrid, BitronixXid.FORMAT_ID)); IncrementalRecoverer.recover(pds); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); } /** * Create 3 XIDs on the resource that are in the journal -> recoverer commits them. * @throws Exception */ public void testRecoverCommitting() throws Exception { Xid xid0 = new MockXid(0, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid0); Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid1); Xid xid2 = new MockXid(2, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid2); Set names = new HashSet(); names.add(pds.getUniqueName()); journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names); journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names); journal.log(Status.STATUS_COMMITTING, new Uid(xid2.getGlobalTransactionId()), names); TransactionManagerServices.getRecoverer().run(); assertEquals(3, TransactionManagerServices.getRecoverer().getCommittedCount()); assertEquals(0, TransactionManagerServices.getRecoverer().getRolledbackCount()); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); } /** * Create 3 XIDs on the resource that are in the journal -> recoverer commits them. * @throws Exception */ public void testIncrementalRecoverCommitting() throws Exception { Xid xid0 = new MockXid(0, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid0); Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid1); Xid xid2 = new MockXid(2, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid2); Set names = new HashSet(); names.add(pds.getUniqueName()); journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names); journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names); journal.log(Status.STATUS_COMMITTING, new Uid(xid2.getGlobalTransactionId()), names); IncrementalRecoverer.recover(pds); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); } public void testSkipInFlightRollback() throws Exception { BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager(); Uid uid0 = UidGenerator.generateUid(); Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid0); assertNull(btm.getCurrentTransaction()); Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one btm.begin(); Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid1); TransactionManagerServices.getRecoverer().run(); btm.rollback(); assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount()); assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount()); assertEquals(1, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); btm.shutdown(); TransactionManagerServices.getJournal().open(); TransactionManagerServices.getRecoverer().run(); assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount()); assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount()); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); } public void testSkipInFlightCommit() throws Exception { BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager(); Uid uid0 = UidGenerator.generateUid(); Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid0); Set names = new HashSet(); names.add(pds.getUniqueName()); journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names); assertNull(btm.getCurrentTransaction()); Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one btm.begin(); Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid1); names = new HashSet(); names.add(pds.getUniqueName()); journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names); TransactionManagerServices.getRecoverer().run(); btm.rollback(); assertEquals(1, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); btm.shutdown(); TransactionManagerServices.getJournal().open(); TransactionManagerServices.getRecoverer().run(); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); } public void testRecoverMissingResource() throws Exception { final Xid xid0 = new MockXid(0, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID); xaResource.addInDoubtXid(xid0); Set names = new HashSet(); names.add("no-such-registered-resource"); journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names); assertEquals(1, TransactionManagerServices.getJournal().collectDanglingRecords().size()); // the TM must run the recoverer in this scenario TransactionManagerServices.getTransactionManager(); assertEquals(1, TransactionManagerServices.getJournal().collectDanglingRecords().size()); assertNull(TransactionManagerServices.getRecoverer().getCompletionException()); assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount()); assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount()); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); // the TM is running, adding this resource will kick incremental recovery on it PoolingDataSource pds = new PoolingDataSource() { public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception { JdbcPooledConnection pc = (JdbcPooledConnection) super.createPooledConnection(xaFactory, bean); MockXAResource xaResource = (MockXAResource) pc.getXAResource(); xaResource.addInDoubtXid(UidGenerator.generateXid(new Uid(xid0.getGlobalTransactionId()))); return pc; } }; pds.setClassName(MockitoXADataSource.class.getName()); pds.setUniqueName("no-such-registered-resource"); pds.setMinPoolSize(1); pds.setMaxPoolSize(1); pds.init(); Connection connection = pds.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection); XAResource xaResource = handle.getPooledConnection().getXAResource(); handle.close(); assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length); assertEquals(0, TransactionManagerServices.getJournal().collectDanglingRecords().size()); pds.close(); TransactionManagerServices.getTransactionManager().shutdown(); } volatile boolean listenerExecuted = false; public void testBackgroundRecovererSkippingInFlightTransactions() throws Exception { // change disk journal into mock journal Field field = TransactionManagerServices.class.getDeclaredField("journalRef"); field.setAccessible(true); AtomicReference journalRef = (AtomicReference) field.get(TransactionManagerServices.class); journalRef.set(new MockJournal()); pds.setMaxPoolSize(2); BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager(); final Recoverer recoverer = TransactionManagerServices.getRecoverer(); try { btm.begin(); BitronixTransaction tx = btm.getCurrentTransaction(); tx.addTransactionStatusChangeListener(new TransactionStatusChangeListener() { public void statusChanged(int oldStatus, int newStatus) { if (newStatus != Status.STATUS_COMMITTING) return; recoverer.run(); assertEquals(0, recoverer.getCommittedCount()); assertEquals(0, recoverer.getRolledbackCount()); assertNull(recoverer.getCompletionException()); listenerExecuted = true; } }); Connection c = pds.getConnection(); c.createStatement(); c.close(); xaResource.addInDoubtXid(new MockXid(new byte[] {0, 1, 2}, tx.getResourceManager().getGtrid().getArray(), BitronixXid.FORMAT_ID)); btm.commit(); } finally { btm.shutdown(); } assertTrue("recoverer did not run between phases 1 and 2", listenerExecuted); int committedCount = 0; List events = EventRecorder.getOrderedEvents(); for (int i = 0; i < events.size(); i++) { Event event = (Event) events.get(i); if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_COMMITTED) committedCount++; } } assertEquals("TX has been committed more or less times than just once", 1, committedCount); } public void testReentrance() throws Exception { log.debug("Start test RecovererTest.testReentrance()"); final int THREAD_COUNT = 10; Recoverer recoverer = new Recoverer(); xaResource.setRecoveryDelay(1000); List threads = new ArrayList(); //create for (int i=0; i< THREAD_COUNT;i++) { Thread t = new Thread(recoverer); threads.add(t); } //start for (int i=0; i< THREAD_COUNT;i++) { Thread t = (Thread) threads.get(i); t.start(); } //join for (int i=0; i< THREAD_COUNT;i++) { Thread t = (Thread) threads.get(i); t.join(); } assertEquals(1, recoverer.getExecutionsCount()); } } btm-dist-2.1.4/test/bitronix/tm/ExceptionAnalyzerTest.java0000644000175000017500000000376412147207062022424 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.utils.DefaultExceptionAnalyzer; import bitronix.tm.utils.ExceptionAnalyzer; import junit.framework.TestCase; import javax.transaction.xa.XAException; /** * * @author lorban */ public class ExceptionAnalyzerTest extends TestCase { public void testExceptionAnalyzer() throws Exception { assertEquals(DefaultExceptionAnalyzer.class, TransactionManagerServices.getExceptionAnalyzer().getClass()); TransactionManagerServices.clear(); TransactionManagerServices.getConfiguration().setExceptionAnalyzer("nonexistentClass"); assertEquals(DefaultExceptionAnalyzer.class, TransactionManagerServices.getExceptionAnalyzer().getClass()); TransactionManagerServices.clear(); TransactionManagerServices.getConfiguration().setExceptionAnalyzer(TestExceptionAnalyzer.class.getName()); assertEquals(TestExceptionAnalyzer.class, TransactionManagerServices.getExceptionAnalyzer().getClass()); } public static class TestExceptionAnalyzer implements ExceptionAnalyzer { public String extractExtraXAExceptionDetails(XAException ex) { return ""; } public void shutdown() { } } } btm-dist-2.1.4/test/bitronix/tm/jndi/0000755000175000017500000000000012147207062016167 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/jndi/JndiTest.java0000644000175000017500000000771512147207062020570 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.jndi; import java.util.Hashtable; import javax.naming.*; import junit.framework.TestCase; import bitronix.tm.*; import bitronix.tm.mock.resource.jdbc.MockitoXADataSource; import bitronix.tm.resource.jdbc.PoolingDataSource; /** * * @author lorban */ public class JndiTest extends TestCase { private BitronixTransactionManager transactionManager; protected void setUp() throws Exception { transactionManager = TransactionManagerServices.getTransactionManager(); } protected void tearDown() throws Exception { transactionManager.shutdown(); } public void testNameParser() throws Exception { BitronixContext bitronixContext = new BitronixContext(); Name name = bitronixContext.getNameParser("").parse("java:comp/UserTransaction"); assertEquals("java:comp/UserTransaction", name.toString()); assertSame(BitronixTransactionManager.class, bitronixContext.lookup(name).getClass()); name = bitronixContext.getNameParser(new CompositeName()).parse("java:comp/UserTransaction"); assertEquals("java:comp/UserTransaction", name.toString()); assertSame(BitronixTransactionManager.class, bitronixContext.lookup(name).getClass()); } public void testDefaultUserTransactionAndResources() throws Exception { PoolingDataSource pds = new PoolingDataSource(); pds.setMaxPoolSize(1); pds.setClassName(MockitoXADataSource.class.getName()); pds.setUniqueName("jdbc/pds"); pds.init(); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, BitronixInitialContextFactory.class.getName()); Context ctx = new InitialContext(env); assertTrue(transactionManager == ctx.lookup("java:comp/UserTransaction")); try { ctx.lookup("aaa"); fail("expected NameNotFoundException"); } catch (NameNotFoundException ex) { assertEquals("unable to find a bound object at name 'aaa'", ex.getMessage()); } assertTrue(pds == ctx.lookup("jdbc/pds")); ctx.close(); pds.close(); } public void testSpecialUserTransactionName() throws Exception { transactionManager.shutdown(); TransactionManagerServices.getConfiguration().setJndiUserTransactionName("TM"); transactionManager = TransactionManagerServices.getTransactionManager(); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, BitronixInitialContextFactory.class.getName()); Context ctx = new InitialContext(env); try { ctx.lookup("java:comp/UserTransaction"); fail("expected NameNotFoundException"); } catch (NameNotFoundException ex) { assertEquals("unable to find a bound object at name 'java:comp/UserTransaction'", ex.getMessage()); } assertTrue(transactionManager == ctx.lookup("TM")); try { ctx.lookup("aaa"); fail("expected NameNotFoundException"); } catch (NameNotFoundException ex) { assertEquals("unable to find a bound object at name 'aaa'", ex.getMessage()); } ctx.close(); } } btm-dist-2.1.4/test/bitronix/tm/ConfigurationTest.java0000644000175000017500000001143312147207062021557 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import junit.framework.TestCase; import java.util.Properties; /** * * @author lorban */ public class ConfigurationTest extends TestCase { public void testGetString() throws Exception { Properties props = new Properties(); props.setProperty("1", "one"); props.setProperty("2", "two"); System.setProperty("3", "three"); props.setProperty("4", "four"); System.setProperty("4", "four-sys"); props.setProperty("12", "${1} ${2}"); props.setProperty("13", "${1} ${3}"); props.setProperty("14", "${1} ${}"); props.setProperty("15", "${1} ${tatata"); props.setProperty("16", "${1} ${4}"); props.setProperty("17", "x$"); props.setProperty("18", "x${"); assertEquals("one", Configuration.getString(props, "1", null)); assertEquals("two", Configuration.getString(props, "2", null)); assertEquals("three", Configuration.getString(props, "3", null)); assertEquals("one two", Configuration.getString(props, "12", null)); assertEquals("one three", Configuration.getString(props, "13", null)); assertEquals("one four-sys", Configuration.getString(props, "16", null)); try { Configuration.getString(props, "14", null); fail("expected IllegalArgumentException: property ref cannot refer to an empty name: ${}"); } catch (IllegalArgumentException ex) { assertEquals("property ref cannot refer to an empty name: ${}", ex.getMessage()); } try { Configuration.getString(props, "15", null); fail("expected IllegalArgumentException: unclosed property ref: ${tatata"); } catch (IllegalArgumentException ex) { assertEquals("unclosed property ref: ${tatata", ex.getMessage()); } assertEquals("x$", Configuration.getString(props, "17", null)); try { Configuration.getString(props, "18", null); fail("expected IllegalArgumentException: unclosed property ref: ${"); } catch (IllegalArgumentException ex) { assertEquals("unclosed property ref: ${", ex.getMessage()); } } public void testGetIntBoolean() { Properties props = new Properties(); props.setProperty("one", "1"); props.setProperty("two", "2"); System.setProperty("three", "3"); System.setProperty("vrai", "true"); props.setProperty("faux", "false"); assertEquals(1, Configuration.getInt(props, "one", -1)); assertEquals(2, Configuration.getInt(props, "two", -1)); assertEquals(3, Configuration.getInt(props, "three", -1)); assertEquals(10, Configuration.getInt(props, "ten", 10)); assertEquals(true, Configuration.getBoolean(props, "vrai", false)); assertEquals(false, Configuration.getBoolean(props, "faux", true)); assertEquals(true, Configuration.getBoolean(props, "wrong", true)); } public void testToString() { final String expectation = "a Configuration with [allowMultipleLrc=false, asynchronous2Pc=false," + " backgroundRecoveryInterval=1, backgroundRecoveryIntervalSeconds=60, currentNodeOnlyRecovery=true," + " debugZeroResourceTransaction=false, defaultTransactionTimeout=60, disableJmx=false," + " exceptionAnalyzer=null, filterLogStatus=false," + " forceBatchingEnabled=true, forcedWriteEnabled=true, gracefulShutdownInterval=10," + " jndiTransactionSynchronizationRegistryName=java:comp/TransactionSynchronizationRegistry," + " jndiUserTransactionName=java:comp/UserTransaction, journal=disk," + " logPart1Filename=target/btm1.tlog, logPart2Filename=target/btm2.tlog, maxLogSizeInMb=2," + " resourceConfigurationFilename=null, serverId=null, skipCorruptedLogs=false," + " warnAboutZeroResourceTransaction=true]"; assertEquals(expectation, new Configuration().toString()); } } btm-dist-2.1.4/test/bitronix/tm/BitronixTransactionSynchronizationRegistryTest.java0000644000175000017500000001100312147207062027620 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import junit.framework.TestCase; import javax.transaction.*; /** * * @author lorban */ public class BitronixTransactionSynchronizationRegistryTest extends TestCase { private BitronixTransactionManager btm; protected void setUp() throws Exception { btm = TransactionManagerServices.getTransactionManager(); } protected void tearDown() throws Exception { if (btm.getStatus() != Status.STATUS_NO_TRANSACTION) btm.rollback(); btm.shutdown(); } public void testMultiThreaded() throws Exception { final TransactionSynchronizationRegistry reg = TransactionManagerServices.getTransactionSynchronizationRegistry(); btm.begin(); reg.putResource("1", "one"); assertEquals("one", reg.getResource("1")); btm.commit(); Thread t = new Thread() { public void run() { try { btm.begin(); reg.putResource("1", "one"); assertEquals("one", reg.getResource("1")); btm.commit(); } catch (Exception e) { throw new RuntimeException(e); } } }; t.start(); t.join(); } public void testRegistryResources() throws Exception { TransactionSynchronizationRegistry reg = TransactionManagerServices.getTransactionSynchronizationRegistry(); try { reg.putResource("0", "zero"); fail("expected IllegalStateException"); } catch (IllegalStateException ex) { assertEquals("no transaction started on current thread", ex.getMessage()); } btm.begin(); reg.putResource("1", "one"); assertEquals("one", reg.getResource("1")); btm.commit(); try { reg.getResource("1"); fail("expected IllegalStateException"); } catch (Exception ex) { assertEquals("no transaction started on current thread", ex.getMessage()); } btm.begin(); assertNull(reg.getResource("1")); btm.commit(); } public void testRegistrySynchronizations() throws Exception { TransactionSynchronizationRegistry reg = TransactionManagerServices.getTransactionSynchronizationRegistry(); CoutingSynchronization normalSync = new CoutingSynchronization(); CoutingSynchronization interposedSync = new CoutingSynchronization(); btm.begin(); reg.registerInterposedSynchronization(interposedSync); btm.getCurrentTransaction().registerSynchronization(normalSync); btm.commit(); assertTrue(normalSync.getBeforeTimestamp() < interposedSync.getBeforeTimestamp()); assertTrue(interposedSync.getBeforeTimestamp() < normalSync.getAfterTimestamp()); assertTrue(interposedSync.getAfterTimestamp() < normalSync.getAfterTimestamp()); } private class CoutingSynchronization implements Synchronization { private long beforeTimestamp; private long afterTimestamp; public long getBeforeTimestamp() { return beforeTimestamp; } public long getAfterTimestamp() { return afterTimestamp; } public void beforeCompletion() { beforeTimestamp = System.currentTimeMillis(); try { Thread.sleep(100); } catch (InterruptedException e) { // ignore } } public void afterCompletion(int status) { afterTimestamp = System.currentTimeMillis(); try { Thread.sleep(100); } catch (InterruptedException e) { // ignore } } } } btm-dist-2.1.4/test/bitronix/tm/RestartTest.properties0000644000175000017500000000020512147207062021642 0ustar tonytonyresource.ds1.className=bitronix.tm.mock.resource.jdbc.MockitoXADataSource resource.ds1.uniqueName=mock resource.ds1.maxPoolSize=5 btm-dist-2.1.4/test/bitronix/tm/mock/0000755000175000017500000000000012147207062016174 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/mock/NewJdbcStrangeUsageMockTest.java0000644000175000017500000004021612147207062024341 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock; import bitronix.tm.BitronixTransactionManager; import bitronix.tm.TransactionManagerServices; import bitronix.tm.mock.events.*; import bitronix.tm.resource.common.XAPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.Status; import javax.transaction.Transaction; import javax.transaction.xa.XAResource; import java.sql.Connection; import java.sql.SQLException; import java.util.List; /** * * @author lorban */ public class NewJdbcStrangeUsageMockTest extends AbstractMockJdbcTest { private final static Logger log = LoggerFactory.getLogger(NewJdbcStrangeUsageMockTest.class); public void testDeferredReuse() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); XAPool pool1 = getPool(poolingDataSource1); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); assertEquals(POOL_SIZE, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** getting again connection from DS1"); connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** closing again connection 1"); connection1.close(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); assertEquals(POOL_SIZE, pool1.inPoolSize()); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(11, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(true, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testDeferredCannotReuse() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); // Use DataSource2 because it does not have shared accessible connections XAPool pool2 = getPool(poolingDataSource2); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); assertEquals(POOL_SIZE, pool2.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** getting connection 1 from DS1"); Connection connection1 = poolingDataSource2.getConnection(); connection1.createStatement(); assertEquals(POOL_SIZE -1, pool2.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** getting connection 2 from DS1"); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); assertEquals(POOL_SIZE -2, pool2.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); assertEquals(POOL_SIZE -2, pool2.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); assertEquals(POOL_SIZE -2, pool2.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); assertEquals(POOL_SIZE, pool2.inPoolSize()); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(17, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testConnectionCloseInDifferentContext() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** beginning"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); if (log.isDebugEnabled()) log.debug("*** beginning"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(22, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); } public void testClosingSuspendedConnectionsInDifferentContext() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); XAPool pool1 = getPool(poolingDataSource1); assertEquals(POOL_SIZE, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** suspending"); Transaction t1 = tm.suspend(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** starting 2nd tx"); tm.begin(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** closing connection 1 too eagerly within another context"); try { // TODO: the ConnectionHandler tries to 'veto' the connection close here like the old pool did. // Instead, close the resource immediately or defer its release. connection1.close(); fail("successfully closed a connection participating in a global transaction, this should never be allowed"); } catch (SQLException ex) { assertEquals("cannot close a resource when its XAResource is taking part in an unfinished global transaction", ex.getCause().getMessage()); } assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** committing 2nd tx"); tm.commit(); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** resuming"); tm.resume(t1); assertEquals(POOL_SIZE -1, pool1.inPoolSize()); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); assertEquals(POOL_SIZE, pool1.inPoolSize()); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(18, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(true, ((XAResourceIsSameRmEvent) orderedEvents.get(i++)).isSameRm()); assertEquals(XAResource.TMJOIN, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(true, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } } btm-dist-2.1.4/test/bitronix/tm/mock/JdbcSharedConnectionTest.java0000644000175000017500000001553212147207062023716 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock; import java.lang.reflect.Proxy; import java.sql.Connection; import java.util.ArrayList; import javax.transaction.*; import org.slf4j.*; import bitronix.tm.*; import bitronix.tm.resource.jdbc.JdbcConnectionHandle; /** * * @author lorban */ public class JdbcSharedConnectionTest extends AbstractMockJdbcTest { private final static Logger log = LoggerFactory.getLogger(NewJdbcProperUsageMockTest.class); public void testSharedConnectionMultithreaded() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); final BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.setTransactionTimeout(120); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); final Transaction suspended = tm.suspend(); final ArrayList twoConnections = new ArrayList(); Thread thread1 = new Thread() { public void run() { try { tm.resume(suspended); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection = poolingDataSource1.getConnection(); connection.createStatement(); twoConnections.add(connection); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } }; thread1.start(); thread1.join(); Thread thread2 = new Thread() { public void run() { try { tm.resume(suspended); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection = poolingDataSource1.getConnection(); connection.createStatement(); twoConnections.add(connection); tm.commit(); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } } }; thread2.start(); thread2.join(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(twoConnections.get(0)); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(twoConnections.get(1)); assertNotSame(handle1.getConnection(), handle2.getConnection()); } public void testUnSharedConnection() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.setTransactionTimeout(120); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection1 = poolingDataSource2.getConnection(); // createStatement causes enlistment connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting second connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); assertNotSame(handle1.getConnection(), handle2.getConnection()); connection1.close(); connection2.close(); tm.commit(); } public void testSharedConnectionInLocalTransaction() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); // createStatement causes enlistment connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting second connection from DS1"); Connection connection2 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); assertNotSame(handle1.getConnection(), handle2.getConnection()); connection1.close(); connection2.close(); } public void testUnSharedConnectionInLocalTransaction() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection1 = poolingDataSource2.getConnection(); // createStatement causes enlistment connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting second connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); assertNotSame(handle1.getConnection(), handle2.getConnection()); connection1.close(); connection2.close(); } public void testSharedConnectionInGlobal() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.setTransactionTimeout(120); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** getting second connection from DS1"); Connection connection2 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); assertSame(handle1.getConnection(), handle2.getConnection()); connection1.close(); connection2.close(); tm.commit(); } } btm-dist-2.1.4/test/bitronix/tm/mock/AbstractMockJmsTest.java0000644000175000017500000000704712147207062022736 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock; import bitronix.tm.TransactionManagerServices; import bitronix.tm.journal.Journal; import bitronix.tm.mock.events.EventRecorder; import bitronix.tm.mock.resource.MockJournal; import bitronix.tm.mock.resource.jms.MockXAConnectionFactory; import bitronix.tm.resource.jms.PoolingConnectionFactory; import junit.framework.TestCase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.reflect.Field; import java.util.concurrent.atomic.AtomicReference; /** * * @author lorban */ public abstract class AbstractMockJmsTest extends TestCase { private final static Logger log = LoggerFactory.getLogger(AbstractMockJmsTest.class); protected PoolingConnectionFactory poolingConnectionFactory1; protected PoolingConnectionFactory poolingConnectionFactory2; protected static final int POOL_SIZE = 5; protected static final String CONNECTION_FACTORY1_NAME = "pcf1"; protected static final String CONNECTION_FACTORY2_NAME = "pcf2"; protected void setUp() throws Exception { poolingConnectionFactory1 = new PoolingConnectionFactory(); poolingConnectionFactory1.setClassName(MockXAConnectionFactory.class.getName()); poolingConnectionFactory1.setUniqueName(CONNECTION_FACTORY1_NAME); poolingConnectionFactory1.setAcquisitionTimeout(5); poolingConnectionFactory1.setMinPoolSize(POOL_SIZE); poolingConnectionFactory1.setMaxPoolSize(POOL_SIZE); poolingConnectionFactory1.init(); poolingConnectionFactory2 = new PoolingConnectionFactory(); poolingConnectionFactory2.setClassName(MockXAConnectionFactory.class.getName()); poolingConnectionFactory2.setUniqueName(CONNECTION_FACTORY2_NAME); poolingConnectionFactory2.setAcquisitionTimeout(5); poolingConnectionFactory2.setMinPoolSize(POOL_SIZE); poolingConnectionFactory2.setMaxPoolSize(POOL_SIZE); poolingConnectionFactory2.init(); // change disk journal into mock journal Field field = TransactionManagerServices.class.getDeclaredField("journalRef"); field.setAccessible(true); AtomicReference journalRef = (AtomicReference) field.get(TransactionManagerServices.class); journalRef.set(new MockJournal()); // start TM TransactionManagerServices.getTransactionManager(); // clear event recorder list EventRecorder.clear(); } protected void tearDown() throws Exception { try { if (log.isDebugEnabled()) log.debug("*** tearDown rollback"); TransactionManagerServices.getTransactionManager().rollback(); } catch (Exception ex) { // ignore } poolingConnectionFactory1.close(); poolingConnectionFactory2.close(); } } btm-dist-2.1.4/test/bitronix/tm/mock/NewJdbcProperUsageMockTest.java0000644000175000017500000017107312147207062024213 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock; import java.io.*; import java.lang.reflect.*; import java.sql.*; import java.util.*; import javax.sql.XAConnection; import javax.transaction.*; import javax.transaction.xa.*; import org.slf4j.*; import bitronix.tm.*; import bitronix.tm.mock.events.*; import bitronix.tm.mock.resource.MockXAResource; import bitronix.tm.mock.resource.jdbc.MockDriver; import bitronix.tm.resource.common.XAPool; import bitronix.tm.resource.jdbc.*; import bitronix.tm.resource.jdbc.lrc.LrcXADataSource; /** * * @author lorban */ public class NewJdbcProperUsageMockTest extends AbstractMockJdbcTest { private final static Logger log = LoggerFactory.getLogger(NewJdbcProperUsageMockTest.class); private static final int LOOPS = 2; public void testSimpleWorkingCase() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.setTransactionTimeout(10); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(17, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testOrderedCommitResources() throws Exception { poolingDataSource1.setTwoPcOrderingPosition(200); poolingDataSource2.setTwoPcOrderingPosition(-1); if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.setTransactionTimeout(10); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(17, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourcePrepareEvent prepareEvent1 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals(XAResource.XA_OK, prepareEvent1.getReturnCode()); XAResourcePrepareEvent prepareEvent2 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals(XAResource.XA_OK, prepareEvent2.getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourceCommitEvent commitEvent1 = (XAResourceCommitEvent) orderedEvents.get(i++); assertTrue(prepareEvent2.getSource() == commitEvent1.getSource()); assertEquals(false, commitEvent1.isOnePhase()); XAResourceCommitEvent commitEvent2 = (XAResourceCommitEvent) orderedEvents.get(i++); assertTrue(prepareEvent1.getSource() == commitEvent2.getSource()); assertEquals(false, commitEvent2.isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testReversePhase2Order() throws Exception { poolingDataSource1.setTwoPcOrderingPosition(1); poolingDataSource2.setTwoPcOrderingPosition(1); if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.setTransactionTimeout(10); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(17, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourcePrepareEvent prepareEvent1 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals(XAResource.XA_OK, prepareEvent1.getReturnCode()); XAResourcePrepareEvent prepareEvent2 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals(XAResource.XA_OK, prepareEvent2.getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourceCommitEvent commitEvent1 = (XAResourceCommitEvent) orderedEvents.get(i++); assertTrue(prepareEvent2.getSource() == commitEvent1.getSource()); assertEquals(false, commitEvent1.isOnePhase()); XAResourceCommitEvent commitEvent2 = (XAResourceCommitEvent) orderedEvents.get(i++); assertTrue(prepareEvent1.getSource() == commitEvent2.getSource()); assertEquals(false, commitEvent2.isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testLrc() throws Exception { PoolingDataSource poolingDataSource2 = new PoolingDataSource(); poolingDataSource2.setClassName(LrcXADataSource.class.getName()); poolingDataSource2.setUniqueName(DATASOURCE2_NAME + "_lrc"); poolingDataSource2.setMinPoolSize(POOL_SIZE); poolingDataSource2.setMaxPoolSize(POOL_SIZE); poolingDataSource2.setAllowLocalTransactions(true); poolingDataSource2.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName()); poolingDataSource2.getDriverProperties().setProperty("user", "user"); poolingDataSource2.getDriverProperties().setProperty("password", "password"); poolingDataSource2.init(); if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.setTransactionTimeout(10); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 2"); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 1"); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(12, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(LocalCommitEvent.class, orderedEvents.get(i++).getClass()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testStatementTimeout() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.setTransactionTimeout(1); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 1"); connection1.createStatement(); Thread.sleep(1500); try { if (log.isDebugEnabled()) log.debug("*** creating statement 2 on connection 1"); connection1.createStatement(); fail("expected transaction to time out"); } catch (SQLException ex) { assertEquals("transaction timed out", ex.getCause().getMessage()); } if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** rolling back"); tm.rollback(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(9, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResourceRollbackEvent.class, orderedEvents.get(i++).getClass()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testCommitTimeout() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.setTransactionTimeout(1); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** creating statement 1 on connection 1"); connection1.createStatement(); Thread.sleep(1500); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** committing"); try { tm.commit(); fail("expected transaction to time out"); } catch (RollbackException ex) { assertEquals("transaction timed out and has been rolled back", ex.getMessage()); } if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(9, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResourceRollbackEvent.class, orderedEvents.get(i++).getClass()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testGlobalAfterLocal() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1 in local ctx"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2 in local ctx"); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1 in global ctx"); connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2 in global ctx"); connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(21, orderedEvents.size()); int i=0; assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testDeferredReleaseAfterMarkedRollback() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** marking TX for rollback only"); tm.setRollbackOnly(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** rolling back"); tm.rollback(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(9, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResourceRollbackEvent.class, orderedEvents.get(i++).getClass()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testRollingBackSynchronization() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); final BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); tm.getTransaction().registerSynchronization(new Synchronization() { public void beforeCompletion() { try { if (log.isDebugEnabled()) log.debug("**** before setRollbackOnly"); tm.setRollbackOnly(); if (log.isDebugEnabled()) log.debug("**** after setRollbackOnly"); } catch (SystemException ex) { throw new RuntimeException("could not setRollbackOnly", ex); } } public void afterCompletion(int status) { } }); if (log.isDebugEnabled()) log.debug("*** after registerSynchronization"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); try { tm.commit(); fail("transaction should not have been able to commit as it has been marked as rollback only"); } catch (RollbackException ex) { assertEquals("transaction was marked as rollback only and has been rolled back", ex.getMessage()); } if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(14, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResourceRollbackEvent.class, orderedEvents.get(i++).getClass()); assertEquals(XAResourceRollbackEvent.class, orderedEvents.get(i++).getClass()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testSuspendResume() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** suspending transaction"); Transaction tx = tm.suspend(); if (log.isDebugEnabled()) log.debug("*** resuming transaction"); tm.resume(tx); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(23, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(true, ((XAResourceIsSameRmEvent) orderedEvents.get(i++)).isSameRm()); assertEquals(XAResource.TMJOIN, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(true, ((XAResourceIsSameRmEvent) orderedEvents.get(i++)).isSameRm()); assertEquals(XAResource.TMJOIN, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testLooseWorkingCaseOutsideOutside() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); connection1.createStatement(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(17, orderedEvents.size()); int i=0; assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testLooseWorkingCaseOutsideInside() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); connection1.createStatement(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(17, orderedEvents.size()); int i=0; assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testLooseWorkingCaseInsideOutside() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from DS1"); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); if (log.isDebugEnabled()) log.debug("*** getting connection from DS2"); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** closing connection 2"); connection2.close(); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(17, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testHeuristicCommitWorkingCase() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcPooledConnection pc1 = handle.getPooledConnection(); XAConnection mockXAConnection1 = (XAConnection) getWrappedXAConnectionOf(pc1); MockXAResource mockXAResource = (MockXAResource) mockXAConnection1.getXAResource(); mockXAResource.setCommitException(new XAException(XAException.XA_HEURCOM)); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); connection1.close(); connection2.close(); tm.commit(); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(18, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(XAResource.XA_OK, ((XAResourcePrepareEvent) orderedEvents.get(i++)).getReturnCode()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourceCommitEvent event = ((XAResourceCommitEvent) orderedEvents.get(i++)); assertEquals(false, event.isOnePhase()); if (event.getException() != null) { assertNotNull(orderedEvents.get(i++)); assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i)).isOnePhase()); assertNull(((XAResourceCommitEvent) orderedEvents.get(i++)).getException()); } else { assertEquals(false, ((XAResourceCommitEvent) orderedEvents.get(i)).isOnePhase()); assertNotNull(((XAResourceCommitEvent) orderedEvents.get(i++)).getException()); assertNotNull(orderedEvents.get(i++)); } assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testHeuristicRollbackWorkingCase() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcPooledConnection pc1 = handle.getPooledConnection(); XAConnection mockXAConnection1 = (XAConnection) getWrappedXAConnectionOf(pc1); MockXAResource mockXAResource = (MockXAResource) mockXAConnection1.getXAResource(); mockXAResource.setRollbackException(new XAException(XAException.XA_HEURRB)); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); connection1.close(); connection2.close(); tm.setTransactionTimeout(3); tm.rollback(); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(14, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourceRollbackEvent event = ((XAResourceRollbackEvent) orderedEvents.get(i++)); assertNotNull(event); if (event.getException() != null) { assertNotNull(orderedEvents.get(i++)); assertNotNull(orderedEvents.get(i++)); } else { assertNotNull(orderedEvents.get(i)); assertNotNull(((XAResourceRollbackEvent) orderedEvents.get(i++)).getException()); assertNotNull(orderedEvents.get(i++)); } assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testNonXaPool() throws Exception { for (int i=0; i journalRef = (AtomicReference) field.get(TransactionManagerServices.class); journalRef.set(new MockJournal()); // change connection pools into mock pools XAPool p1 = getPool(this.poolingDataSource1); registerPoolEventListener(p1); XAPool p2 = getPool(this.poolingDataSource2); registerPoolEventListener(p2); TransactionManagerServices.getConfiguration().setGracefulShutdownInterval(2); // start TM TransactionManagerServices.getTransactionManager(); // clear event recorder list EventRecorder.clear(); } protected XAPool getPool(PoolingDataSource poolingDataSource) throws NoSuchFieldException, IllegalAccessException { Field poolField = PoolingDataSource.class.getDeclaredField("pool"); poolField.setAccessible(true); return (XAPool) poolField.get(poolingDataSource); } private void registerPoolEventListener(XAPool pool) throws Exception { ArrayList connections = new ArrayList(); Iterator iterator = XAPoolHelper.getXAResourceHolders(pool).iterator(); while (iterator.hasNext()) { XAStatefulHolder holder = (XAStatefulHolder) iterator.next(); JdbcConnectionHandle connectionHandle = (JdbcConnectionHandle) holder.getConnectionHandle(); JdbcPooledConnection jdbcPooledConnection = connectionHandle.getPooledConnection(); connections.add(connectionHandle); jdbcPooledConnection.addStateChangeEventListener(new StateChangeListener() { public void stateChanged(XAStatefulHolder source, int oldState, int newState) { if (newState == AbstractXAResourceHolder.STATE_IN_POOL) EventRecorder.getEventRecorder(this).addEvent(new ConnectionQueuedEvent(this, (JdbcPooledConnection) source)); if (newState == AbstractXAResourceHolder.STATE_ACCESSIBLE) EventRecorder.getEventRecorder(this).addEvent(new ConnectionDequeuedEvent(this, (JdbcPooledConnection) source)); } public void stateChanging(XAStatefulHolder source, int currentState, int futureState) { } }); } for (int i = 0; i < connections.size(); i++) { JdbcConnectionHandle connectionHandle = (JdbcConnectionHandle) connections.get(i); connectionHandle.close(); } } protected void tearDown() throws Exception { try { if (log.isDebugEnabled()) log.debug("*** tearDown rollback"); TransactionManagerServices.getTransactionManager().rollback(); } catch (Exception ex) { // ignore } poolingDataSource1.close(); poolingDataSource2.close(); TransactionManagerServices.getTransactionManager().shutdown(); } public static Object getWrappedXAConnectionOf(Object pc1) throws NoSuchFieldException, IllegalAccessException { Field f = pc1.getClass().getDeclaredField("xaConnection"); f.setAccessible(true); return f.get(pc1); } } btm-dist-2.1.4/test/bitronix/tm/mock/NewJdbcWrongUsageMockTest.java0000644000175000017500000003727412147207062024044 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock; import java.lang.reflect.Proxy; import java.sql.*; import java.util.List; import javax.sql.XAConnection; import javax.transaction.*; import javax.transaction.xa.*; import bitronix.tm.*; import bitronix.tm.mock.events.*; import bitronix.tm.mock.resource.MockXAResource; import bitronix.tm.mock.resource.jdbc.*; import bitronix.tm.mock.resource.jms.MockConnectionFactory; import bitronix.tm.resource.jdbc.*; import bitronix.tm.resource.jdbc.lrc.LrcXADataSource; import bitronix.tm.resource.jms.PoolingConnectionFactory; import bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author lorban */ public class NewJdbcWrongUsageMockTest extends AbstractMockJdbcTest { private final static Logger log = LoggerFactory.getLogger(NewJdbcWrongUsageMockTest.class); public void testPrepareXAFailureCase() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcPooledConnection pc1 = handle.getPooledConnection(); XAConnection xaConnection1 = (XAConnection) getWrappedXAConnectionOf(pc1); MockXAResource mockXAResource = (MockXAResource) xaConnection1.getXAResource(); XAException xaException = new XAException("resource failed"); xaException.errorCode = XAException.XAER_RMERR; mockXAResource.setPrepareException(xaException); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); connection1.close(); connection2.close(); try { tm.commit(); fail("TM should have thrown rollback exception"); } catch (RollbackException ex) { assertTrue("Got: " + ex.getMessage(), ex.getMessage().matches("transaction failed to prepare: a Bitronix Transaction with GTRID (.*?) status=ROLLEDBACK, 2 resource\\(s\\) enlisted (.*?)")); assertTrue("Got: " + ex.getCause().getMessage(), ex.getCause().getMessage().matches("transaction failed during prepare of a Bitronix Transaction with GTRID (.*?) status=PREPARING, 2 resource\\(s\\) enlisted (.*?) resource\\(s\\) \\[pds1\\] threw unexpected exception")); assertEquals("collected 1 exception(s):" + System.getProperty("line.separator") + " [pds1 - javax.transaction.xa.XAException(XAER_RMERR) - resource failed]", ex.getCause().getCause().getMessage()); } // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(16, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourcePrepareEvent prepareEvent1 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals("resource failed", prepareEvent1.getException().getMessage()); XAResourcePrepareEvent prepareEvent2 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals(XAResource.XA_OK, prepareEvent2.getReturnCode()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourceRollbackEvent rollbackEvent1 = (XAResourceRollbackEvent) orderedEvents.get(i++); assertTrue(prepareEvent2.getSource() == rollbackEvent1.getSource()); XAResourceRollbackEvent rollbackEvent2 = (XAResourceRollbackEvent) orderedEvents.get(i++); assertTrue(prepareEvent1.getSource() == rollbackEvent2.getSource()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testPrepareRuntimeFailureCase() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); JdbcPooledConnection pc1 = handle.getPooledConnection(); XAConnection xaConnection1 = (XAConnection) getWrappedXAConnectionOf(pc1); MockXAResource mockXAResource = (MockXAResource) xaConnection1.getXAResource(); mockXAResource.setPrepareException(new RuntimeException("driver error")); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); connection1.close(); connection2.close(); try { tm.commit(); fail("TM should have thrown exception"); } catch (RollbackException ex) { assertTrue("Got: " + ex.getMessage(), ex.getMessage().matches("transaction failed to prepare: a Bitronix Transaction with GTRID (.*?) status=ROLLEDBACK, 2 resource\\(s\\) enlisted (.*?)")); assertTrue("Got: " + ex.getCause().getMessage(), ex.getCause().getMessage().matches("transaction failed during prepare of a Bitronix Transaction with GTRID (.*?) status=PREPARING, 2 resource\\(s\\) enlisted (.*?) resource\\(s\\) \\[pds1\\] threw unexpected exception")); assertEquals("collected 1 exception(s):" + System.getProperty("line.separator") + " [pds1 - java.lang.RuntimeException - driver error]", ex.getCause().getCause().getMessage()); } // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(16, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(DATASOURCE2_NAME, ((ConnectionDequeuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourcePrepareEvent prepareEvent1 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals("driver error", prepareEvent1.getException().getMessage()); XAResourcePrepareEvent prepareEvent2 = (XAResourcePrepareEvent) orderedEvents.get(i++); assertEquals(XAResource.XA_OK, prepareEvent2.getReturnCode()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); XAResourceRollbackEvent rollbackEvent1 = (XAResourceRollbackEvent) orderedEvents.get(i++); assertTrue(prepareEvent2.getSource() == rollbackEvent1.getSource()); XAResourceRollbackEvent rollbackEvent2 = (XAResourceRollbackEvent) orderedEvents.get(i++); assertTrue(prepareEvent1.getSource() == rollbackEvent2.getSource()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(DATASOURCE1_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); assertEquals(DATASOURCE2_NAME, ((ConnectionQueuedEvent) orderedEvents.get(i++)).getPooledConnectionImpl().getPoolingDataSource().getUniqueName()); } public void testIncorrectSuspendResume() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); tm.begin(); Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); connection2.createStatement(); Transaction tx = tm.suspend(); assertNull(tm.suspend()); try { tm.resume(null); fail("TM has allowed resuming a null TX context"); } catch (InvalidTransactionException ex) { assertEquals("resumed transaction cannot be null", ex.getMessage()); } tm.resume(tx); try { tm.resume(tx); fail("TM has allowed resuming a TX context when another one is still running"); } catch (IllegalStateException ex) { assertEquals("a transaction is already running on this thread", ex.getMessage()); } connection1.close(); connection2.close(); tm.commit(); } public void testEagerEnding() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); try { tm.rollback(); fail("TM allowed rollback with no TX started"); } catch (IllegalStateException ex) { assertEquals("no transaction started on this thread", ex.getMessage()); } try { tm.commit(); fail("TM allowed commit with no TX started"); } catch (IllegalStateException ex) { assertEquals("no transaction started on this thread", ex.getMessage()); } } public void testRegisterTwoLrc() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); PoolingDataSource lrcDs1 = new PoolingDataSource(); lrcDs1.setClassName(LrcXADataSource.class.getName()); lrcDs1.setUniqueName(DATASOURCE1_NAME + "_lrc"); lrcDs1.setMinPoolSize(POOL_SIZE); lrcDs1.setMaxPoolSize(POOL_SIZE); lrcDs1.setAllowLocalTransactions(true); lrcDs1.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName()); lrcDs1.getDriverProperties().setProperty("url", ""); lrcDs1.init(); PoolingDataSource lrcDs2 = new PoolingDataSource(); lrcDs2.setClassName(LrcXADataSource.class.getName()); lrcDs2.setUniqueName(DATASOURCE2_NAME + "_lrc"); lrcDs2.setMinPoolSize(POOL_SIZE); lrcDs2.setMaxPoolSize(POOL_SIZE); lrcDs2.setAllowLocalTransactions(true); lrcDs2.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName()); lrcDs2.getDriverProperties().setProperty("url", ""); lrcDs2.init(); tm.begin(); Connection c1 = lrcDs1.getConnection(); c1.createStatement(); c1.close(); Connection c2 = lrcDs2.getConnection(); try { c2.createStatement(); fail("expected SQLException"); } catch (SQLException ex) { assertTrue(ex.getMessage().startsWith("error enlisting a JdbcConnectionHandle of a JdbcPooledConnection from datasource pds2_lrc in state ACCESSIBLE with usage count 1 wrapping a JDBC LrcXAConnection on Mock for Connection")); assertTrue(ex.getCause().getMessage().matches("cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=pds2_lrc XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=pds1_lrc XAResource=a JDBC LrcXAResource in state STARTED \\(started\\) with XID a Bitronix XID .*")); } c2.close(); tm.commit(); lrcDs2.close(); lrcDs1.close(); } public void testRegisterTwoLrcJms() throws Exception { BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); PoolingConnectionFactory pcf = new PoolingConnectionFactory(); pcf.setClassName(LrcXAConnectionFactory.class.getName()); pcf.setUniqueName("pcf_lrc"); pcf.setMaxPoolSize(1); pcf.getDriverProperties().setProperty("connectionFactoryClassName", MockConnectionFactory.class.getName()); pcf.init(); PoolingDataSource lrcDs2 = new PoolingDataSource(); lrcDs2.setClassName(LrcXADataSource.class.getName()); lrcDs2.setUniqueName(DATASOURCE2_NAME + "_lrc"); lrcDs2.setMinPoolSize(POOL_SIZE); lrcDs2.setMaxPoolSize(POOL_SIZE); lrcDs2.setAllowLocalTransactions(true); lrcDs2.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName()); lrcDs2.getDriverProperties().setProperty("url", ""); lrcDs2.init(); tm.begin(); javax.jms.Connection c = pcf.createConnection(); javax.jms.Session s = c.createSession(true, 0); javax.jms.MessageProducer p = s.createProducer(null); p.send(null); c.close(); Connection c2 = lrcDs2.getConnection(); try { c2.createStatement(); fail("expected SQLException"); } catch (SQLException ex) { assertTrue(ex.getMessage().startsWith("error enlisting a JdbcConnectionHandle of a JdbcPooledConnection from datasource pds2_lrc in state ACCESSIBLE with usage count 1 wrapping a JDBC LrcXAConnection on Mock for Connection")); assertTrue(ex.getCause().getMessage().startsWith("cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=pds2_lrc XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=pcf_lrc XAResource=a JMS LrcXAResource in state STARTED of session Mock for Session")); } c2.close(); tm.commit(); lrcDs2.close(); pcf.close(); } } btm-dist-2.1.4/test/bitronix/tm/mock/DelistmentTest.java0000644000175000017500000003450012147207062022011 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock; import bitronix.tm.BitronixTransactionManager; import bitronix.tm.TransactionManagerServices; import bitronix.tm.internal.BitronixXAException; import bitronix.tm.journal.Journal; import bitronix.tm.mock.events.EventRecorder; import bitronix.tm.mock.events.JournalLogEvent; import bitronix.tm.mock.events.XAResourceEndEvent; import bitronix.tm.mock.events.XAResourceRollbackEvent; import bitronix.tm.mock.events.XAResourceStartEvent; import bitronix.tm.mock.resource.MockJournal; import bitronix.tm.mock.resource.MockXAResource; import bitronix.tm.mock.resource.jdbc.MockitoXADataSource; import bitronix.tm.resource.jdbc.JdbcConnectionHandle; import bitronix.tm.resource.jdbc.PoolingDataSource; import junit.framework.TestCase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.sql.XAConnection; import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import java.lang.reflect.Field; import java.lang.reflect.Proxy; import java.sql.Connection; import java.util.List; import java.util.concurrent.atomic.AtomicReference; public class DelistmentTest extends TestCase { private final static Logger log = LoggerFactory.getLogger(DelistmentTest.class); private PoolingDataSource poolingDataSource1; private PoolingDataSource poolingDataSource2; private BitronixTransactionManager btm; protected void setUp() throws Exception { EventRecorder.clear(); // change disk journal into mock journal Field field = TransactionManagerServices.class.getDeclaredField("journalRef"); field.setAccessible(true); AtomicReference journalRef = (AtomicReference) field.get(TransactionManagerServices.class); journalRef.set(new MockJournal()); poolingDataSource1 = new PoolingDataSource(); poolingDataSource1.setClassName(MockitoXADataSource.class.getName()); poolingDataSource1.setUniqueName("pds1"); poolingDataSource1.setMinPoolSize(5); poolingDataSource1.setMaxPoolSize(5); poolingDataSource1.setAutomaticEnlistingEnabled(true); poolingDataSource1.init(); poolingDataSource2 = new PoolingDataSource(); poolingDataSource2.setClassName(MockitoXADataSource.class.getName()); poolingDataSource2.setUniqueName("pds2"); poolingDataSource2.setMinPoolSize(5); poolingDataSource2.setMaxPoolSize(5); poolingDataSource2.setAutomaticEnlistingEnabled(true); poolingDataSource2.init(); btm = TransactionManagerServices.getTransactionManager(); } protected void tearDown() throws Exception { poolingDataSource1.close(); poolingDataSource2.close(); btm.shutdown(); } public void testDelistErrorOnCommit() throws Exception { btm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); XAConnection xaConnection1 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle1.getPooledConnection()); MockXAResource xaResource1 = (MockXAResource) xaConnection1.getXAResource(); connection1.createStatement(); // triggers enlistment xaResource1.setEndException(new BitronixXAException("screw delistment", XAException.XAER_RMERR)); xaResource1.setRollbackException(new BitronixXAException("delistment was screwed, cannot rollback", XAException.XAER_RMERR)); Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle2.getPooledConnection()); MockXAResource xaResource2 = (MockXAResource) xaConnection2.getXAResource(); connection2.createStatement(); // triggers enlistment try { btm.commit(); fail("expected RollbackException"); } catch (RollbackException ex) { assertEquals("delistment error caused transaction rollback" + System.getProperty("line.separator") + " resource(s) [pds1] could not be delisted", ex.getMessage()); } // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(9, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertTrue(((XAResourceRollbackEvent) orderedEvents.get(i++)).getSource() == xaResource2); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); } public void testDelistUnilateralRollbackOnCommit() throws Exception { btm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); XAConnection xaConnection1 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle1.getPooledConnection()); MockXAResource xaResource1 = (MockXAResource) xaConnection1.getXAResource(); connection1.createStatement(); xaResource1.setEndException(new BitronixXAException("what was that transaction again?", XAException.XAER_NOTA)); xaResource1.setRollbackException(new BitronixXAException("delistment unilaterally rolled back, cannot rollback twice", XAException.XAER_RMERR)); Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle2.getPooledConnection()); MockXAResource xaResource2 = (MockXAResource) xaConnection2.getXAResource(); connection2.createStatement(); // triggers enlistment try { btm.commit(); fail("expected RollbackException"); } catch (RollbackException ex) { assertEquals("delistment error caused transaction rollback" + System.getProperty("line.separator") + " resource(s) [pds1] unilaterally rolled back", ex.getMessage()); } // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(9, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertTrue(((XAResourceRollbackEvent) orderedEvents.get(i++)).getSource() == xaResource2); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); } public void testDelistErrorAndUnilateralRollbackOnCommit() throws Exception { btm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle1 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); XAConnection xaConnection1 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle1.getPooledConnection()); MockXAResource xaResource1 = (MockXAResource) xaConnection1.getXAResource(); xaResource1.setEndException(new BitronixXAException("screw delistment", XAException.XAER_RMERR)); xaResource1.setRollbackException(new BitronixXAException("delistment was screwed, cannot rollback", XAException.XAER_RMERR)); connection1.createStatement(); // triggers enlistment Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle2.getPooledConnection()); MockXAResource xaResource2 = (MockXAResource) xaConnection2.getXAResource(); xaResource2.setEndException(new BitronixXAException("what was that transaction again?", XAException.XAER_NOTA)); xaResource2.setRollbackException(new BitronixXAException("delistment unilaterally rolled back, cannot rollback twice", XAException.XAER_RMERR)); connection2.createStatement(); // triggers enlistment try { btm.commit(); fail("expected RollbackException"); } catch (RollbackException ex) { assertEquals("delistment error caused transaction rollback" + System.getProperty("line.separator") + " resource(s) [pds2] unilaterally rolled back" + System.getProperty("line.separator") + " resource(s) [pds1] could not be delisted" , ex.getMessage()); } // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(8, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); } public void testDelistErrorAndUnilateralRollbackOnRollback() throws Exception { btm.begin(); Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); XAConnection xaConnection1 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle.getPooledConnection()); MockXAResource xaResource1 = (MockXAResource) xaConnection1.getXAResource(); xaResource1.setEndException(new BitronixXAException("screw delistment", XAException.XAER_RMERR)); xaResource1.setRollbackException(new BitronixXAException("delistment was screwed, cannot rollback", XAException.XAER_RMERR)); connection1.createStatement(); // triggers enlistment Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle2 = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle2.getPooledConnection()); MockXAResource xaResource2 = (MockXAResource) xaConnection2.getXAResource(); xaResource2.setEndException(new BitronixXAException("what was that transaction again?", XAException.XAER_NOTA)); xaResource2.setRollbackException(new BitronixXAException("delistment unilaterally rolled back, cannot rollback twice", XAException.XAER_RMERR)); connection2.createStatement(); // triggers enlistment btm.rollback(); log.info(EventRecorder.dumpToString()); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(8, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_MARKED_ROLLBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_ROLLING_BACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_ROLLEDBACK, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); } } btm-dist-2.1.4/test/bitronix/tm/mock/JmsProperUsageMockTest.java0000644000175000017500000001127012147207062023420 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock; import bitronix.tm.BitronixTransactionManager; import bitronix.tm.TransactionManagerServices; import bitronix.tm.resource.jms.PoolingConnectionFactory; import bitronix.tm.mock.events.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.*; import javax.transaction.xa.XAResource; import javax.jms.Connection; import javax.jms.Session; import javax.jms.Queue; import javax.jms.MessageProducer; import java.util.List; import java.io.*; /** * * @author lorban */ public class JmsProperUsageMockTest extends AbstractMockJmsTest { private final static Logger log = LoggerFactory.getLogger(JmsProperUsageMockTest.class); @Override protected void setUp() throws Exception { super.setUp(); TransactionManagerServices.getTransactionManager(); // start TM } @Override protected void tearDown() throws Exception { super.tearDown(); TransactionManagerServices.getTransactionManager().shutdown(); // stop TM } public void testSimpleWorkingCase() throws Exception { if (log.isDebugEnabled()) log.debug("*** getting TM"); BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager(); if (log.isDebugEnabled()) log.debug("*** before begin"); tm.setTransactionTimeout(10); tm.begin(); if (log.isDebugEnabled()) log.debug("*** after begin"); if (log.isDebugEnabled()) log.debug("*** getting connection from CF1"); Connection connection1 = poolingConnectionFactory1.createConnection(); if (log.isDebugEnabled()) log.debug("*** creating session 1 on connection 1"); Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE); if (log.isDebugEnabled()) log.debug("*** creating queue 1 on session 1"); Queue queue1 = session1.createQueue("queue"); if (log.isDebugEnabled()) log.debug("*** creating producer1 on session 1"); MessageProducer producer1 = session1.createProducer(queue1); if (log.isDebugEnabled()) log.debug("*** sending message on producer1"); producer1.send(session1.createTextMessage("testSimpleWorkingCase")); if (log.isDebugEnabled()) log.debug("*** closing connection 1"); connection1.close(); if (log.isDebugEnabled()) log.debug("*** committing"); tm.commit(); if (log.isDebugEnabled()) log.debug("*** TX is done"); // check flow List orderedEvents = EventRecorder.getOrderedEvents(); log.info(EventRecorder.dumpToString()); assertEquals(8, orderedEvents.size()); int i=0; assertEquals(Status.STATUS_ACTIVE, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(XAResource.TMNOFLAGS, ((XAResourceStartEvent) orderedEvents.get(i++)).getFlag()); assertEquals(XAResource.TMSUCCESS, ((XAResourceEndEvent) orderedEvents.get(i++)).getFlag()); assertEquals(Status.STATUS_PREPARING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_PREPARED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(Status.STATUS_COMMITTING, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); assertEquals(true, ((XAResourceCommitEvent) orderedEvents.get(i++)).isOnePhase()); assertEquals(Status.STATUS_COMMITTED, ((JournalLogEvent) orderedEvents.get(i++)).getStatus()); } public void testSerialization() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(poolingConnectionFactory1); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); poolingConnectionFactory1 = (PoolingConnectionFactory) ois.readObject(); ois.close(); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/0000755000175000017500000000000012147207062017500 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/mock/events/Chrono.java0000644000175000017500000000242412147207062021575 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; /** * * @author lorban */ public class Chrono { private static long lastTime = 0; private static long counter = 0; public synchronized static long getTime() { long time = System.currentTimeMillis(); if (time <= lastTime) { counter++; time += counter; lastTime += counter; } else { counter = 0; lastTime = time; } return time; } } btm-dist-2.1.4/test/bitronix/tm/mock/events/ConnectionQueuedEvent.java0000644000175000017500000000312612147207062024617 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import bitronix.tm.resource.jdbc.JdbcPooledConnection; /** * * @author lorban */ public class ConnectionQueuedEvent extends Event { private JdbcPooledConnection jdbcPooledConnection; public ConnectionQueuedEvent(Object source, JdbcPooledConnection jdbcPooledConnection) { super(source, null); this.jdbcPooledConnection = jdbcPooledConnection; } public ConnectionQueuedEvent(Object source, Exception ex) { super(source, ex); } public JdbcPooledConnection getPooledConnectionImpl() { return jdbcPooledConnection; } public String toString() { return "ConnectionQueuedEvent at " + getTimestamp() + " on " + jdbcPooledConnection + (getException()!=null ? " and " + getException().toString() : ""); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAResourceForgetEvent.java0000644000175000017500000000222312147207062024533 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import javax.transaction.xa.Xid; /** * * @author lorban */ public class XAResourceForgetEvent extends XAEvent { public XAResourceForgetEvent(Object source, Xid xid) { super(source, xid); } public String toString() { return "XAResourceForgetEvent at " + getTimestamp() + " on " + getXid(); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAEvent.java0000644000175000017500000000234712147207062021663 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import javax.transaction.xa.Xid; /** * * @author lorban */ public abstract class XAEvent extends Event { private Xid xid; protected XAEvent(Object source, Xid xid) { super(source, null); this.xid = xid; } protected XAEvent(Object source, Exception ex, Xid xid) { super(source, ex); this.xid = xid; } public Xid getXid() { return xid; } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAConnectionCloseEvent.java0000644000175000017500000000237512147207062024672 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; /** * * @author lorban */ public class XAConnectionCloseEvent extends Event { public XAConnectionCloseEvent(Object source) { super(source, null); } public XAConnectionCloseEvent(Object source, Exception ex) { super(source, ex); } public String toString() { return "XAConnectionCloseEvent at " + getTimestamp() + (getException()!=null ? " and " + getException().toString() : ""); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/LocalCommitEvent.java0000644000175000017500000000212112147207062023544 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; /** * * @author lorban */ public class LocalCommitEvent extends Event { public LocalCommitEvent(Object source, Exception ex) { super(source, ex); } public String toString() { return "LocalCommitEvent at " + getTimestamp(); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/ConnectionCloseEvent.java0000644000175000017500000000236512147207062024440 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; /** * * @author lorban */ public class ConnectionCloseEvent extends Event { public ConnectionCloseEvent(Object source) { super(source, null); } public ConnectionCloseEvent(Object source, Exception ex) { super(source, ex); } public String toString() { return "ConnectionCloseEvent at " + getTimestamp() + (getException()!=null ? " and " + getException().toString() : ""); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/EventRecorder.java0000644000175000017500000000456712147207062023126 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import java.util.*; /** * * @author lorban */ public class EventRecorder { private static Map eventRecorders = new HashMap(); public synchronized static EventRecorder getEventRecorder(Object key) { EventRecorder er = (EventRecorder) eventRecorders.get(key); if (er == null) { er = new EventRecorder(); eventRecorders.put(key, er); } return er; } public static Map getEventRecorders() { return eventRecorders; } public static Iterator iterateEvents() { return new EventsIterator(eventRecorders); } public static List getOrderedEvents() { Iterator iterator = iterateEvents(); List orderedEvents = new ArrayList(); while (iterator.hasNext()) { Object o = iterator.next(); orderedEvents.add(o); } return orderedEvents; } public static String dumpToString() { StringBuffer sb = new StringBuffer(); int i = 0; Iterator it = iterateEvents(); while (it.hasNext()) { Event event = (Event) it.next(); sb.append(i++); sb.append(" - "); sb.append(event.toString()); sb.append("\n"); } return sb.toString(); } public static void clear() { eventRecorders.clear(); } private List events = new ArrayList(); private EventRecorder() { } public void addEvent(Event evt) { events.add(evt); } public List getEvents() { return events; } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAResourceStartEvent.java0000644000175000017500000000253212147207062024405 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import javax.transaction.xa.Xid; import bitronix.tm.utils.Decoder; /** * * @author lorban */ public class XAResourceStartEvent extends XAEvent { private int flag; public XAResourceStartEvent(Object source, Xid xid, int flag) { super(source, xid); this.flag = flag; } public int getFlag() { return flag; } public String toString() { return "XAResourceStartEvent at " + getTimestamp() + " with flag=" + Decoder.decodeXAResourceFlag(flag) + " on " + getXid(); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAResourceIsSameRmEvent.java0000644000175000017500000000273212147207062024772 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import javax.transaction.xa.XAResource; /** * * @author lorban */ public class XAResourceIsSameRmEvent extends XAEvent { private XAResource xaResource; private boolean sameRm; public XAResourceIsSameRmEvent(Object source, XAResource xaResource, boolean sameRm) { super(source, null); this.xaResource = xaResource; this.sameRm = sameRm; } public XAResource getXAResource() { return xaResource; } public boolean isSameRm() { return sameRm; } public String toString() { return "XAResourceIsSameRmEvent at " + getTimestamp() + " with XAResource=" + xaResource; } }btm-dist-2.1.4/test/bitronix/tm/mock/events/Event.java0000644000175000017500000000273012147207062021426 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; /** * * @author lorban */ public abstract class Event { private Exception callStack; private Object source; private Exception exception; private long timestamp; protected Event(Object source, Exception ex) { this.callStack = new Exception(); this.source = source; this.exception = ex; this.timestamp = Chrono.getTime(); } public Exception getCallStack() { return callStack; } public Object getSource() { return source; } public long getTimestamp() { return timestamp; } public Exception getException() { return exception; } } btm-dist-2.1.4/test/bitronix/tm/mock/events/LocalRollbackEvent.java0000644000175000017500000000212612147207062024052 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; /** * * @author lorban */ public class LocalRollbackEvent extends Event { public LocalRollbackEvent(Object source, Exception ex) { super(source, ex); } public String toString() { return "LocalRollbackEvent at " + getTimestamp(); } }btm-dist-2.1.4/test/bitronix/tm/mock/events/XAResourceRollbackEvent.java0000644000175000017500000000241312147207062025037 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import javax.transaction.xa.Xid; /** * * @author lorban */ public class XAResourceRollbackEvent extends XAEvent { public XAResourceRollbackEvent(Object source, Xid xid) { super(source, xid); } public XAResourceRollbackEvent(Object source, Exception ex, Xid xid) { super(source, ex, xid); } public String toString() { return "XAResourceRollbackEvent at " + getTimestamp() + " on " + getXid(); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/JournalLogEvent.java0000644000175000017500000000312012147207062023415 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import bitronix.tm.utils.Decoder; import bitronix.tm.utils.Uid; import java.util.Set; /** * * @author lorban */ public class JournalLogEvent extends Event { private int status; private Uid gtrid; private Set jndiNames; public JournalLogEvent(Object source, int status, Uid gtrid, Set jndiNames) { super(source, null); this.status = status; this.gtrid = gtrid; this.jndiNames = jndiNames; } public int getStatus() { return status; } public Uid getGtrid() { return gtrid; } public Set getJndiNames() { return jndiNames; } public String toString() { return "JournalLogEvent at " + getTimestamp() + " with status=" + Decoder.decodeStatus(status); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAResourceEndEvent.java0000644000175000017500000000252512147207062024020 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import bitronix.tm.utils.Decoder; import javax.transaction.xa.Xid; /** * * @author lorban */ public class XAResourceEndEvent extends XAEvent { private int flag; public XAResourceEndEvent(Object source, Xid xid, int flag) { super(source, xid); this.flag = flag; } public int getFlag() { return flag; } public String toString() { return "XAResourceEndEvent at " + getTimestamp() + " with flag=" + Decoder.decodeXAResourceFlag(flag) + " on " + getXid(); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAResourceCommitEvent.java0000644000175000017500000000305712147207062024543 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import javax.transaction.xa.Xid; /** * * @author lorban */ public class XAResourceCommitEvent extends XAEvent { private boolean onePhase; public XAResourceCommitEvent(Object source, Xid xid, boolean onePhase) { super(source, xid); this.onePhase = onePhase; } public XAResourceCommitEvent(Object source, Exception ex, Xid xid, boolean onePhase) { super(source, ex, xid); this.onePhase = onePhase; } public boolean isOnePhase() { return onePhase; } public String toString() { return "XAResourceCommitEvent at " + getTimestamp() + " with onePhase=" + onePhase + (getException()!=null ? " and " + getException().toString() : "" + " on " + getXid()); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/EventsIterator.java0000644000175000017500000000524512147207062023327 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import java.util.*; /** * * @author lorban */ public class EventsIterator implements Iterator { private Iterator[] eventRecorderIterators; private Event[] nextEvents; public EventsIterator(Map eventRecorders) { int size = eventRecorders.size(); eventRecorderIterators = new Iterator[size]; nextEvents = new Event[size]; int i = 0; Iterator it = eventRecorders.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); EventRecorder er = (EventRecorder) entry.getValue(); eventRecorderIterators[i] = er.getEvents().iterator(); if (eventRecorderIterators[i].hasNext()) nextEvents[i] = (Event) eventRecorderIterators[i].next(); i++; } } public void remove() { } public boolean hasNext() { for (int i = 0; i < nextEvents.length; i++) { Event nextEvent = nextEvents[i]; if (nextEvent != null) return true; } return false; } public Object next() { Event current = null; int index = -1; for (int i = 0; i < nextEvents.length; i++) { Event nextEvent = nextEvents[i]; if (nextEvent == null) continue; if (current == null) { current = nextEvent; index = i; } else if (nextEvent.getTimestamp() < current.getTimestamp()) { current = nextEvent; index = i; } } if (index != -1) { if (eventRecorderIterators[index].hasNext()) nextEvents[index] = (Event) eventRecorderIterators[index].next(); else nextEvents[index] = null; } return current; } } btm-dist-2.1.4/test/bitronix/tm/mock/events/ConnectionDequeuedEvent.java0000644000175000017500000000313612147207062025131 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import bitronix.tm.resource.jdbc.JdbcPooledConnection; /** * * @author lorban */ public class ConnectionDequeuedEvent extends Event { private JdbcPooledConnection jdbcPooledConnection; public ConnectionDequeuedEvent(Object source, JdbcPooledConnection jdbcPooledConnection) { super(source, null); this.jdbcPooledConnection = jdbcPooledConnection; } public ConnectionDequeuedEvent(Object source, Exception ex) { super(source, ex); } public JdbcPooledConnection getPooledConnectionImpl() { return jdbcPooledConnection; } public String toString() { return "ConnectionDequeuedEvent at " + getTimestamp() + " on " + jdbcPooledConnection + (getException()!=null ? " and " + getException().toString() : ""); } } btm-dist-2.1.4/test/bitronix/tm/mock/events/XAResourcePrepareEvent.java0000644000175000017500000000305612147207062024710 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.events; import bitronix.tm.utils.Decoder; import javax.transaction.xa.Xid; /** * * @author lorban */ public class XAResourcePrepareEvent extends XAEvent { private int returnCode; public XAResourcePrepareEvent(Object source, Xid xid, int returnCode) { super(source, xid); this.returnCode = returnCode; } public XAResourcePrepareEvent(Object source, Exception ex, Xid xid, int returnCode) { super(source, ex, xid); this.returnCode = returnCode; } public int getReturnCode() { return returnCode; } public String toString() { return "XAResourcePrepareEvent at " + getTimestamp() + " with vote=" + Decoder.decodePrepareVote(returnCode) + " on " + getXid(); } } btm-dist-2.1.4/test/bitronix/tm/mock/resource/0000755000175000017500000000000012147207062020023 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/mock/resource/jms/0000755000175000017500000000000012147207062020614 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/mock/resource/jms/MockXAConnectionFactory.java0000644000175000017500000000761212147207062026157 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.resource.jms; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import javax.jms.*; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import bitronix.tm.mock.resource.MockXAResource; /** * * @author lorban */ public class MockXAConnectionFactory implements XAConnectionFactory { private static JMSException staticCloseXAConnectionException; private static JMSException staticCreateXAConnectionException; public XAConnection createXAConnection() throws JMSException { if (staticCreateXAConnectionException != null) throw staticCreateXAConnectionException; Answer xaSessionAnswer = new Answer() { public XASession answer(InvocationOnMock invocation)throws Throwable { XASession mockXASession = mock(XASession.class); MessageProducer messageProducer = mock(MessageProducer.class); when(mockXASession.createProducer((Destination) anyObject())).thenReturn(messageProducer); MessageConsumer messageConsumer = mock(MessageConsumer.class); when(mockXASession.createConsumer((Destination) anyObject())).thenReturn(messageConsumer); when(mockXASession.createConsumer((Destination) anyObject(), anyString())).thenReturn(messageConsumer); when(mockXASession.createConsumer((Destination) anyObject(), anyString(), anyBoolean())).thenReturn(messageConsumer); Queue queue = mock(Queue.class); when(mockXASession.createQueue(anyString())).thenReturn(queue); Topic topic = mock(Topic.class); when(mockXASession.createTopic(anyString())).thenReturn(topic); MockXAResource mockXAResource = new MockXAResource(null); when(mockXASession.getXAResource()).thenReturn(mockXAResource); Answer sessionAnswer = new Answer() { public Session answer(InvocationOnMock invocation) throws Throwable { Session session = mock(Session.class); MessageProducer producer = mock(MessageProducer.class); when(session.createProducer((Destination) anyObject())).thenReturn(producer); return session; } }; when(mockXASession.getSession()).thenAnswer(sessionAnswer); return mockXASession; } }; XAConnection mockXAConnection = mock(XAConnection.class); when(mockXAConnection.createXASession()).thenAnswer(xaSessionAnswer); when(mockXAConnection.createSession(anyBoolean(), anyInt())).thenAnswer(xaSessionAnswer); if (staticCloseXAConnectionException != null) doThrow(staticCloseXAConnectionException).when(mockXAConnection).close(); return mockXAConnection; } public XAConnection createXAConnection(String jndiName, String jndiName1) throws JMSException { return createXAConnection(); } public static void setStaticCloseXAConnectionException(JMSException e) { staticCloseXAConnectionException = e; } public static void setStaticCreateXAConnectionException(JMSException e) { staticCreateXAConnectionException = e; } } btm-dist-2.1.4/test/bitronix/tm/mock/resource/jms/MockConnectionFactory.java0000644000175000017500000000347112147207062025725 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.resource.jms; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import javax.jms.*; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; /** * * @author lorban */ public class MockConnectionFactory implements ConnectionFactory { public Connection createConnection() throws JMSException { Answer sessionAnswer = new Answer() { public Session answer(InvocationOnMock invocation) throws Throwable { Session session = mock(Session.class); MessageProducer producer = mock(MessageProducer.class); when(session.createProducer((Destination) anyObject())).thenReturn(producer); return session; } }; Connection connection = mock(Connection.class); when(connection.createSession(anyBoolean(), anyInt())).thenAnswer(sessionAnswer); return connection; } public Connection createConnection(String jndiName, String jndiName1) throws JMSException { return createConnection(); } }btm-dist-2.1.4/test/bitronix/tm/mock/resource/MockJournal.java0000644000175000017500000000444112147207062023115 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.resource; import bitronix.tm.utils.Uid; import bitronix.tm.journal.Journal; import bitronix.tm.journal.TransactionLogRecord; import bitronix.tm.mock.events.EventRecorder; import bitronix.tm.mock.events.JournalLogEvent; import javax.transaction.Status; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Set; /** * * @author lorban */ public class MockJournal implements Journal { private Map danglingRecords; private EventRecorder getEventRecorder() { return EventRecorder.getEventRecorder(this); } public void log(int status, Uid gtrid, Set uniqueNames) throws IOException { TransactionLogRecord record = new TransactionLogRecord(status, gtrid, uniqueNames); if (status == Status.STATUS_COMMITTING) { danglingRecords.put(gtrid, record); } if (status == Status.STATUS_COMMITTED) { danglingRecords.remove(gtrid); } getEventRecorder().addEvent(new JournalLogEvent(this, status, gtrid, uniqueNames)); } public void open() throws IOException { danglingRecords = new HashMap(); } public void close() throws IOException { danglingRecords = null; } public void force() throws IOException { } public Map collectDanglingRecords() throws IOException { return danglingRecords; } public void shutdown() { } } btm-dist-2.1.4/test/bitronix/tm/mock/resource/MockXAResource.java0000644000175000017500000001270112147207062023521 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.resource; import javax.transaction.xa.*; import bitronix.tm.internal.BitronixXAException; import bitronix.tm.mock.events.*; import bitronix.tm.mock.resource.jdbc.*; /** * * @author lorban */ public class MockXAResource implements XAResource { private int prepareRc = XAResource.XA_OK; private int transactiontimeout; private MockitoXADataSource xads; private XAException endException; private XAException prepareException; private XAException commitException; private XAException rollbackException; private RuntimeException prepareRuntimeException; private XAException recoverException; private long recoveryDelay; public MockXAResource(MockitoXADataSource xads) { this.xads = xads; } public void setRecoveryDelay(long recoveryDelay) { this.recoveryDelay = recoveryDelay; } public void setPrepareRc(int prepareRc) { this.prepareRc = prepareRc; } public void addInDoubtXid(Xid xid) { xads.addInDoubtXid(xid); } private EventRecorder getEventRecorder() { return EventRecorder.getEventRecorder(this); } /* Interface implementation */ public int getTransactionTimeout() throws XAException { return transactiontimeout; } public boolean setTransactionTimeout(int i) throws XAException { this.transactiontimeout = i; return true; } public boolean isSameRM(XAResource xaResource) throws XAException { boolean result = xaResource == this; getEventRecorder().addEvent(new XAResourceIsSameRmEvent(this, xaResource, result)); return result; } public Xid[] recover(int flag) throws XAException { if (recoveryDelay > 0) { try { Thread.sleep(recoveryDelay); } catch (InterruptedException e) { // ignore } } if (recoverException != null) throw recoverException; if (xads == null) return new Xid[0]; return xads.getInDoubtXids(); } public int prepare(Xid xid) throws XAException { if (prepareException != null) { getEventRecorder().addEvent(new XAResourcePrepareEvent(this, prepareException, xid, -1)); prepareException.fillInStackTrace(); throw prepareException; } if (prepareRuntimeException != null) { prepareRuntimeException.fillInStackTrace(); getEventRecorder().addEvent(new XAResourcePrepareEvent(this, prepareRuntimeException, xid, -1)); throw prepareRuntimeException; } getEventRecorder().addEvent(new XAResourcePrepareEvent(this, xid, prepareRc)); return prepareRc; } public void forget(Xid xid) throws XAException { getEventRecorder().addEvent(new XAResourceForgetEvent(this, xid)); boolean found = xads.removeInDoubtXid(xid); if (!found) throw new BitronixXAException("unknown XID: " + xid, XAException.XAER_INVAL); } public void rollback(Xid xid) throws XAException { getEventRecorder().addEvent(new XAResourceRollbackEvent(this, rollbackException, xid)); if (rollbackException != null) throw rollbackException; if (xads != null) xads.removeInDoubtXid(xid); } public void end(Xid xid, int flag) throws XAException { getEventRecorder().addEvent(new XAResourceEndEvent(this, xid, flag)); if (endException != null) throw endException; } public void start(Xid xid, int flag) throws XAException { getEventRecorder().addEvent(new XAResourceStartEvent(this, xid, flag)); } public void commit(Xid xid, boolean b) throws XAException { getEventRecorder().addEvent(new XAResourceCommitEvent(this, commitException, xid, b)); if (commitException != null) throw commitException; if (xads != null) xads.removeInDoubtXid(xid); } public void setEndException(XAException endException) { this.endException = endException; } public void setPrepareException(XAException prepareException) { this.prepareException = prepareException; } public void setPrepareException(RuntimeException prepareException) { this.prepareRuntimeException = prepareException; } public void setCommitException(XAException commitException) { this.commitException = commitException; } public void setRollbackException(XAException rollbackException) { this.rollbackException = rollbackException; } public void setRecoverException(XAException recoverException) { this.recoverException = recoverException; } } btm-dist-2.1.4/test/bitronix/tm/mock/resource/MockXid.java0000644000175000017500000000445412147207062022233 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.resource; import javax.transaction.xa.Xid; /** * * @author lorban */ public class MockXid implements Xid { private int formatId = 123456; private byte[] bqual; private byte[] gtrid; public MockXid(long bqual0, long gtrid0, int formatId) { this(bqual0, gtrid0); this.formatId = formatId; } public MockXid(long bqual0, byte[] gtrid0, int formatId) { this.bqual = new byte[8]; System.arraycopy(longToBytes(bqual0), 0, bqual, 0, 8); this.gtrid = gtrid0; this.formatId = formatId; } public MockXid(long bqual0, long gtrid0) { this.bqual = new byte[8]; this.gtrid = new byte[8]; System.arraycopy(longToBytes(bqual0), 0, bqual, 0, 8); System.arraycopy(longToBytes(gtrid0), 0, gtrid, 0, 8); } public MockXid(byte[] bqual, byte[] gtrid) { this.bqual = bqual; this.gtrid = gtrid; } public MockXid(byte[] bqual, byte[] gtrid, int formatId) { this.bqual = bqual; this.gtrid = gtrid; this.formatId = formatId; } public int getFormatId() { return formatId; } public byte[] getBranchQualifier() { return bqual; } public byte[] getGlobalTransactionId() { return gtrid; } private static byte[] longToBytes(long aLong) { byte[] array = new byte[8]; for (int i = 0; i < 8; i++) { array[i] = (byte) ((aLong >> (8 * i)) & 0xff); } return array; } } btm-dist-2.1.4/test/bitronix/tm/mock/resource/jdbc/0000755000175000017500000000000012147207062020725 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/mock/resource/jdbc/MockDriver.java0000644000175000017500000000315412147207062023640 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.resource.jdbc; import java.sql.Driver; import java.sql.SQLException; import java.sql.Connection; import java.sql.DriverPropertyInfo; import java.util.Properties; /** * * @author lorban */ public class MockDriver implements Driver { public int getMajorVersion() { return 0; } public int getMinorVersion() { return 0; } public boolean jdbcCompliant() { return false; } public boolean acceptsURL(String url) throws SQLException { return false; } public Connection connect(String url, Properties info) throws SQLException { return MockitoXADataSource.createMockConnection(); } public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { return new DriverPropertyInfo[0]; } } btm-dist-2.1.4/test/bitronix/tm/mock/resource/jdbc/MockitoXADataSource.java0000644000175000017500000002034312147207062025403 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.mock.resource.jdbc; import static org.mockito.Mockito.*; import java.io.PrintWriter; import java.sql.*; import java.util.*; import javax.sql.*; import javax.transaction.xa.*; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import bitronix.tm.mock.events.*; import bitronix.tm.mock.resource.MockXAResource; /** * * @author lorban */ public class MockitoXADataSource implements XADataSource { private List xaConnections = new ArrayList(); private String userName; private String password; private String database; private Object uselessThing; private List inDoubtXids = new ArrayList(); private SQLException getXAConnectionException; private static SQLException staticGetXAConnectionException; private static SQLException staticCloseXAConnectionException; public int getLoginTimeout() throws SQLException { return 0; } public void setLoginTimeout(int seconds) throws SQLException { } public PrintWriter getLogWriter() throws SQLException { return null; } public void setLogWriter(PrintWriter out) throws SQLException { } public XAConnection getXAConnection() throws SQLException { if (staticGetXAConnectionException != null) throw staticGetXAConnectionException; if (getXAConnectionException != null) throw getXAConnectionException; // Create an XAResource XAResource xaResource = new MockXAResource(this); // Setup mock XAConnection final XAConnection mockXAConnection = mock(XAConnection.class); // Handle XAConnection.close(), first time we answer, after that we throw doAnswer(new Answer() { public Object answer(InvocationOnMock invocation) throws Throwable { EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockXAConnection); eventRecorder.addEvent(new XAConnectionCloseEvent(mockXAConnection)); return null; } }).doThrow(new SQLException("XAConnection is already closed")).when(mockXAConnection).close(); when(mockXAConnection.getXAResource()).thenReturn(xaResource); Connection mockConnection = createMockConnection(); when(mockXAConnection.getConnection()).thenReturn(mockConnection); if (staticCloseXAConnectionException != null) doThrow(staticCloseXAConnectionException).when(mockXAConnection).close(); xaConnections.add(mockXAConnection); return mockXAConnection; } public XAConnection getXAConnection(String user, String password) throws SQLException { return getXAConnection(); } public void setXaConnections(List xaConnections) { this.xaConnections = xaConnections; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getDatabase() { return database; } public void setDatabase(String database) { this.database = database; } public void addInDoubtXid(Xid xid) { inDoubtXids.add(xid); } public boolean removeInDoubtXid(Xid xid) { for (int i = 0; i < inDoubtXids.size(); i++) { Xid xid1 = (Xid) inDoubtXids.get(i); if (Arrays.equals(xid1.getGlobalTransactionId(), xid.getGlobalTransactionId()) && Arrays.equals(xid1.getBranchQualifier(), xid.getBranchQualifier()) ) { inDoubtXids.remove(xid1); return true; } } return false; } public Xid[] getInDoubtXids() { return (Xid[]) inDoubtXids.toArray(new Xid[inDoubtXids.size()]); } public void setGetXAConnectionException(SQLException ex) { this.getXAConnectionException = ex; } public static void setStaticGetXAConnectionException(SQLException ex) { staticGetXAConnectionException = ex; } public static void setStaticCloseXAConnectionException(SQLException ex) { staticCloseXAConnectionException = ex; } public static Connection createMockConnection() throws SQLException { // Setup mock connection final Connection mockConnection = mock(Connection.class); // Autocommit is always true by default when(mockConnection.getAutoCommit()).thenReturn(true); // Handle Connection.createStatement() Statement statement = mock(Statement.class); when(mockConnection.createStatement()).thenReturn(statement); when(mockConnection.createStatement(anyInt(), anyInt())).thenReturn(statement); when(mockConnection.createStatement(anyInt(), anyInt(), anyInt())).thenReturn(statement); // Handle Connection.prepareStatement() PreparedStatement mockPreparedStatement = mock(PreparedStatement.class); when(mockConnection.prepareStatement(anyString())).thenReturn(mockPreparedStatement); when(mockConnection.prepareStatement(anyString(), anyInt())).thenReturn(mockPreparedStatement); when(mockConnection.prepareStatement(anyString(), (int[]) anyObject())).thenReturn(mockPreparedStatement); when(mockConnection.prepareStatement(anyString(), (String[]) anyObject())).thenReturn(mockPreparedStatement); when(mockConnection.prepareStatement(anyString(), anyInt(), anyInt())).thenReturn(mockPreparedStatement); when(mockConnection.prepareStatement(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(mockPreparedStatement); // Handle Connection.prepareCall() CallableStatement mockCallableStatement = mock(CallableStatement.class); when(mockConnection.prepareCall(anyString())).thenReturn(mockCallableStatement); when(mockConnection.prepareCall(anyString(), anyInt(), anyInt())).thenReturn(mockCallableStatement); when(mockConnection.prepareCall(anyString(), anyInt(), anyInt(), anyInt())).thenReturn(mockCallableStatement); // Handle Connection.close() doAnswer(new Answer() { public Object answer(InvocationOnMock invocation) throws Throwable { EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockConnection); eventRecorder.addEvent(new ConnectionCloseEvent(mockConnection)); return null; } }).doThrow(new SQLException("Connection is already closed")).when(mockConnection).close(); // Handle Connection.commit() doAnswer(new Answer() { public Object answer(InvocationOnMock invocation) throws Throwable { EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockConnection); eventRecorder.addEvent(new LocalCommitEvent(mockConnection, new Exception())); return null; } }).doThrow(new SQLException("Transaction already commited")).when(mockConnection).commit(); // Handle Connection.rollback() doAnswer(new Answer() { public Object answer(InvocationOnMock invocation) throws Throwable { EventRecorder eventRecorder = EventRecorder.getEventRecorder(mockConnection); eventRecorder.addEvent(new LocalRollbackEvent(mockConnection, new Exception())); return null; } }).doThrow(new SQLException("Transaction already rolledback")).when(mockConnection).rollback(); return mockConnection; } public Object getUselessThing() { return uselessThing; } public void setUselessThing(Object uselessThing) { this.uselessThing = uselessThing; } } btm-dist-2.1.4/test/bitronix/tm/journal/0000755000175000017500000000000012147207062016715 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/journal/DiskJournalTest.java0000644000175000017500000001631612147207062022654 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.journal; import junit.framework.TestCase; import java.io.IOException; import java.io.File; import java.util.*; import bitronix.tm.TransactionManagerServices; import bitronix.tm.utils.Uid; import bitronix.tm.utils.UidGenerator; import javax.transaction.Status; /** * * @author lorban */ public class DiskJournalTest extends TestCase { protected void setUp() throws Exception { new File(TransactionManagerServices.getConfiguration().getLogPart1Filename()).delete(); new File(TransactionManagerServices.getConfiguration().getLogPart2Filename()).delete(); } public void testExceptions() throws Exception { DiskJournal journal = new DiskJournal(); try { journal.force(); fail("expected IOException"); } catch (IOException ex) { assertEquals("cannot force log writing, disk logger is not open", ex.getMessage()); } try { journal.log(0, null, null); fail("expected IOException"); } catch (IOException ex) { assertEquals("cannot write log, disk logger is not open", ex.getMessage()); } try { journal.collectDanglingRecords(); fail("expected IOException"); } catch (IOException ex) { assertEquals("cannot collect dangling records, disk logger is not open", ex.getMessage()); } journal.close(); } public void testSimpleCollectDanglingRecords() throws Exception { DiskJournal journal = new DiskJournal(); journal.open(); Uid gtrid = UidGenerator.generateUid(); assertEquals(0, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTING, gtrid, csvToSet("name1")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid, csvToSet("name1")); assertEquals(0, journal.collectDanglingRecords().size()); journal.close(); } public void testComplexCollectDanglingRecords() throws Exception { DiskJournal journal = new DiskJournal(); journal.open(); Uid gtrid1 = UidGenerator.generateUid(); Uid gtrid2 = UidGenerator.generateUid(); assertEquals(0, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTING, gtrid1, csvToSet("name1,name2,name3")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid1, csvToSet("name1")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid1, csvToSet("name2")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid1, csvToSet("name3")); assertEquals(0, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTING, gtrid2, csvToSet("name1,name2,name3")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid2, csvToSet("name2")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid2, csvToSet("name3,name1")); assertEquals(0, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTING, gtrid2, csvToSet("name1,name2,name3")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_UNKNOWN, gtrid2, csvToSet("name2")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid2, csvToSet("name1")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_ROLLEDBACK, gtrid2, csvToSet("name3")); assertEquals(0, journal.collectDanglingRecords().size()); journal.close(); } public void testCorruptedCollectDanglingRecords() throws Exception { DiskJournal journal = new DiskJournal(); journal.open(); Uid gtrid1 = UidGenerator.generateUid(); Uid gtrid2 = UidGenerator.generateUid(); assertEquals(0, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTING, gtrid1, csvToSet("name1,name2,name3")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid1, csvToSet("name1")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid1, csvToSet("name3")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid1, csvToSet("name4")); assertEquals(1, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid1, csvToSet("name2")); assertEquals(0, journal.collectDanglingRecords().size()); journal.log(Status.STATUS_COMMITTED, gtrid2, csvToSet("name1")); assertEquals(0, journal.collectDanglingRecords().size()); journal.close(); } public void testCrc32Value() throws Exception { Set names = new HashSet(); names.add("ActiveMQ"); names.add("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"); String uidString = "626974726F6E697853657276657249440000011C31FD45510000955B"; byte[] uidArray = new byte[uidString.length()/2]; for (int i=0; i journalRef = (AtomicReference) field.get(TransactionManagerServices.class); journalRef.set(new MockJournal()); poolingDataSource1 = new PoolingDataSource(); poolingDataSource1.setClassName(MockitoXADataSource.class.getName()); poolingDataSource1.setUniqueName("pds1"); poolingDataSource1.setMinPoolSize(5); poolingDataSource1.setMaxPoolSize(5); poolingDataSource1.setAutomaticEnlistingEnabled(true); poolingDataSource1.init(); poolingDataSource2 = new PoolingDataSource(); poolingDataSource2.setClassName(MockitoXADataSource.class.getName()); poolingDataSource2.setUniqueName("pds2"); poolingDataSource2.setMinPoolSize(5); poolingDataSource2.setMaxPoolSize(5); poolingDataSource2.setAutomaticEnlistingEnabled(true); poolingDataSource2.init(); poolingDataSource3 = new PoolingDataSource(); poolingDataSource3.setClassName(MockitoXADataSource.class.getName()); poolingDataSource3.setUniqueName("pds3"); poolingDataSource3.setMinPoolSize(5); poolingDataSource3.setMaxPoolSize(5); poolingDataSource3.setAutomaticEnlistingEnabled(true); poolingDataSource3.init(); poolingDataSourceLrc = new PoolingDataSource(); poolingDataSourceLrc.setClassName(LrcXADataSource.class.getName()); poolingDataSourceLrc.setUniqueName("pds4_lrc"); poolingDataSourceLrc.setMinPoolSize(5); poolingDataSourceLrc.setMaxPoolSize(5); poolingDataSourceLrc.setAllowLocalTransactions(true); poolingDataSourceLrc.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName()); poolingDataSourceLrc.getDriverProperties().setProperty("user", "user"); poolingDataSourceLrc.getDriverProperties().setProperty("password", "password"); poolingDataSourceLrc.init(); tm = TransactionManagerServices.getTransactionManager(); } protected void tearDown() throws Exception { poolingDataSource1.close(); poolingDataSource2.close(); poolingDataSource3.close(); poolingDataSourceLrc.close(); tm.shutdown(); } private XAException createXAException(String msg, int errorCode) { XAException prepareException = new XAException(msg); prepareException.errorCode = errorCode; return prepareException; } } btm-dist-2.1.4/test/bitronix/tm/twopc/OnePcFailureTest.java0000644000175000017500000001556412147207062022431 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc; import bitronix.tm.BitronixTransactionManager; import bitronix.tm.TransactionManagerServices; import bitronix.tm.journal.Journal; import bitronix.tm.mock.AbstractMockJdbcTest; import bitronix.tm.mock.events.Event; import bitronix.tm.mock.events.EventRecorder; import bitronix.tm.mock.events.JournalLogEvent; import bitronix.tm.mock.events.XAResourceCommitEvent; import bitronix.tm.mock.events.XAResourceForgetEvent; import bitronix.tm.mock.resource.MockJournal; import bitronix.tm.mock.resource.MockXAResource; import bitronix.tm.mock.resource.jdbc.MockitoXADataSource; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.jdbc.JdbcConnectionHandle; import bitronix.tm.resource.jdbc.PoolingDataSource; import junit.framework.TestCase; import oracle.jdbc.xa.OracleXAException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.sql.XAConnection; import javax.transaction.HeuristicMixedException; import javax.transaction.HeuristicRollbackException; import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.SystemException; import javax.transaction.xa.XAException; import java.lang.reflect.Field; import java.lang.reflect.Proxy; import java.sql.Connection; import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicReference; /** * * @author lorban */ public class OnePcFailureTest extends TestCase { private final static Logger log = LoggerFactory.getLogger(OnePcFailureTest.class); private PoolingDataSource poolingDataSource1; private BitronixTransactionManager tm; /** * Test scenario: * * XAResources: 2 * TX timeout: 10s * TX resolution: heuristic mixed * * XAResource 1 resolution: successful * XAResource 2 resolution: commit throws exception XAException.XAER_RMERR * * Expected outcome: * TM fails on resource 2 commit but does not report that via an exception * as the recoverer will clean that up * Expected TM events: * 2 XAResourcePrepareEvent, 2 XAResourceCommitEvent * Expected journal events: * ACTIVE, PREPARING, PREPARED, COMMITTING, COMMITTED * @throws Exception if any error happens. */ public void testExpectNoHeuristic() throws Exception { tm.begin(); tm.setTransactionTimeout(10); // TX must not timeout Connection connection1 = poolingDataSource1.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection1); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle.getPooledConnection()); connection1.createStatement(); final MockXAResource mockXAResource2 = (MockXAResource) xaConnection2.getXAResource(); mockXAResource2.setCommitException(createXAException("resource 2 commit failed with XAER_RMERR", XAException.XAER_RMERR)); try { tm.commit(); fail("expected RollbackException"); } catch (RollbackException ex) { assertTrue(ex.getMessage().matches("transaction failed during 1PC commit of a Bitronix Transaction with GTRID \\[.*\\], status=ROLLEDBACK, 1 resource\\(s\\) enlisted \\(.*\\)")); } log.info(EventRecorder.dumpToString()); int journalUnknownEventCount = 0; int journalCommittingEventCount = 0; int journalRolledbackEventCount = 0; int commitEventCount = 0; List events = EventRecorder.getOrderedEvents(); for (int i = 0; i < events.size(); i++) { Event event = (Event) events.get(i); if (event instanceof XAResourceCommitEvent) commitEventCount++; if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_UNKNOWN) journalUnknownEventCount++; } if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_COMMITTING) journalCommittingEventCount++; } if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_ROLLEDBACK) journalRolledbackEventCount++; } } assertEquals("TM should have logged a COMMITTING status", 1, journalCommittingEventCount); assertEquals("TM should have logged a ROLLEDBACK status", 1, journalRolledbackEventCount); assertEquals("TM should not have logged ant UNKNOWN status", 0, journalUnknownEventCount); assertEquals("TM haven't properly tried to commit", 1, commitEventCount); } protected void setUp() throws Exception { Iterator it = ResourceRegistrar.getResourcesUniqueNames().iterator(); while (it.hasNext()) { String name = (String) it.next(); ResourceRegistrar.unregister(ResourceRegistrar.get(name)); } EventRecorder.clear(); // change disk journal into mock journal Field field = TransactionManagerServices.class.getDeclaredField("journalRef"); field.setAccessible(true); AtomicReference journalRef = (AtomicReference) field.get(TransactionManagerServices.class); journalRef.set(new MockJournal()); poolingDataSource1 = new PoolingDataSource(); poolingDataSource1.setClassName(MockitoXADataSource.class.getName()); poolingDataSource1.setUniqueName("pds1"); poolingDataSource1.setMinPoolSize(5); poolingDataSource1.setMaxPoolSize(5); poolingDataSource1.setAutomaticEnlistingEnabled(true); poolingDataSource1.init(); tm = TransactionManagerServices.getTransactionManager(); } protected void tearDown() throws Exception { poolingDataSource1.close(); tm.shutdown(); } private XAException createXAException(String msg, int errorCode) { XAException prepareException = new OracleXAException(msg, 9876); prepareException.errorCode = errorCode; return prepareException; } } btm-dist-2.1.4/test/bitronix/tm/twopc/Phase2FailureTest.java0000644000175000017500000002746312147207062022550 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.twopc; import java.lang.reflect.*; import java.sql.Connection; import java.util.*; import java.util.concurrent.atomic.AtomicReference; import javax.sql.XAConnection; import javax.transaction.*; import javax.transaction.xa.XAException; import bitronix.tm.journal.Journal; import junit.framework.TestCase; import bitronix.tm.*; import bitronix.tm.mock.AbstractMockJdbcTest; import bitronix.tm.mock.events.*; import bitronix.tm.mock.resource.*; import bitronix.tm.mock.resource.jdbc.*; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.jdbc.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author lorban */ public class Phase2FailureTest extends TestCase { private final static Logger log = LoggerFactory.getLogger(Phase2FailureTest.class); private PoolingDataSource poolingDataSource1; private PoolingDataSource poolingDataSource2; private BitronixTransactionManager tm; /** * Test scenario: * * XAResources: 2 * TX timeout: 10s * TX resolution: heuristic mixed * * XAResource 1 resolution: successful * XAResource 2 resolution: commit throws exception XAException.XAER_RMERR * * Expected outcome: * TM fails on resource 2 commit but does not report that via an exception * as the recoverer will clean that up * Expected TM events: * 2 XAResourcePrepareEvent, 2 XAResourceCommitEvent * Expected journal events: * ACTIVE, PREPARING, PREPARED, COMMITTING, COMMITTED * @throws Exception if any error happens. */ public void testExpectNoHeuristic() throws Exception { tm.begin(); tm.setTransactionTimeout(10); // TX must not timeout Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle.getPooledConnection()); connection2.createStatement(); final MockXAResource mockXAResource2 = (MockXAResource) xaConnection2.getXAResource(); mockXAResource2.setCommitException(createXAException("resource 2 commit failed with XAER_RMERR", XAException.XAER_RMERR)); tm.commit(); log.info(EventRecorder.dumpToString()); int journalUnknownEventCount = 0; int journalCommittingEventCount = 0; int journalCommittedEventCount = 0; int commitEventCount = 0; List events = EventRecorder.getOrderedEvents(); for (int i = 0; i < events.size(); i++) { Event event = (Event) events.get(i); if (event instanceof XAResourceCommitEvent) commitEventCount++; if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_UNKNOWN) journalUnknownEventCount++; } if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_COMMITTING) journalCommittingEventCount++; } if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_COMMITTED) journalCommittedEventCount++; } } assertEquals("TM should have logged a COMMITTING status", 1, journalCommittingEventCount); assertEquals("TM should have logged a COMMITTED status", 1, journalCommittedEventCount); assertEquals("TM should not have logged ant UNKNOWN status", 0, journalUnknownEventCount); assertEquals("TM haven't properly tried to commit", 2, commitEventCount); } /** * Test scenario: * * XAResources: 2 * TX timeout: 1s * TX resolution: commit * * XAResource 1 resolution: successful * XAResource 2 resolution: commit throws exception XAException.XA_HEURCOM * * Expected outcome: * TM fails on resource 2 commit because of heuristic commit. Since the decision is compatible * with the TX outcome, the XID is forgotten on the resource and the TX should succeed. * Expected TM events: * 2 XAResourcePrepareEvent, 2 XAResourceCommitEvent, 1 XAResourceForgetEvent * Expected journal events: * ACTIVE, PREPARING, PREPARED, COMMITTING, COMMITTED * @throws Exception if any error happens. */ public void testHeuristicCommit() throws Exception { tm.begin(); tm.setTransactionTimeout(1); // TX timeout should have no effect here Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle.getPooledConnection()); connection2.createStatement(); final MockXAResource mockXAResource2 = (MockXAResource) xaConnection2.getXAResource(); mockXAResource2.setCommitException(createXAException("resource 2 commit failed with XA_HEURCOM", XAException.XA_HEURCOM)); tm.commit(); log.info(EventRecorder.dumpToString()); // we should find a COMMITTED status in the journal log // 2 commit tries and 1 forget int journalCommittedEventCount = 0; int commitEventCount = 0; int forgetEventCount = 0; List events = EventRecorder.getOrderedEvents(); for (int i = 0; i < events.size(); i++) { Event event = (Event) events.get(i); if (event instanceof XAResourceCommitEvent) commitEventCount++; if (event instanceof XAResourceForgetEvent) forgetEventCount++; if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_COMMITTED) journalCommittedEventCount++; } } assertEquals("TM should have logged a COMMITTED status", 1, journalCommittedEventCount); assertEquals("TM haven't properly tried to commit", 2, commitEventCount); assertEquals("TM haven't properly tried to forget", 1, forgetEventCount); } /** * Test scenario: * * XAResources: 2 * TX timeout: 1s * TX resolution: commit * * XAResource 1 resolution: successful * XAResource 2 resolution: commit throws exception XAException.XA_HEURRB * * Expected outcome: * TM fails on resource 2 commit because of heuristic rollback. Since the decision is not compatible * with the TX outcome, the TX should fail. * Expected TM events: * 2 XAResourcePrepareEvent, 2 XAResourceCommitEvent * Expected journal events: * ACTIVE, PREPARING, PREPARED, COMMITTING, COMMITTED * @throws Exception if any error happens. */ public void testHeuristicMixed() throws Exception { tm.begin(); tm.setTransactionTimeout(1); // TX timeout should have no effect here Connection connection1 = poolingDataSource1.getConnection(); connection1.createStatement(); Connection connection2 = poolingDataSource2.getConnection(); JdbcConnectionHandle handle = (JdbcConnectionHandle) Proxy.getInvocationHandler(connection2); XAConnection xaConnection2 = (XAConnection) AbstractMockJdbcTest.getWrappedXAConnectionOf(handle.getPooledConnection()); connection2.createStatement(); final MockXAResource mockXAResource2 = (MockXAResource) xaConnection2.getXAResource(); mockXAResource2.setCommitException(createXAException("resource 2 commit failed with XA_HEURRB", XAException.XA_HEURRB)); try { tm.commit(); fail("TM should have thrown HeuristicMixedException"); } catch (HeuristicMixedException ex) { assertEquals("transaction failed during commit of a Bitronix Transaction with GTRID [", ex.getMessage().substring(0, 71)); int idx = ex.getMessage().indexOf(']'); assertEquals("], status=UNKNOWN, 2 resource(s) enlisted (started ", ex.getMessage().substring(idx, idx + 51)); assertTrue("got message <" + ex.getMessage() + ">", ex.getMessage().endsWith("resource(s) [pds2] improperly unilaterally rolled back")); } log.info(EventRecorder.dumpToString()); int journalUnknownEventCount = 0; int commitEventCount = 0; List events = EventRecorder.getOrderedEvents(); for (int i = 0; i < events.size(); i++) { Event event = (Event) events.get(i); if (event instanceof XAResourceCommitEvent) commitEventCount++; if (event instanceof JournalLogEvent) { if (((JournalLogEvent) event).getStatus() == Status.STATUS_UNKNOWN) journalUnknownEventCount++; } } assertEquals("TM should have logged a UNKNOWN status", 1, journalUnknownEventCount); assertEquals("TM haven't properly tried to commit", 2, commitEventCount); } protected void setUp() throws Exception { Iterator it = ResourceRegistrar.getResourcesUniqueNames().iterator(); while (it.hasNext()) { String name = (String) it.next(); ResourceRegistrar.unregister(ResourceRegistrar.get(name)); } EventRecorder.clear(); // change disk journal into mock journal Field field = TransactionManagerServices.class.getDeclaredField("journalRef"); field.setAccessible(true); AtomicReference journalRef = (AtomicReference) field.get(TransactionManagerServices.class); journalRef.set(new MockJournal()); poolingDataSource1 = new PoolingDataSource(); poolingDataSource1.setClassName(MockitoXADataSource.class.getName()); poolingDataSource1.setUniqueName("pds1"); poolingDataSource1.setMinPoolSize(5); poolingDataSource1.setMaxPoolSize(5); poolingDataSource1.setAutomaticEnlistingEnabled(true); poolingDataSource1.init(); poolingDataSource2 = new PoolingDataSource(); poolingDataSource2.setClassName(MockitoXADataSource.class.getName()); poolingDataSource2.setUniqueName("pds2"); poolingDataSource2.setMinPoolSize(5); poolingDataSource2.setMaxPoolSize(5); poolingDataSource2.setAutomaticEnlistingEnabled(true); poolingDataSource2.init(); tm = TransactionManagerServices.getTransactionManager(); } protected void tearDown() throws Exception { poolingDataSource1.close(); poolingDataSource2.close(); tm.shutdown(); } private XAException createXAException(String msg, int errorCode) { XAException prepareException = new XAException(msg); prepareException.errorCode = errorCode; return prepareException; } } btm-dist-2.1.4/test/bitronix/tm/JdbcFailedPoolTest.java0000644000175000017500000001331412147207062021551 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import java.sql.SQLException; import junit.framework.TestCase; import bitronix.tm.mock.resource.jdbc.*; import bitronix.tm.recovery.*; import bitronix.tm.resource.ResourceRegistrar; import bitronix.tm.resource.jdbc.PoolingDataSource; /** * * @author lorban */ public class JdbcFailedPoolTest extends TestCase { protected void setUp() throws Exception { TransactionManagerServices.getJournal().open(); TransactionManagerServices.getTaskScheduler(); } protected void tearDown() throws Exception { TransactionManagerServices.getJournal().close(); TransactionManagerServices.getTaskScheduler().shutdown(); } public void testAcquiringConnectionAfterRecoveryDoesNotMarkAsFailed() throws Exception { PoolingDataSource poolingDataSource = new PoolingDataSource(); poolingDataSource.setClassName(MockitoXADataSource.class.getName()); poolingDataSource.setUniqueName("ds1"); poolingDataSource.setMaxPoolSize(1); poolingDataSource.setMaxIdleTime(1); // set low shrink timeout poolingDataSource.init(); IncrementalRecoverer.recover(poolingDataSource); MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work")); Thread.sleep(2000); // wait for shrink // should not work but should not mark the pool as failed as it could recover try { poolingDataSource.getConnection(); fail("expected SQLException"); } catch (SQLException ex) { assertEquals("unable to get a connection from pool of a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available)", ex.getMessage()); } poolingDataSource.close(); } public void testFailingRecoveryMarksAsFailed() throws Exception { MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work")); PoolingDataSource poolingDataSource = new PoolingDataSource(); poolingDataSource.setClassName(MockitoXADataSource.class.getName()); poolingDataSource.setUniqueName("ds1"); poolingDataSource.setMaxPoolSize(1); poolingDataSource.init(); // try { // IncrementalRecoverer.recover(poolingDataSource); // fail("expected RecoveryException"); // } catch (RecoveryException ex) { // assertEquals("cannot start recovery on a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available)", ex.getMessage()); // } // // assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available) -failed-", poolingDataSource.toString()); Recoverer recoverer = new Recoverer(); recoverer.run(); assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available) -failed-", poolingDataSource.toString()); // recoverer must not unregister the resource assertSame(poolingDataSource, ResourceRegistrar.get("ds1")); MockitoXADataSource.setStaticGetXAConnectionException(null); recoverer.run(); assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 1 connection(s) (1 still available)", poolingDataSource.toString()); // recoverer must not unregister the resource assertSame(poolingDataSource, ResourceRegistrar.get("ds1")); poolingDataSource.close(); } public void testSuccessfulRecoveryMarksAsNotFailed() throws Exception { MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("creating a new connection does not work")); PoolingDataSource poolingDataSource = new PoolingDataSource(); poolingDataSource.setClassName(MockitoXADataSource.class.getName()); poolingDataSource.setUniqueName("ds1"); poolingDataSource.setMaxPoolSize(1); poolingDataSource.init(); try { IncrementalRecoverer.recover(poolingDataSource); fail("expected RecoveryException"); } catch (RecoveryException ex) { assertEquals("cannot start recovery on a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available)", ex.getMessage()); } assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 0 connection(s) (0 still available) -failed-", poolingDataSource.toString()); MockitoXADataSource.setStaticGetXAConnectionException(null); Recoverer recoverer = new Recoverer(); recoverer.run(); assertEquals("a PoolingDataSource containing an XAPool of resource ds1 with 1 connection(s) (1 still available)", poolingDataSource.toString()); // recoverer must not unregister the resource assertSame(poolingDataSource, ResourceRegistrar.get("ds1")); poolingDataSource.close(); } } btm-dist-2.1.4/test/bitronix/tm/resource/0000755000175000017500000000000012147207062017072 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/resource/common/0000755000175000017500000000000012147207062020362 5ustar tonytonybtm-dist-2.1.4/test/bitronix/tm/resource/common/XAPoolTest.java0000644000175000017500000000442612147207062023235 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import junit.framework.TestCase; import bitronix.tm.*; import bitronix.tm.mock.resource.jdbc.MockitoXADataSource; import bitronix.tm.resource.jdbc.PoolingDataSource; import bitronix.tm.utils.CryptoEngine; /** * * @author lorban */ public class XAPoolTest extends TestCase { public void testBuildXAFactory() throws Exception { ResourceBean rb = new ResourceBean() {}; rb.setMaxPoolSize(1); rb.setClassName(MockitoXADataSource.class.getName()); rb.getDriverProperties().setProperty("userName", "java"); rb.getDriverProperties().setProperty("password", "{DES}" + CryptoEngine.crypt("DES", "java")); XAPool xaPool = new XAPool(null, rb); assertEquals(0, xaPool.totalPoolSize()); assertEquals(0, xaPool.inPoolSize()); MockitoXADataSource xads = (MockitoXADataSource) xaPool.getXAFactory(); assertEquals("java", xads.getUserName()); assertEquals("java", xads.getPassword()); } public void testNoRestartOfTaskSchedulerDuringClose() throws Exception { PoolingDataSource pds = new PoolingDataSource(); pds.setClassName(MockitoXADataSource.class.getName()); pds.setMaxPoolSize(1); pds.setUniqueName("mock"); pds.init(); BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager(); btm.shutdown(); pds.close(); assertFalse(TransactionManagerServices.isTaskSchedulerRunning()); } }btm-dist-2.1.4/test/bitronix/tm/resource/common/XAPoolHelper.java0000644000175000017500000000040212147207062023523 0ustar tonytonypackage bitronix.tm.resource.common; import java.util.List; /** * @author Ludovic Orban */ public class XAPoolHelper { public static List getXAResourceHolders(XAPool xaPool) { return xaPool.getXAResourceHolders(); } } btm-dist-2.1.4/test/bitronix/tm/resource/common/AbstractXAResourceHolderTest.java0000644000175000017500000000613712147207062026736 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource.common; import bitronix.tm.internal.XAResourceHolderState; import bitronix.tm.utils.Uid; import bitronix.tm.utils.UidGenerator; import junit.framework.TestCase; import javax.transaction.xa.XAResource; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; /** * * @author lorban */ public class AbstractXAResourceHolderTest extends TestCase { public void testStatesForGtridIterationOrder() throws Exception { final ResourceBean resourceBean = new ResourceBean() { }; AbstractXAResourceHolder xaResourceHolder = new AbstractXAResourceHolder() { public XAResource getXAResource() { return null; } public ResourceBean getResourceBean() { return resourceBean; } public List getXAResourceHolders() { return null; } public Object getConnectionHandle() throws Exception { return null; } public void close() throws Exception { } public Date getLastReleaseDate() { return null; } }; Uid gtrid = UidGenerator.generateUid(); XAResourceHolderState state1 = new XAResourceHolderState(xaResourceHolder, resourceBean); XAResourceHolderState state2 = new XAResourceHolderState(xaResourceHolder, resourceBean); XAResourceHolderState state3 = new XAResourceHolderState(xaResourceHolder, resourceBean); xaResourceHolder.putXAResourceHolderState(UidGenerator.generateXid(gtrid), state1); xaResourceHolder.putXAResourceHolderState(UidGenerator.generateXid(gtrid), state2); xaResourceHolder.putXAResourceHolderState(UidGenerator.generateXid(gtrid), state3); Map statesForGtrid = xaResourceHolder.getXAResourceHolderStatesForGtrid(gtrid); Iterator statesForGtridIt = statesForGtrid.values().iterator(); assertTrue(statesForGtridIt.hasNext()); assertSame(state1, statesForGtridIt.next()); assertTrue(statesForGtridIt.hasNext()); assertSame(state2, statesForGtridIt.next()); assertTrue(statesForGtridIt.hasNext()); assertSame(state3, statesForGtridIt.next()); assertFalse(statesForGtridIt.hasNext()); } } btm-dist-2.1.4/test/bitronix/tm/resource/ResourceLoaderTest.java0000644000175000017500000002551512147207062023523 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm.resource; import java.lang.reflect.Field; import java.util.*; import javax.sql.XADataSource; import junit.framework.TestCase; import bitronix.tm.mock.resource.jdbc.MockitoXADataSource; import bitronix.tm.mock.resource.jms.MockXAConnectionFactory; import bitronix.tm.resource.jdbc.PoolingDataSource; import bitronix.tm.resource.jms.PoolingConnectionFactory; import bitronix.tm.utils.PropertyUtils; /** * * @author lorban */ public class ResourceLoaderTest extends TestCase { public void testBindOneJdbc() throws Exception { ResourceLoader loader = new ResourceLoader(); Properties p = new Properties(); p.setProperty("resource.ds1.className", MockitoXADataSource.class.getName()); p.setProperty("resource.ds1.uniqueName", "dataSource1"); p.setProperty("resource.ds1.maxPoolSize", "123"); p.setProperty("resource.ds1.automaticEnlistingEnabled", "true"); p.setProperty("resource.ds1.useTmJoin", "false"); p.setProperty("resource.ds1.deferConnectionRelease", "true"); p.setProperty("resource.ds1.driverProperties.userName", "java"); p.setProperty("resource.ds1.driverProperties.password", "java"); p.setProperty("resource.ds1.driverProperties.database", "users1"); loader.initXAResourceProducers(p); Map dataSources = loader.getResources(); assertEquals(1, dataSources.size()); String uniqueName = (String) dataSources.keySet().iterator().next(); assertEquals("dataSource1", uniqueName); PoolingDataSource pds = (PoolingDataSource) dataSources.get(uniqueName); assertEquals("bitronix.tm.mock.resource.jdbc.MockitoXADataSource", pds.getClassName()); assertEquals("dataSource1", pds.getUniqueName()); assertEquals(123, pds.getMaxPoolSize()); assertEquals(3, pds.getDriverProperties().size()); } public void testDecryptPassword() throws Exception { ResourceLoader loader = new ResourceLoader(); Properties p = new Properties(); p.setProperty("resource.ds1.className", MockitoXADataSource.class.getName()); p.setProperty("resource.ds1.uniqueName", "dataSource10"); p.setProperty("resource.ds1.maxPoolSize", "123"); p.setProperty("resource.ds1.automaticEnlistingEnabled", "true"); p.setProperty("resource.ds1.useTmJoin", "false"); p.setProperty("resource.ds1.deferConnectionRelease", "true"); p.setProperty("resource.ds1.driverProperties.userName", "java"); p.setProperty("resource.ds1.driverProperties.password", "{DES}UcXKog312decCrwu51xGmw=="); p.setProperty("resource.ds1.driverProperties.database", "users1"); loader.initXAResourceProducers(p); Map dataSources = loader.getResources(); assertEquals(1, dataSources.size()); String uniqueName = (String) dataSources.keySet().iterator().next(); assertEquals("dataSource10", uniqueName); PoolingDataSource pds = (PoolingDataSource) dataSources.get(uniqueName); assertEquals("bitronix.tm.mock.resource.jdbc.MockitoXADataSource", pds.getClassName()); assertEquals("dataSource10", pds.getUniqueName()); assertEquals(123, pds.getMaxPoolSize()); assertEquals(3, pds.getDriverProperties().size()); String decryptedPassword = (String) PropertyUtils.getProperty(getXADataSource(pds), "password"); assertEquals("java", decryptedPassword); } protected XADataSource getXADataSource(PoolingDataSource poolingDataSource) throws NoSuchFieldException, IllegalAccessException { Field field = PoolingDataSource.class.getDeclaredField("xaDataSource"); field.setAccessible(true); return (XADataSource) field.get(poolingDataSource); } public void testBindOneJms() throws Exception { ResourceLoader loader = new ResourceLoader(); Properties p = new Properties(); p.setProperty("resource.ds1.className", MockXAConnectionFactory.class.getName()); p.setProperty("resource.ds1.uniqueName", "mq1"); p.setProperty("resource.ds1.maxPoolSize", "123"); p.setProperty("resource.ds1.automaticEnlistingEnabled", "true"); p.setProperty("resource.ds1.useTmJoin", "false"); p.setProperty("resource.ds1.deferConnectionRelease", "true"); p.setProperty("resource.ds1.driverProperties.endpoint", "tcp://somewhere"); loader.initXAResourceProducers(p); Map dataSources = loader.getResources(); assertEquals(1, dataSources.size()); String uniqueName = (String) dataSources.keySet().iterator().next(); assertEquals("mq1", uniqueName); PoolingConnectionFactory pcf = (PoolingConnectionFactory) dataSources.get(uniqueName); assertEquals("bitronix.tm.mock.resource.jms.MockXAConnectionFactory", pcf.getClassName()); assertEquals("mq1", pcf.getUniqueName()); assertEquals(123, pcf.getMaxPoolSize()); assertEquals(1, pcf.getDriverProperties().size()); } public void testBind2WithSomeDefaults() throws Exception { ResourceLoader loader = new ResourceLoader(); Properties p = new Properties(); p.setProperty("resource.ds1.className", MockitoXADataSource.class.getName()); p.setProperty("resource.ds1.uniqueName", "dataSource2"); p.setProperty("resource.ds1.maxPoolSize", "123"); p.setProperty("resource.ds1.automaticEnlistingEnabled", "true"); p.setProperty("resource.ds1.useTmJoin", "false"); p.setProperty("resource.ds1.deferConnectionRelease", "true"); p.setProperty("resource.ds1.driverProperties.userName", "java"); p.setProperty("resource.ds1.driverProperties.password", "java"); p.setProperty("resource.ds1.driverProperties.database", "users1"); p.setProperty("resource.ds2.className", MockitoXADataSource.class.getName()); p.setProperty("resource.ds2.uniqueName", "some.unique.Name"); p.setProperty("resource.ds2.maxPoolSize", "123"); loader.initXAResourceProducers(p); Map dataSources = loader.getResources(); assertEquals(2, dataSources.size()); PoolingDataSource pds = (PoolingDataSource) dataSources.get("dataSource2"); assertEquals("bitronix.tm.mock.resource.jdbc.MockitoXADataSource", pds.getClassName()); assertEquals("dataSource2", pds.getUniqueName()); assertEquals(123, pds.getMaxPoolSize()); assertEquals(3, pds.getDriverProperties().size()); pds = (PoolingDataSource) dataSources.get("some.unique.Name"); assertEquals("bitronix.tm.mock.resource.jdbc.MockitoXADataSource", pds.getClassName()); assertEquals("some.unique.Name", pds.getUniqueName()); assertEquals(123, pds.getMaxPoolSize()); assertEquals(true, pds.getDeferConnectionRelease()); assertEquals(true, pds.getAutomaticEnlistingEnabled()); assertEquals(true, pds.getUseTmJoin()); assertEquals(0, pds.getDriverProperties().size()); } public void testConfigErrors() throws Exception { ResourceLoader loader = new ResourceLoader(); try { Properties p = new Properties(); p.setProperty("resource.ds2.className", "some.class.Name"); loader.initXAResourceProducers(p); fail("should have thrown ResourceConfigurationException"); } catch (ResourceConfigurationException ex) { assertEquals("cannot configure resource for configuration entries with name [ds2] - failing property is [className]", ex.getMessage()); assertEquals(ClassNotFoundException.class, ex.getCause().getClass()); assertEquals("some.class.Name", ex.getCause().getMessage()); } try { Properties p = new Properties(); p.setProperty("resource.ds2.className", MockitoXADataSource.class.getName()); loader.initXAResourceProducers(p); fail("should have thrown ResourceConfigurationException"); } catch (ResourceConfigurationException ex) { assertEquals("missing mandatory property [uniqueName] of resource [ds2] in resources configuration file", ex.getMessage()); } try { Properties p = new Properties(); p.setProperty("resource.ds2.jndiName", "some.jndi.Name"); loader.initXAResourceProducers(p); fail("should have thrown ResourceConfigurationException"); } catch (ResourceConfigurationException ex) { assertEquals("missing mandatory property [className] for resource [ds2] in resources configuration file", ex.getMessage()); } Properties p = new Properties(); p.setProperty("resource.ds2.className", MockitoXADataSource.class.getName()); p.setProperty("resource.ds2.uniqueName", "some.other.unique.Name"); p.setProperty("resource.ds2.maxPoolSize", "123"); loader.initXAResourceProducers(p); } public void testFormatErrors() throws Exception { ResourceLoader loader = new ResourceLoader(); Properties p = new Properties(); p.setProperty("resource.ds2.className", MockitoXADataSource.class.getName()); p.setProperty("resource.ds2.uniqueName", "some.more.unique.Name"); p.setProperty("resource.ds2.maxPoolSize", "abc"); // incorrect format try { loader.initXAResourceProducers(p); fail("expected ResourceConfigurationException"); } catch (ResourceConfigurationException ex) { assertEquals("cannot configure resource for configuration entries with name [ds2] - failing property is [maxPoolSize]", ex.getMessage()); } p.setProperty("resource.ds2.className", MockitoXADataSource.class.getName()); p.setProperty("resource.ds2.uniqueName", "some.also.other.unique.Name"); p.setProperty("resource.ds2.maxPoolSize", "123"); p.setProperty("resource.ds2.useTmJoin", "unknown"); // incorrect format, will default to false loader.initXAResourceProducers(p); PoolingDataSource pds = (PoolingDataSource) loader.getResources().get("some.also.other.unique.Name"); assertFalse(pds.getUseTmJoin()); } } btm-dist-2.1.4/test/bitronix/tm/JtaTest.java0000644000175000017500000002022412147207062017464 0ustar tonytony/* * Bitronix Transaction Manager * * Copyright (c) 2010, Bitronix Software. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package bitronix.tm; import bitronix.tm.utils.DefaultExceptionAnalyzer; import junit.framework.TestCase; import javax.transaction.*; import bitronix.tm.resource.jdbc.PoolingDataSource; import bitronix.tm.resource.jdbc.lrc.LrcXADataSource; import bitronix.tm.mock.resource.jdbc.MockDriver; import java.sql.Connection; import org.slf4j.LoggerFactory; import org.slf4j.Logger; /** * * @author lorban */ public class JtaTest extends TestCase { private final static Logger log = LoggerFactory.getLogger(JtaTest.class); private BitronixTransactionManager btm; protected void setUp() throws Exception { TransactionManagerServices.getConfiguration().setGracefulShutdownInterval(1); TransactionManagerServices.getConfiguration().setExceptionAnalyzer(DefaultExceptionAnalyzer.class.getName()); btm = TransactionManagerServices.getTransactionManager(); } protected void tearDown() throws Exception { btm.shutdown(); } public void testTransactionManagerGetTransaction() throws Exception { assertNull(btm.getTransaction()); btm.begin(); assertNotNull(btm.getTransaction()); btm.commit(); assertNull(btm.getTransaction()); btm.begin(); assertNotNull(btm.getTransaction()); btm.rollback(); } // this test also helps verifying MDC support but logs have to be manually checked public void testSuspendResume() throws Exception { log.info("test starts"); btm.begin(); log.info("tx begun"); Transaction tx = btm.suspend(); log.info("tx suspended"); btm.resume(tx); log.info("tx resumed"); btm.rollback(); log.info("test over"); } public void testTimeout() throws Exception { btm.setTransactionTimeout(1); btm.begin(); CountingSynchronization sync = new CountingSynchronization(); btm.getTransaction().registerSynchronization(sync); Thread.sleep(2000); assertEquals(Status.STATUS_MARKED_ROLLBACK, btm.getTransaction().getStatus()); try { btm.commit(); fail("commit should have thrown an RollbackException"); } catch (RollbackException ex) { assertEquals("transaction timed out and has been rolled back", ex.getMessage()); } assertEquals(1, sync.beforeCount); assertEquals(1, sync.afterCount); } public void testMarkedRollback() throws Exception { btm.begin(); CountingSynchronization sync = new CountingSynchronization(); btm.getTransaction().registerSynchronization(sync); btm.setRollbackOnly(); assertEquals(Status.STATUS_MARKED_ROLLBACK, btm.getTransaction().getStatus()); try { btm.commit(); fail("commit should have thrown an RollbackException"); } catch (RollbackException ex) { assertEquals("transaction was marked as rollback only and has been rolled back", ex.getMessage()); } assertEquals(1, sync.beforeCount); assertEquals(1, sync.afterCount); } public void testRecycleAfterSuspend() throws Exception { PoolingDataSource pds = new PoolingDataSource(); pds.setClassName(LrcXADataSource.class.getName()); pds.setUniqueName("lrc-pds"); pds.setMaxPoolSize(2); pds.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName()); pds.init(); btm.begin(); Connection c1 = pds.getConnection(); c1.createStatement(); c1.close(); Transaction tx = btm.suspend(); btm.begin(); Connection c11 = pds.getConnection(); c11.createStatement(); c11.close(); btm.commit(); btm.resume(tx); Connection c2 = pds.getConnection(); c2.createStatement(); c2.close(); btm.commit(); pds.close(); } public void testTransactionContextCleanup() throws Exception { assertEquals(Status.STATUS_NO_TRANSACTION, btm.getStatus()); btm.begin(); assertEquals(Status.STATUS_ACTIVE, btm.getStatus()); final Transaction tx = btm.getTransaction(); // commit on a different thread Thread t = new Thread() { public void run() { try { tx.commit(); } catch (Exception ex) { ex.printStackTrace(); fail(); } } }; t.start(); t.join(); assertNull(btm.getTransaction()); } public void testBeforeCompletionAddsExtraSynchronizationInDifferentPriority() throws Exception { btm.begin(); btm.getCurrentTransaction().getSynchronizationScheduler().add(new SynchronizationRegisteringSynchronization(btm.getCurrentTransaction()), 5); btm.commit(); } public void testDebugZeroResourceTransactionDisabled() throws Exception { btm.begin(); assertNull("Activation stack trace must not be available by default.", btm.getCurrentTransaction().getActivationStackTrace()); btm.commit(); } public void testDebugZeroResourceTransaction() throws Exception { btm.shutdown(); // necessary to change the configuration TransactionManagerServices.getConfiguration().setDebugZeroResourceTransaction(true); btm = TransactionManagerServices.getTransactionManager(); btm.begin(); assertNotNull("Activation stack trace must be available.", btm.getCurrentTransaction().getActivationStackTrace()); btm.commit(); } public void testBeforeCompletionRuntimeExceptionRethrown() throws Exception { btm.begin(); btm.getTransaction().registerSynchronization(new Synchronization() { public void beforeCompletion() { throw new RuntimeException("beforeCompletion failure"); } public void afterCompletion(int i) { } }); try { btm.commit(); fail("expected runtime exception"); } catch (RollbackException ex) { assertEquals(RuntimeException.class, ex.getCause().getClass()); assertEquals("beforeCompletion failure", ex.getCause().getMessage()); } btm.begin(); btm.commit(); } private class SynchronizationRegisteringSynchronization implements Synchronization { private BitronixTransaction transaction; public SynchronizationRegisteringSynchronization(BitronixTransaction transaction) { this.transaction = transaction; } public void beforeCompletion() { try { transaction.getSynchronizationScheduler().add(new Synchronization() { public void beforeCompletion() { } public void afterCompletion(int i) { } }, 10); } catch (Exception e) { fail("unexpected exception: " + e); } } public void afterCompletion(int i) { } } private class CountingSynchronization implements Synchronization { public int beforeCount = 0; public int afterCount = 0; public void beforeCompletion() { beforeCount++; } public void afterCompletion(int i) { afterCount++; } } } btm-dist-2.1.4/test/bitronix-res.properties0000644000175000017500000000426712147207062017541 0ustar tonytony# # Bitronix XA resource loader example config file # # bind configured resources to JNDI bitronix.tm.resource.bind=true # These will create two PoolingDataSource's wrapping the FBConnectionPoolDataSource resource.ds1.className=org.firebirdsql.pool.FBConnectionPoolDataSource resource.ds1.uniqueName=fb1 resource.ds1.poolSize=5 resource.ds1.acquisitionTimeout=30 resource.ds1.testQuery=select 1 from rdb$database resource.ds1.deferConnectionRelease=true resource.ds1.driverProperties.userName=java resource.ds1.driverProperties.password=java resource.ds1.driverProperties.database=users1 resource.ds1.driverProperties.blockingTimeout=3000 resource.ds1.driverProperties.pooling=true resource.ds2.className=org.firebirdsql.pool.FBConnectionPoolDataSource resource.ds2.uniqueName=fb2 resource.ds2.poolSize=5 resource.ds2.acquisitionTimeout=30 resource.ds2.testQuery=select 1 from rdb$database resource.ds2.deferConnectionRelease=true resource.ds2.driverProperties.userName=java resource.ds2.driverProperties.password=java resource.ds2.driverProperties.database=users2 resource.ds2.driverProperties.blockingTimeout=3000 resource.ds2.driverProperties.pooling=true # These will bind a PoolingConnectionFactory wrapping the ActiveMQXAConnectionFactory resource.mq1.className=org.apache.activemq.ActiveMQXAConnectionFactory resource.mq1.uniqueName=amq1 resource.mq1.poolSize=2 resource.mq1.driverProperties.userName=defaultUser resource.mq1.driverProperties.password=defaultPassword resource.mq1.driverProperties.brokerURL=tcp://localhost:61616 # These will bind a PoolingConnectionFactory fetching the SMQ QueueConnectionFactory from another JNDI resource.mq2.className=bitronix.tm.resource.jms.JndiXAConnectionFactory resource.mq2.uniqueName=smq2 resource.mq2.poolSize=2 resource.mq2.cacheProducersConsumers=true resource.mq2.driverProperties.name=QueueConnectionFactory resource.mq2.driverProperties.initialContextFactory=com.swiftmq.jndi.InitialContextFactoryImpl resource.mq2.driverProperties.providerUrl=smqp://localhost:4001/timeout=10000 resource.mq2.serverSessionPool.poolSize=2 resource.mq2.serverSessionPool.listenerClassName=bitronix.tm.resource.jms.SimpleMessageListener btm-dist-2.1.4/test/bitronix-default-config.properties0000644000175000017500000000140212136323160021617 0ustar tonytony#bitronix.tm.serverId=server-id #bitronix.tm.2pc.async=false bitronix.tm.journal.disk.logPart1Filename=target/btm1.tlog bitronix.tm.journal.disk.logPart2Filename=target/btm2.tlog #bitronix.tm.journal.disk.forcedWriteEnabled=true #bitronix.tm.journal.disk.forceBatchingEnabled=true #bitronix.tm.journal.disk.skipCorruptedLogs=false # maxLogSize is in MB #bitronix.tm.journal.disk.maxLogSize=2 #bitronix.tm.journal.disk.filterLogStatus=false # these timer parameters are all in seconds #bitronix.tm.timer.defaultTransactionTimeout=60 #bitronix.tm.timer.transactionRetryInterval=10 bitronix.tm.timer.gracefulShutdownInterval=10 # this one is in minutes #bitronix.tm.timer.backgroundRecoveryInterval=0 # resources configuration file #bitronix.tm.resource.configuration=btm-dist-2.1.4/build.properties0000644000175000017500000000005112215446660015224 0ustar tonytony# # The BTM version. # btm.version=2.1.4 btm-dist-2.1.4/license.txt0000644000175000017500000001674312147207062014204 0ustar tonytony GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.