code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@Override 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); ...
This task is used to run the background recovery. @author Ludovic Orban
execute
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/RecoveryTask.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/RecoveryTask.java
Apache-2.0
@Override public String toString() { return "a RecoveryTask scheduled for " + getExecutionTime(); }
This task is used to run the background recovery. @author Ludovic Orban
toString
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/RecoveryTask.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/RecoveryTask.java
Apache-2.0
public Date getExecutionTime() { return executionTime; }
Asbtract superclass of all timed tasks. @author Ludovic Orban
getExecutionTime
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/Task.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/Task.java
Apache-2.0
protected TaskScheduler getTaskScheduler() { return taskScheduler; }
Asbtract superclass of all timed tasks. @author Ludovic Orban
getTaskScheduler
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/Task.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/Task.java
Apache-2.0
@Override public int compareTo(Task otherTask) { int compareResult = this.executionTime.compareTo(otherTask.executionTime); if (compareResult == 0) { compareResult = Integer.valueOf(uniqueId).compareTo(otherTask.getUniqueId()); } return compareResult; }
Asbtract superclass of all timed tasks. @author Ludovic Orban
compareTo
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/Task.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/Task.java
Apache-2.0
int getUniqueId() { return uniqueId; }
Asbtract superclass of all timed tasks. @author Ludovic Orban
getUniqueId
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/Task.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/Task.java
Apache-2.0
private void lock() { if (tasksLock != null) { tasksLock.lock(); } }
Timed tasks service. @author Ludovic Orban
lock
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
private void unlock() { if (tasksLock != null) { tasksLock.unlock(); } }
Timed tasks service. @author Ludovic Orban
unlock
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
private SortedSet<Task> getSafeIterableTasks() { if (tasksLock != null) { return new TreeSet<Task>(tasks); } else { return tasks; } }
Timed tasks service. @author Ludovic Orban
getSafeIterableTasks
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
public int countTasksQueued() { lock(); try { return tasks.size(); } finally { unlock(); } }
Get the amount of tasks currently queued. @return the amount of tasks currently queued.
countTasksQueued
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
@Override public void shutdown() { boolean wasActive = setActive(false); if (wasActive) { try { long gracefulShutdownTime = TransactionManagerServices.getConfiguration().getGracefulShutdownInterval() * 1000; if (log.isDebugEnabled()) { log.debug("graceful...
Get the amount of tasks currently queued. @return the amount of tasks currently queued.
shutdown
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
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 no...
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 transa...
scheduleTransactionTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
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 (!removeTaskBy...
Cancel the task that will mark the transaction as timed out at the specified date. @param transaction the transaction to mark as timeout.
cancelTransactionTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
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) ...
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.
scheduleRecovery
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
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); } }
Cancel the task that will run background recovery at the specified date. @param recoverer the recovery implementation to use.
cancelRecovery
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
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("expecte...
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.
schedulePoolShrinking
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
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.isDebu...
Cancel the task that will tell a XA pool to close idle connections. @param xaPool the XA pool to notify.
cancelPoolShrinking
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
void addTask(Task task) { lock(); try { removeTaskByObject(task.getObject()); tasks.add(task); } finally { unlock(); } }
Cancel the task that will tell a XA pool to close idle connections. @param xaPool the XA pool to notify.
addTask
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
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(...
Cancel the task that will tell a XA pool to close idle connections. @param xaPool the XA pool to notify.
removeTaskByObject
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
boolean setActive(boolean active) { return this.active.getAndSet(active); }
Cancel the task that will tell a XA pool to close idle connections. @param xaPool the XA pool to notify.
setActive
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
private boolean isActive() { return active.get(); }
Cancel the task that will tell a XA pool to close idle connections. @param xaPool the XA pool to notify.
isActive
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
@Override public void run() { while (isActive()) { try { executeElapsedTasks(); Thread.sleep(500); // execute twice per second. That's enough precision. } catch (InterruptedException ex) { // ignore } } }
Cancel the task that will tell a XA pool to close idle connections. @param xaPool the XA pool to notify.
run
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
private void executeElapsedTasks() { lock(); try { if (this.tasks.isEmpty()) return; Set<Task> toRemove = new HashSet<Task>(); for (Task task : getSafeIterableTasks()) { if (task.getExecutionTime().compareTo(new Date(MonotonicClock.cur...
Cancel the task that will tell a XA pool to close idle connections. @param xaPool the XA pool to notify.
executeElapsedTasks
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TaskScheduler.java
Apache-2.0
@Override public Object getObject() { return transaction; }
This task is used to mark a transaction as timed-out. @author Ludovic Orban
getObject
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TransactionTimeoutTask.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TransactionTimeoutTask.java
Apache-2.0
@Override 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 " + transacti...
This task is used to mark a transaction as timed-out. @author Ludovic Orban
execute
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TransactionTimeoutTask.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TransactionTimeoutTask.java
Apache-2.0
@Override public String toString() { return "a TransactionTimeoutTask on " + transaction + " scheduled for " + getExecutionTime(); }
This task is used to mark a transaction as timed-out. @author Ludovic Orban
toString
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/timer/TransactionTimeoutTask.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/timer/TransactionTimeoutTask.java
Apache-2.0
protected void executePhase(XAResourceManager resourceManager, boolean reverse) throws PhaseException { SortedSet<Integer> positions; if (reverse) { positions = resourceManager.getReverseOrderPositions(); if (log.isDebugEnabled()) { log.debug("executing phase on " + resourceManag...
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 paral...
executePhase
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
Apache-2.0
private JobsExecutionReport runJobsForPosition(List<XAResourceHolderState> resources) { List<Job> jobs = new ArrayList<Job>(); List<Exception> exceptions = new ArrayList<Exception>(); List<XAResourceHolderState> errorResources = new ArrayList<XAResourceHolderState>(); // start threads ...
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 paral...
runJobsForPosition
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
Apache-2.0
protected void logFailedResources(PhaseException ex) { List<Exception> exceptions = ex.getExceptions(); List<XAResourceHolderState> resources = ex.getResourceStates(); for (int i = 0; i < exceptions.size(); i++) { Exception e = exceptions.get(i); XAResourceHolderState ho...
Log exceptions that happened during a phase failure. @param ex the phase exception.
logFailedResources
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
Apache-2.0
protected static Set<String> collectResourcesUniqueNames(List<XAResourceHolderState> resources) { Set<String> uniqueNames = new HashSet<String>(); for (XAResourceHolderState resourceHolderState : resources) { uniqueNames.add(resourceHolderState.getUniqueName()); } return un...
Log exceptions that happened during a phase failure. @param ex the phase exception.
collectResourcesUniqueNames
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
Apache-2.0
protected static List<XAResourceHolderState> collectNotInterestedResources(List<XAResourceHolderState> allResources, List<XAResourceHolderState> interestedResources) { List<XAResourceHolderState> result = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState resourceHolderState : allResour...
Log exceptions that happened during a phase failure. @param ex the phase exception.
collectNotInterestedResources
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
Apache-2.0
public List<Exception> getExceptions() { return exceptions; }
Log exceptions that happened during a phase failure. @param ex the phase exception.
getExceptions
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
Apache-2.0
public List<XAResourceHolderState> getResources() { return resources; }
Log exceptions that happened during a phase failure. @param ex the phase exception.
getResources
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/AbstractPhaseEngine.java
Apache-2.0
@Override 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.ap...
Thrown when a phase exection has thrown one or more exception(s). @author Ludovic Orban
getMessage
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/PhaseException.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/PhaseException.java
Apache-2.0
public List<Exception> getExceptions() { return exceptions; }
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.
getExceptions
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/PhaseException.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/PhaseException.java
Apache-2.0
public List<XAResourceHolderState> getResourceStates() { return resourceStates; }
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 pha...
getResourceStates
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/PhaseException.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/PhaseException.java
Apache-2.0
public List<XAResourceHolderState> prepare(BitronixTransaction transaction) throws RollbackException, BitronixSystemException { XAResourceManager resourceManager = transaction.getResourceManager(); transaction.setStatus(Status.STATUS_PREPARING); preparedResources.clear(); if (resourceMa...
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 bitr...
prepare
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/Preparer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/Preparer.java
Apache-2.0
private void throwException(String message, PhaseException phaseException) throws BitronixRollbackException { List<Exception> exceptions = phaseException.getExceptions(); List<XAResourceHolderState> resources = phaseException.getResourceStates(); List<XAResourceHolderState> heuristicResources =...
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 bitr...
throwException
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/Preparer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/Preparer.java
Apache-2.0
@Override protected Job createJob(XAResourceHolderState xaResourceHolderState) { return new PrepareJob(xaResourceHolderState); }
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.
createJob
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/Preparer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/Preparer.java
Apache-2.0
@Override protected boolean isParticipating(XAResourceHolderState xaResourceHolderState) { return true; }
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.
isParticipating
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/Preparer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/Preparer.java
Apache-2.0
@Override public void execute() { try { XAResourceHolderState resourceHolder = getResource(); if (log.isDebugEnabled()) { log.debug("preparing resource " + resourceHolder); } int vote = resourceHolder.getXAResource().prepare(resourceHolder.getXid()); ...
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.
execute
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/Preparer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/Preparer.java
Apache-2.0
@Override public String toString() { return "a PrepareJob with " + getResource(); }
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.
toString
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/Preparer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/Preparer.java
Apache-2.0
public XAResourceHolderState getResource() { return resourceHolder; }
Abstract job definition executable by the 2PC thread pools. @author Ludovic Orban
getResource
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/executor/Job.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/executor/Job.java
Apache-2.0
public XAException getXAException() { return xaException; }
Abstract job definition executable by the 2PC thread pools. @author Ludovic Orban
getXAException
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/executor/Job.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/executor/Job.java
Apache-2.0
public RuntimeException getRuntimeException() { return runtimeException; }
Abstract job definition executable by the 2PC thread pools. @author Ludovic Orban
getRuntimeException
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/executor/Job.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/executor/Job.java
Apache-2.0
public void setFuture(Object future) { this.future = future; }
Abstract job definition executable by the 2PC thread pools. @author Ludovic Orban
setFuture
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/executor/Job.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/executor/Job.java
Apache-2.0
public Object getFuture() { return future; }
Abstract job definition executable by the 2PC thread pools. @author Ludovic Orban
getFuture
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/executor/Job.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/executor/Job.java
Apache-2.0
@Override public final void run() { String oldThreadName = null; if (TransactionManagerServices.getConfiguration().isAsynchronous2Pc()) { oldThreadName = Thread.currentThread().getName(); Thread.currentThread().setName("bitronix-2pc [ " + resourceHolder.ge...
Abstract job definition executable by the 2PC thread pools. @author Ludovic Orban
run
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/twopc/executor/Job.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/twopc/executor/Job.java
Apache-2.0
public static Set<Class<?>> getAllInterfaces(Class<?> clazz) { Set<Class<?>> interfaces = new HashSet<Class<?>>(); for (Class<?> intf : Arrays.asList(clazz.getInterfaces())) { if (intf.getInterfaces().length > 0) { interfaces.addAll(getAllInterfaces(intf)); } ...
Static utility methods for loading classes and resources.
getAllInterfaces
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
Apache-2.0
public static ClassLoader getClassLoader() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl != null) { return new CascadingClassLoader(cl); } return ClassLoaderUtils.class.getClassLoader(); }
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.
getClassLoader
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
Apache-2.0
public static Class loadClass(String className) throws ClassNotFoundException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl != null) { try { return new CascadingClassLoader(cl).loadClass(className); } catch (ClassNotFoundException ex) {...
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.
loadClass
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
Apache-2.0
public static InputStream getResourceAsStream(String resourceName) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl != null) return cl.getResourceAsStream(resourceName); return ClassLoaderUtils.class.getClassLoader().getResourceAsStream(resourceName); }
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.
getResourceAsStream
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
Apache-2.0
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { try { return contextLoader.loadClass(name); } catch (ClassNotFoundException cnfe) { return CascadingClassLoader.class.getClassLoader().loadClass(name); ...
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.
findClass
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ClassLoaderUtils.java
Apache-2.0
public static boolean containsByIdentity(Collection<?> collection, Object toBeFound) { for (Object o : collection) { if (o == toBeFound) return true; } return false; }
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.
containsByIdentity
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CollectionUtils.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CollectionUtils.java
Apache-2.0
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); ...
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 ...
crypt
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
public static String decrypt(String cipher, String data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IOException { DESKeySpec desKeySpec = new DESKeySpec(CRYPTO_PASSWORD.getBytes()); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(cip...
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...
decrypt
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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 <password> [ciphe...
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.
main
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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; }
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
getAlphabet
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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; }
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
getDecodabet
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
private static byte[] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes, int options) { encode3to4(threeBytes, 0, numSigBytes, b4, 0, options); return b4; }
Encodes up to the first three bytes of array <var>threeBytes</var> and returns a four-byte array in Base64 notation. The actual number of significant bytes in your array is given by <var>numSigBytes</var>. The array <var>threeBytes</var> needs only be as big as <var>numSigBytes</var>. Code can reuse a byte array by pas...
encode3to4
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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 posi...
<p>Encodes up to three bytes of the array <var>source</var> and writes the resulting four Base64 bytes to <var>destination</var>. The source and destination arrays can be manipulated anywhere along their length by specifying <var>srcOffset</var> and <var>destOffset</var>. This method does not check to make sure your ar...
encode3to4
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); }
Encodes a byte array into Base64 notation. Does not GZip-compress data. @param source The data to convert @return a String @since 1.4
encodeBytes
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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 ...
Encodes a byte array into Base64 notation. <p/> Valid options:<pre> GZIP: gzip-compresses object before encoding it. DONT_BREAK_LINES: don't break lines at 76 characters <i>Note: Technically, this makes your encoding non-compliant.</i> </pre> <p/> Example: <code>encodeBytes( myData, Base64.GZIP )</code> or <p/>...
encodeBytes
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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 wa...
Decodes four bytes from array <var>source</var> and writes the resulting bytes (up to three of them) to <var>destination</var>. The source and destination arrays can be manipulated anywhere along their length by specifying <var>srcOffset</var> and <var>destOffset</var>. This method does not check to make sure your arra...
decode4to3
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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]; ...
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 ...
decode
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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 @return the decoded data @since 1.4
decode
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
public static byte[] decode(String s, int options) { byte[] bytes = s.getBytes(UTF8); //</change> // Decode bytes = decode(bytes, 0, bytes.length, options); // Check to see if it's gzip-compressed // GZIP Magic Two-Byte Number: 0x8b1f (35615) ...
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
decode
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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 { ...
Attempts to decode Base64 data and deserialize a Java Object within. Returns <tt>null</tt> if there was an error. @param encodedObject The Base64 data to decode @return The decoded and deserialized object @since 1.5
decodeToObject
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
@Override public void write(int theByte) throws java.io.IOException { // Encoding suspended? if (suspendEncoding) { super.out.write(theByte); return; } // end if: supsended // Encode? i...
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
write
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
@Override 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 ...
Calls {@link #write(int)} repeatedly until <var>len</var> 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
write
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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 { ...
Method added by PHIL. [Thanks, PHIL. -Rob] This pads the buffer without closing the stream. @throws java.io.IOException when wrong padding is used
flushBase64
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
@Override 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(); ...
Flushes and closes (I think, in the superclass) the stream. @since 1.3
close
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
public void suspendEncoding() throws java.io.IOException { flushBase64(); this.suspendEncoding = true; }
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
suspendEncoding
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
public void resumeEncoding() { this.suspendEncoding = false; }
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
resumeEncoding
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/CryptoEngine.java
Apache-2.0
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_...
Constant to string decoder. @author Ludovic Orban
decodeXAExceptionErrorCode
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Decoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Decoder.java
Apache-2.0
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_R...
Constant to string decoder. @author Ludovic Orban
decodeStatus
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Decoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Decoder.java
Apache-2.0
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 XAResou...
Constant to string decoder. @author Ludovic Orban
decodeXAResourceFlag
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Decoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Decoder.java
Apache-2.0
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 + ")!"; } }
Constant to string decoder. @author Ludovic Orban
decodePrepareVote
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Decoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Decoder.java
Apache-2.0
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 + ")!"; } ...
Constant to string decoder. @author Ludovic Orban
decodeHeaderState
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Decoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Decoder.java
Apache-2.0
public static String collectResourcesNames(Collection<XAResourceHolderState> resources) { StringBuilder sb = new StringBuilder(); sb.append("["); Iterator<XAResourceHolderState> it = resources.iterator(); while (it.hasNext()) { XAResourceHolderState resourceHolderState = it....
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.
collectResourcesNames
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Decoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Decoder.java
Apache-2.0
@Override public String extractExtraXAExceptionDetails(XAException ex) { if (ex.getClass().getName().equals("oracle.jdbc.xa.OracleXAException")) { try { return "ORA-" + PropertyUtils.getProperty(ex, "oracleError"); } catch (PropertyException e) { retur...
Default implementation of {@link ExceptionAnalyzer}. @author Ludovic Orban
extractExtraXAExceptionDetails
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/DefaultExceptionAnalyzer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/DefaultExceptionAnalyzer.java
Apache-2.0
@Override public void shutdown() { }
Default implementation of {@link ExceptionAnalyzer}. @author Ludovic Orban
shutdown
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/DefaultExceptionAnalyzer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/DefaultExceptionAnalyzer.java
Apache-2.0
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) & 0x...
Number to byte array and byte array to number encoder. @author Ludovic Orban
longToBytes
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Encoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Encoder.java
Apache-2.0
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; }
Number to byte array and byte array to number encoder. @author Ludovic Orban
intToBytes
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Encoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Encoder.java
Apache-2.0
public static byte[] shortToBytes(short aShort) { byte[] array = new byte[2]; array[1] = (byte) (aShort & 0xff); array[0] = (byte) ((aShort >> 8) & 0xff); return array; }
Number to byte array and byte array to number encoder. @author Ludovic Orban
shortToBytes
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Encoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Encoder.java
Apache-2.0
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...
Number to byte array and byte array to number encoder. @author Ludovic Orban
bytesToLong
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Encoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Encoder.java
Apache-2.0
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=...
Number to byte array and byte array to number encoder. @author Ludovic Orban
bytesToInt
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/Encoder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/Encoder.java
Apache-2.0
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(); }
Returns the stack trace of the specified {@link Throwable}. @param t the throwable @return the string representation of the stack trace
getStackTrace
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ExceptionUtils.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ExceptionUtils.java
Apache-2.0
@Override public void run() { while (!isInterrupted()) { try { normalizeAndRunQueuedCommands(); sleep(250); // sampling interval } catch (InterruptedException ex) { ...
JMX facade used to (un)register any JMX enabled instances. <p> In case there is no JMX implementation available, calling methods of this class have no effect. JMX registrations may be synchronous or asynchronous using a work-queue and worker thread. The latter enables higher throughput by avoiding the registration of v...
run
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
public static String makeValidName(String name) { return name.replaceAll("[\\:\\,\\=,\\.]", "_"); }
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 '_'.
makeValidName
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
public static void register(String name, Object obj) { if (mbeanServer == null) return; runOrEnqueueCommand(new ManagementRegisterCommand(name, obj)); }
Register the specified management object. @param name the name of the object. @param obj the management object.
register
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
public static void unregister(String name) { if (mbeanServer == null) return; runOrEnqueueCommand(new ManagementUnregisterCommand(name)); }
Unregister the management object with the specified name. @param name the name of the object.
unregister
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
private static void runOrEnqueueCommand(ManagementCommand command) { if (commandQueue == null) command.run(); else { // Try to enqueue the command unless the queue is full. // Recover from a full queue by running already queued commands first to protect the async. imp...
Unregister the management object with the specified name. @param name the name of the object.
runOrEnqueueCommand
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
static void normalizeAndRunQueuedCommands() { if (commandQueue == null) return; // Synchronizing on commandQueue to ensure that even if 2 threads try to poll, only one can process the commands // that were scheduled at a time (happens if queue is full or during unit tests). ...
Unregister the management object with the specified name. @param name the name of the object.
normalizeAndRunQueuedCommands
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
boolean isReplace() { return replace; }
Registers the given instance within the JMX environment.
isReplace
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
void setReplace(boolean replace) { this.replace = replace; }
Registers the given instance within the JMX environment.
setReplace
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
@Override protected void runCommand() throws Exception { final Object object = instance.get(); if (object != null) { ObjectName objectName = new ObjectName(name); if (replace && mbeanServer.isRegistered(objectName)) mbeanServer.unregist...
Registers the given instance within the JMX environment.
runCommand
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
@Override protected void runCommand() throws Exception { try { mbeanServer.unregisterMBean(new ObjectName(name)); } catch (InstanceNotFoundException e) { if (log.isDebugEnabled()) { log.debug("Failed to unregister the JMX instance of name '" + name + "' as...
Unregisters the given instance within the JMX environment.
runCommand
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
public String getName() { return name; }
Base class for management related commands.
getName
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0
public final void run() { try { if (log.isDebugEnabled()) { log.debug("Calling " + getClass().getSimpleName() + " on object with name " + name); } runCommand(); } catch (Exception ex) { log.warn("Cannot execute " + getClass().getSimpleName() + " on...
Base class for management related commands.
run
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/utils/ManagementRegistrar.java
Apache-2.0