Default key generator
The default key generator provides a convenient way to generate random, numeric values that can be used as primary keys.
The following OSGi service interface represents the specification of a key generator, (aka, ID Factory): com.dwl.base.IDWLIDFactory.
The default published service blueprint definition is as follows:
<service id="IDFactory" interface="com.ibm.mdm.common.servicefactory.api.CommonServiceFactory">
<service-properties>
<entry key="common.service" value="IDFactory"/>
</service-properties>
<bean class="com.ibm.mdm.common.servicefactory.CommonServiceFactoryImpl">
<argument type="java.lang.Class" value="com.dwl.base.IDWLIDFactory"/>
<argument type="java.lang.Class" value="com.dwl.base.util.DWLIDFactory" />
<argument ref="blueprintBundle"/>
</bean>
</service>
The default generator generates numeric keys
in the format that is specified in the /IBM/DWLCommonServices/KeyGeneration/defaultFormat
configuration. This configuration can hold a concatenated string of
the predefined indicators along with their desired length. These indicators
are:- I: Indicates the Instance PK Identifier as configured in the /IBM/DWLCommonServices/KeyGeneration/instancePKIdentifier configuration item.
- T: Indicates the Timestamp in milliseconds.
- S: Indicates the Service Identifier, a number that stays the same for a single service.
- R: Indicates the Record Identifier, a number that is generated randomly when a new record is being added to the database.
This format string may also be optionally prefixed with one of
the following characters:
- B: Indicates that the desired digit length is the number bits in binary format. By default, the digit length indicates the length in decimal format.
- V: Indicate that key generator can generate keys that of variable length.
Examples:
- BV/S8T40R9I6 results in generating a 63-bit
variable-length Ids in this format:
- [8-bits random number per service call] [40-bits Timestamp] [9-bits random number] [6-bits Instance number]
- B/S8T40R9I6 results in generating a 63-bit
fixed-length Ids in this format:
- [8-bits random number per service call] [40-bits Timestamp] [9-bits random number] [6-bits Instance number]
- V/R4T12I2 results in generating a 18-digit
(max) variable-length Ids in this format:
- [4 digit random number][12 digit timestamp][2 digit Instance number]
- R4T12I2 results in generating a 18-digit
fixed-length Ids in this format:
- [4 digit random number][12 digit timestamp][2 digit Instance number]