public class JSParticipant extends Log implements TransactionParticipant, AbortParticipant, XmlConfigurable
Add a transaction participant like this: <participant class="org.jpos.transaction.participant.JSParticipant" logger="Q2" realm="js" src='deploy/test.js' /> test.js may look like this (all functions are optional) var K = Java.type("org.jpos.transaction.TransactionConstants"); var prepare = function(id, ctx) { var map = ctx.getMap(); ctx.log ("Prepare has been called"); ctx.log (map.TIMESTAMP); map.NEWPROPERTY='ABC'; return K.PREPARED; } var prepareForAbort = function(id, ctx) { ctx.put ("Test", "Test from JS transaction $id"); ctx.log ("prepareForAbort has been called"); return K.PREPARED; } var commit = function(id, ctx) { ctx.log ("Commit has been called"); } var abort = function(id, ctx) { ctx.log ("Abort has been called"); }
Constructor and Description |
---|
JSParticipant() |
Modifier and Type | Method and Description |
---|---|
void |
abort(long id,
java.io.Serializable context)
Called by TransactionManager upon transaction commit.
|
void |
commit(long id,
java.io.Serializable context)
Called by TransactionManager upon transaction commit.
|
int |
prepare(long id,
java.io.Serializable context)
Called by TransactionManager in preparation for a transaction
|
int |
prepareForAbort(long id,
java.io.Serializable context)
Called by TransactionManager in preparation for a transaction
that is known to abort.
|
void |
setConfiguration(org.jdom2.Element e) |
createDebug, createDebug, createError, createError, createFatal, createFatal, createInfo, createInfo, createLogEvent, createLogEvent, createTrace, createTrace, createWarn, createWarn, debug, debug, error, error, fatal, fatal, getLog, getLogger, getRealm, info, info, setLogger, setLogger, setRealm, trace, trace, warn, warn
public int prepare(long id, java.io.Serializable context)
TransactionParticipant
prepare
in interface TransactionParticipant
id
- the Transaction identifiercontext
- transaction contextpublic int prepareForAbort(long id, java.io.Serializable context)
AbortParticipant
prepareForAbort
in interface AbortParticipant
id
- the Transaction identifiercontext
- transaction contextpublic void commit(long id, java.io.Serializable context)
TransactionParticipant
commit
in interface TransactionParticipant
id
- the Transaction identifiercontext
- transaction contextpublic void abort(long id, java.io.Serializable context)
TransactionParticipant
abort
in interface TransactionParticipant
id
- the Transaction identifiercontext
- transaction contextpublic void setConfiguration(org.jdom2.Element e) throws ConfigurationException
setConfiguration
in interface XmlConfigurable
e
- Configuration elementConfigurationException
- on error