Package org.jbpm.casemgmt.impl.generator
Class TableCaseIdGenerator
- java.lang.Object
-
- org.jbpm.casemgmt.impl.generator.TableCaseIdGenerator
-
- All Implemented Interfaces:
CaseIdGenerator
public class TableCaseIdGenerator extends Object implements CaseIdGenerator
Data base tabled backed case id generator. The underlying table keeps single entry per case prefix and updates it (by incrementing current value) on each call to generate method. Generation is done with pessimistic locking to secure correctness and since it's the only operation in transaction it should not cause any performance issues.
-
-
Constructor Summary
Constructors Constructor Description TableCaseIdGenerator(TransactionalCommandService commandService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CaseIdInfofindCaseIdInfoByPrefix(String prefix)Stringgenerate(String prefix, Map<String,Object> optionalParameters)Generates next value for given prefix.StringgetIdentifier()Identifier of the generator so it can be found and registered at runtimevoidregister(String prefix)Should be called only one time per given prefix.StringresolveCaseIdPrefix(String expression, Map<String,Object> optionalParameters)Evaluates the current prefix expression to generate the sequence name given the parameters passedvoidunregister(String prefix)Unregisters given prefix from the generator.
-
-
-
Constructor Detail
-
TableCaseIdGenerator
public TableCaseIdGenerator(TransactionalCommandService commandService)
-
-
Method Detail
-
getIdentifier
public String getIdentifier()
Description copied from interface:CaseIdGeneratorIdentifier of the generator so it can be found and registered at runtime- Specified by:
getIdentifierin interfaceCaseIdGenerator- Returns:
- unique identifier
-
register
public void register(String prefix)
Description copied from interface:CaseIdGeneratorShould be called only one time per given prefix. Subsequent calls with same prefix do not affect the generator state.- Specified by:
registerin interfaceCaseIdGenerator- Parameters:
prefix- unique prefix that should be used for generating case identifiers
-
unregister
public void unregister(String prefix)
Description copied from interface:CaseIdGeneratorUnregisters given prefix from the generator. It's up to generator implementation to either remove the prefix and its latest value permanently or resume it in case of further registration of the same prefix.- Specified by:
unregisterin interfaceCaseIdGenerator- Parameters:
prefix- unique prefix that should be used for generating case identifiers
-
resolveCaseIdPrefix
public String resolveCaseIdPrefix(String expression, Map<String,Object> optionalParameters)
Description copied from interface:CaseIdGeneratorEvaluates the current prefix expression to generate the sequence name given the parameters passed- Specified by:
resolveCaseIdPrefixin interfaceCaseIdGeneratoroptionalParameters- parameters needed to evaluate the expression- Returns:
- returns the sequence name
-
generate
public String generate(String prefix, Map<String,Object> optionalParameters)
Description copied from interface:CaseIdGeneratorGenerates next value for given prefix. Returned value should include the prefix as part of the returned value.- Specified by:
generatein interfaceCaseIdGenerator- Parameters:
prefix- unique prefix that should be used for generating case identifiersoptionalParameters- map of optionalParameters that might be helpful for implementation- Returns:
- complete case id in format (PREFIX-GENERATED_VALUE)
-
findCaseIdInfoByPrefix
protected CaseIdInfo findCaseIdInfoByPrefix(String prefix)
-
-