code
docs
tests
This library provides Services to easily generate unique identifiers and sequences of numbers.
Table 46. Artifact
| Group ID | Artifact ID | Version |
|---|---|---|
org.apache.polygene.libraries | org.apache.polygene.library.uid | 3.0.0 |
Assembly is done using the provided Assembler:
new UuidServiceAssembler().visibleIn( layer ).assemble( moduleAssembly );
Usage is quite simple:
@Service UuidService uuidService;
public void doSomething()
{
String id1 = uuidService.generateUuid( 0 );
// eg. 1020ECBB-098C-46E0-94DC-F78E2265EAA1-36
String id2 = uuidService.generateUuid( 12 );
// eg. 84E06578EAE3
}
Sequencing is used to automatically generate a sequence of numbers.
The algorithm is that currentSequenceValue is the number that was last returned in a newSequenceValue call, and will
initially be zero. Persisting Sequencing services defines "initially" as the first run ever, as subsequent starts may
retrieve the currentSequenceValue from an EntityStore.
Assembly is done using the provided Assembler:
new TransientSequencingAssembler().visibleIn( layer ).assemble( moduleAssembly );
Usage is quite simple:
@Service Sequencing sequencing;
public void doSomething()
{
sequencing.currentSequenceValue(); // return 0
sequencing.newSequenceValue(); // return 1
sequencing.currentSequenceValue(); // return 1
}
Assembly is done using the provided Assembler:
new PersistingSequencingAssembler().visibleIn( layer ).assemble( moduleAssembly );
Usage is quite simple:
@Service Sequencing sequencing;
public void doSomething()
{
sequencing.currentSequenceValue(); // return 0
sequencing.newSequenceValue(); // return 1
sequencing.currentSequenceValue(); // return 1
}