01: package com.xoetrope.service;
02:
03: /**
04: * An auto incrementing token/counter used to uniquely identify service requests
05: *
06: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
07: * the GNU Public License (GPL), please see license.txt for more details. If
08: * you make commercial use of this software you must purchase a commercial
09: * license from Xoetrope.</p>
10: * <p> $Revision: 1.4 $</p>
11: */
12: public class CallbackToken {
13: private static int nextToken;
14: private int token = -1;
15:
16: /**
17: * Creates a new token with the next token value.
18: */
19: public CallbackToken() {
20: token = ++nextToken;
21: }
22:
23: /**
24: * This method should only be invoked if the applicationis restarting and
25: * contains live requests from earlier sessions.
26: * @param t the new next token ID
27: */
28: static void setNextToken(int t) {
29: nextToken = t;
30: }
31:
32: /**
33: * Gets the token value
34: * @return an integer value greater than or equal to zero
35: */
36: public int getToken() {
37: return token;
38: }
39: }
|