public class AssignIdsTask extends ViewLifecycleTaskBase<LifecycleElement>
Constructor and Description |
---|
AssignIdsTask()
Create a task to assign component IDs during the initialize phase.
|
Modifier and Type | Method and Description |
---|---|
static String |
generateId(LifecycleElement element,
View view)
Generate a new ID for a lifecycle element at the current phase.
|
protected void |
performLifecycleTask()
Performs phase-specific lifecycle processing tasks.
|
getElementState, getElementType, run, setElementState, toString
public AssignIdsTask()
public static String generateId(LifecycleElement element, View view)
This method used a product of primes similar to the one used for generating String hash codes. In order to minimize to collisions a large prime is used, then when collisions are detected a different large prime is used to generate an alternate ID.
The hash code that the generated ID is based on is equivalent (though not identical) to taking the hash code of the string concenation of all class names, non-null IDs, and successor index positions in the lifecycle phase tree for all predecessors of the current phase. This technique leads to a reliably unique ID that is also repeatable across server instances and test runs.
The use of large primes by this method minimizes collisions, and therefore reduces the likelihood of a race condition causing components to come out with different IDs on different server instances and/or test runs.
element
- The lifecycle element for which to generate an ID.view
- View containing the lifecycle element.ViewIndex.observeAssignedId(String)
,
for the algorithm this method is based on.
protected void performLifecycleTask()
performLifecycleTask
in class ViewLifecycleTaskBase<LifecycleElement>
Copyright © 2005–2014 The Kuali Foundation. All rights reserved.