package at.gv.egovernment.moa.spss.server.transaction; /** * A generator for unique transaction IDs. * *

The transaction IDs are of the form "-", where: *

*

* *

Assuming that it is highly unlikely that MOA servers are started at * exactly the same time instant, the mechanism provided by this class should * guarantee unique transaction IDs across multiple restarts and/or instances of * the server.

* * @author Patrick Peck * @author Stefan Knirsch */ public class TransactionIDGenerator { /** Request sequence number. */ private static long counter = 0; /** The base value to which to append the sequence number. */ private static String base = null; /** * Set up the initial base value. */ static { synchronized (TransactionIDGenerator.class) { base = Long.toString(System.currentTimeMillis()); } } /** * Returns the next transaction ID. * * @return The next transaction ID. */ public static synchronized String nextID() { counter++; return (base + "-" + counter); } }