Class BSHGroupSelector
java.lang.Object
org.jpos.util.SimpleLogSource
org.jpos.transaction.participant.BSHTransactionParticipant
org.jpos.transaction.participant.BSHGroupSelector
- All Implemented Interfaces:
XmlConfigurable, AbortParticipant, GroupSelector, TransactionConstants, TransactionParticipant, LogSource
BeanShell-backed
GroupSelector that evaluates a <select> script
to choose the next participant group, falling back to defaultSelect(long, Serializable)
when the script returns null.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BSHMethodCompiled BSH method invoked to determine the active group.Fields inherited from class BSHTransactionParticipant
abortMethod, commitMethod, prepareForAbortMethod, prepareMethodFields inherited from class SimpleLogSource
logger, realmFields inherited from interface TransactionConstants
ABORTED, FAIL, NO_JOIN, PAUSE, PREPARED, READONLY, RETRYModifier and TypeFieldDescriptionstatic final intTransaction has been aborted.static final intShortcut for a read-only, non-joining abort (READONLY | NO_JOIN).static final intThis participant does not join the transactionstatic final intTransaction is paused.static final intTransaction has been prepared successfully.static final intContext has not been modified (no need to persist a snapshot)static final intTransaction should be retried. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefaultSelect(long id, Serializable context) Hook returning the default group when the BSH script returnsnull.select(long id, Serializable context) Selects the transaction group to execute.voidsetConfiguration(org.jdom2.Element e) Configures this object from an XML element.Methods inherited from class BSHTransactionParticipant
abort, commit, defaultAbort, defaultCommit, defaultPrepare, executeMethod, prepare, prepareForAbortModifier 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) Default abort handling when no BeanShell abort method is configured (no-op).protected voiddefaultCommit(long id, Serializable context, LogEvent ev) Default commit implementation (no-op).protected intdefaultPrepare(long id, Serializable context, LogEvent ev) Default prepare implementation; returns PREPARED|READONLY.protected ObjectexecuteMethod(BSHMethod m, long id, Serializable context, LogEvent evt, String resultName) Executes the given BSHMethod with the standard transaction parameters.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.Methods inherited from class SimpleLogSource
error, error, getLogger, getRealm, info, info, setLogger, setRealm, warning, warningModifier and TypeMethodDescriptionvoidLogs an error message.voidLogs an error message with an attached object.Returns the logger.getRealm()Returns the logging realm.voidLogs an informational message.voidLogs an informational message with an attached object.voidSets the logger and realm for this log source.voidSets the logging realm.voidLogs a warning message.voidLogs a warning message with an attached object.
-
Field Details
-
selectMethod
Compiled BSH method invoked to determine the active group.
-
-
Constructor Details
-
BSHGroupSelector
public BSHGroupSelector()Default constructor; no instance state to initialise.
-
-
Method Details
-
setConfiguration
Description copied from interface:XmlConfigurableConfigures this object from an XML element.- Specified by:
setConfigurationin interfaceXmlConfigurable- Overrides:
setConfigurationin classBSHTransactionParticipant- Parameters:
e- Configuration element- Throws:
ConfigurationException- on error
-
select
Description copied from interface:GroupSelectorSelects the transaction group to execute.- Specified by:
selectin interfaceGroupSelector- Parameters:
id- transaction idcontext- transaction context- Returns:
- group name or null for no-action
-
defaultSelect
Hook returning the default group when the BSH script returnsnull. Subclasses may override to provide deterministic fallback selection.- Parameters:
id- transaction idcontext- transaction context- Returns:
- default group identifier (empty string by default)
-