Changeset 797 for trunk/grails-app/domain
- Timestamp:
- Aug 10, 2010, 5:11:22 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Identity.groovy
r794 r797 52 52 /** 53 53 * Class constructor increments that static iterator 54 * and sets the object's identifier (used in dynamic webforms) 54 * and sets the object's identifier 55 * @visibility public 55 56 * @void 56 57 */ 57 58 public Identity() { 58 // does this instance have an identifier? 59 if (!identifier) { 60 // no, increment the iterator 61 incrementIterator() 62 } 59 // set the local identifier 60 setIdentifier() 63 61 64 println ".instantiating [" + super.getClass() + "] ("+ identifier + ")" 62 // feedback 63 println "instantiating [${identifier}:${super.getClass()}]" 65 64 } 66 65 67 // This method is synchronized to assure a thread-safe increment of the iterator variable 68 synchronized private void incrementIterator() { 69 // Increment the iterator variable 70 identifier = iterator++ 66 /** 67 * Method to increment the static iterator variable. This method 68 * is synchronized to assure a thread-safe increment. 69 * @visibility private 70 * @void 71 */ 72 synchronized final private void setIdentifier() { 73 // increment the iterator variable 74 // reset iterator to 1 if it is becoming too high 75 iterator = (iterator >= maximumIdentity) ? 1 : iterator+1 71 76 72 // has the iterator become too large? 73 if (iterator >= maximumIdentity) { 74 // yes, reset it back to 0 as this iterator 75 // works for the complete application, not 76 // only the user session. We don't want it 77 // to go too high :) 78 iterator = 0 79 } 80 77 // set the instance identifier 78 identifier = iterator 81 79 } 82 80 83 81 /** 84 82 * Return the identifier 83 * @visibility public 85 84 * @return int 86 85 */
Note: See TracChangeset
for help on using the changeset viewer.