Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions jpos/src/main/java/org/jpos/transaction/TransactionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public TransactionManager() {}
/** Configured group-name to participant-list mapping. */
protected Map<String,List<TransactionParticipant>> groups;
private Set<Destroyable> destroyables = new HashSet<>();
private static final ThreadLocal<Serializable> tlContext = new ThreadLocal<>();
private static final ThreadLocal<Long> tlId = new ThreadLocal<>();
private Metrics metrics;
private Map<TransactionParticipant,ParticipantParams> params = new HashMap<>();
private long globalMaxTime;
Expand Down Expand Up @@ -298,7 +296,6 @@ private void runTransaction (Serializable context, int session) {

tme.begin();
try {
setThreadLocal(id, context);
if (hasStatusListeners)
notifyStatusListeners (session, TransactionStatusEvent.State.READY, id, "", null);

Expand Down Expand Up @@ -347,7 +344,6 @@ private void runTransaction (Serializable context, int session) {
else
evt.addMessage (t);
} finally {
removeThreadLocal();
if (hasStatusListeners) {
notifyStatusListeners (
session,
Expand Down Expand Up @@ -1291,31 +1287,6 @@ public int getActiveSessions() {
public int getMaxSessions() {
return maxSessions;
}
/**
* Returns the current thread's transaction context as a raw {@link Serializable}.
*
* @return the thread-local context, or {@code null} when no transaction is in progress
*/
public static Serializable getSerializable() {
return tlContext.get();
}
/**
* Returns the current thread's transaction context, narrowed to the caller's expected type.
*
* @param <T> caller-supplied context type
* @return the thread-local context, or {@code null} when no transaction is in progress
*/
public static <T extends Serializable> T getContext() {
return (T) tlContext.get();
}
/**
* Returns the current thread's transaction id, when one is in progress.
*
* @return the thread-local transaction id, or {@code null}
*/
public static Long getId() {
return tlId.get();
}


private void notifyStatusListeners
Expand All @@ -1334,14 +1305,6 @@ private void setThreadName (long id, String method, TransactionParticipant p) {
LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()))
);
}
private void setThreadLocal (long id, Serializable context) {
tlId.set(id);
tlContext.set(context);
}
private void removeThreadLocal() {
tlId.remove();
tlContext.remove();
}

private String getName(TransactionParticipant p) {
return Optional.ofNullable(params.get(p)).map(ParticipantParams::name).orElseGet(() -> defaultParticipantName(p));
Expand Down