Class AssignIdsTask
- All Implemented Interfaces:
Runnable,ViewLifecycleTask<LifecycleElement>
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a task to assign component IDs during the initialize phase. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgenerateId(LifecycleElement element, View view) Generate a new ID for a lifecycle element at the current phase.protected voidPerforms phase-specific lifecycle processing tasks.Methods inherited from class org.kuali.rice.krad.uif.lifecycle.ViewLifecycleTaskBase
getElementState, getElementType, run, setElementState, toString
-
Constructor Details
-
AssignIdsTask
public AssignIdsTask()Create a task to assign component IDs during the initialize phase.
-
-
Method Details
-
generateId
Generate a new ID for a lifecycle element at the current phase.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.
- Parameters:
element- The lifecycle element for which to generate an ID.view- View containing the lifecycle element.- Returns:
- An ID, unique within the current view, for the given element.
- See Also:
-
performLifecycleTask
protected void performLifecycleTask()Performs phase-specific lifecycle processing tasks.- Specified by:
performLifecycleTaskin classViewLifecycleTaskBase<LifecycleElement>
-