Skip to content

Commit cce6a27

Browse files
committed
added 'trace' capabilities
1 parent d6194c3 commit cce6a27

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

jpos/src/main/java/org/jpos/transaction/Context.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Context implements Externalizable, Loggeable, Pausable {
3434
private Map pmap; // persistent (serializable) map
3535
private long timeout;
3636
private boolean resumeOnPause = false;
37+
private transient boolean trace = false;
3738

3839
public static String LOGEVT = "LOGEVT";
3940
public static String PROFILER = "PROFILER";
@@ -42,10 +43,16 @@ public class Context implements Externalizable, Loggeable, Pausable {
4243
public Context () {
4344
super ();
4445
}
46+
4547
/**
4648
* puts an Object in the transient Map
4749
*/
4850
public void put (Object key, Object value) {
51+
if (trace) {
52+
getProfiler().checkPoint(
53+
String.format(" %s='%s' [%s]", key, value, new Throwable().getStackTrace()[1].toString())
54+
);
55+
}
4956
getMap().put (key, value);
5057
synchronized (this) {
5158
notifyAll();
@@ -55,9 +62,14 @@ public void put (Object key, Object value) {
5562
* puts an Object in the transient Map
5663
*/
5764
public void put (Object key, Object value, boolean persist) {
58-
getMap().put (key, value);
65+
if (trace) {
66+
getProfiler().checkPoint(
67+
String.format("P: %s='%s' [%s]", key, value, new Throwable().getStackTrace()[1].toString())
68+
);
69+
}
5970
if (persist && value instanceof Serializable)
6071
getPMap().put (key, value);
72+
getMap().put(key, value);
6173
}
6274
/**
6375
* Get
@@ -261,6 +273,13 @@ public synchronized void resume() {
261273
resumeOnPause = true;
262274
}
263275
}
276+
public boolean isTrace() {
277+
return trace;
278+
}
279+
public void setTrace(boolean trace) {
280+
getProfiler();
281+
this.trace = trace;
282+
}
264283
static final long serialVersionUID = 6056487212221438338L;
265284
}
266285

0 commit comments

Comments
 (0)