Class BSHTransactionParticipant
java.lang.Object
org.jpos.util.SimpleLogSource
org.jpos.transaction.participant.BSHTransactionParticipant
- All Implemented Interfaces:
XmlConfigurable, AbortParticipant, TransactionConstants, TransactionParticipant, LogSource
- Direct Known Subclasses:
BSHGroupSelector
public class BSHTransactionParticipant
extends SimpleLogSource
implements TransactionParticipant, AbortParticipant, XmlConfigurable
A TransactionParticipant whose prepare, commit and abort methods can be
specified through beanshell scripts.
To indicate what code to execute for any of the methods just add an element named 'prepare', 'commit' or 'abort' contained in that of the participant.
See BSHMethod for details on the syntax of these elements. The value to return in the prepare method should be stored in the script variable named "result". None of these tags are mandatory.
You can subclass BSHTransactionParticipant and override the default... methods. That way you can provide default behaviour for a participant and override it at deploy time through scripts.
To indicate what code to execute for any of the methods just add an element named 'prepare', 'commit' or 'abort' contained in that of the participant.
See BSHMethod for details on the syntax of these elements. The value to return in the prepare method should be stored in the script variable named "result". None of these tags are mandatory.
You can subclass BSHTransactionParticipant and override the default... methods. That way you can provide default behaviour for a participant and override it at deploy time through scripts.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BSHMethodprotected BSHMethodprotected BSHMethodprotected BSHMethodFields inherited from class SimpleLogSource
logger, realm -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of BSHTransactionParticipant -
Method Summary
Modifier and TypeMethodDescriptionvoidabort(long id, Serializable context) Called by TransactionManager upon transaction commit.voidcommit(long id, Serializable context) Called by TransactionManager upon transaction commit.protected voiddefaultAbort(long id, Serializable context, LogEvent ev) protected voiddefaultCommit(long id, Serializable context, LogEvent ev) protected intdefaultPrepare(long id, Serializable context, LogEvent ev) protected ObjectexecuteMethod(BSHMethod m, long id, Serializable context, LogEvent evt, String resultName) intprepare(long id, Serializable context) Called by TransactionManager in preparation for a transactionintprepareForAbort(long id, Serializable context) Called by TransactionManager in preparation for a transaction that is known to abort.voidsetConfiguration(org.jdom2.Element e)
-
Field Details
-
prepareMethod
-
prepareForAbortMethod
-
commitMethod
-
abortMethod
-
-
Constructor Details
-
BSHTransactionParticipant
public BSHTransactionParticipant()Creates a new instance of BSHTransactionParticipant
-
-
Method Details
-
abort
Description copied from interface:TransactionParticipantCalled by TransactionManager upon transaction commit. Warning: implementation should be able to handle multiple calls with the same transaction id (rare crash recovery)- Specified by:
abortin interfaceTransactionParticipant- Parameters:
id- the Transaction identifiercontext- transaction context
-
defaultAbort
-
commit
Description copied from interface:TransactionParticipantCalled by TransactionManager upon transaction commit. Warning: implementation should be able to handle multiple calls with the same transaction id (rare crash recovery)- Specified by:
commitin interfaceTransactionParticipant- Parameters:
id- the Transaction identifiercontext- transaction context
-
defaultCommit
-
prepare
Description copied from interface:TransactionParticipantCalled by TransactionManager in preparation for a transaction- Specified by:
preparein interfaceTransactionParticipant- Parameters:
id- the Transaction identifiercontext- transaction context- Returns:
- PREPARED or ABORTED (| NO_JOIN | READONLY)
-
prepareForAbort
Description copied from interface:AbortParticipantCalled by TransactionManager in preparation for a transaction that is known to abort.- Specified by:
prepareForAbortin interfaceAbortParticipant- Parameters:
id- the Transaction identifiercontext- transaction context- Returns:
- 0 [| NO_JOIN | READONLY)
-
defaultPrepare
-
setConfiguration
- Specified by:
setConfigurationin interfaceXmlConfigurable- Parameters:
e- Configuration element- Throws:
ConfigurationException- on error
-
executeMethod
protected Object executeMethod(BSHMethod m, long id, Serializable context, LogEvent evt, String resultName) throws bsh.EvalError, IOException - Throws:
bsh.EvalErrorIOException
-