com.ezic.direct
Class IdGenerator
java.lang.Object
|
+--com.ezic.net.NetworkClient
|
+--com.ezic.direct.IdGenerator
- public class IdGenerator
- extends NetworkClient
This class allows you to obtain unique ID numbers from the servers.
It's recomended that you obtain a transaction ID prior to submitting the
transaction for processing. This will allow you to later determine what
happened to the transaction, even if you encounter a network error
while waiting for the transaction response.
|
Constructor Summary |
IdGenerator()
Create a new instance object of this class. |
|
Method Summary |
java.lang.String |
obtainNewId()
Returns 1 new unique ID. |
protected int |
obtainNewIds(java.lang.String[] out,
int num)
Obtain one or more unique ID number from the server. |
void |
setPerformanceMode(boolean yes)
When using performance mode, a separate thread will be spawned. |
void |
setTimeout_ms(int milli_seconds)
Set the network timeout for calls to obtainNewIds() in milli seconds. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IdGenerator
public IdGenerator()
- Create a new instance object of this class.
One object can safely be shared by multiple threads, provided
you make sure setServer(), setProtocol() and setPerformanceMode()
are not called while any other threads are using the object.
Normally you only call those methods once, or not at all.
- See Also:
NetworkClient.setProtocol(java.lang.String),
NetworkClient.setServer(java.lang.String),
setPerformanceMode(boolean)
setTimeout_ms
public void setTimeout_ms(int milli_seconds)
- Set the network timeout for calls to obtainNewIds() in milli seconds.
The default is 25000 (25 seconds).
setPerformanceMode
public void setPerformanceMode(boolean yes)
- When using performance mode, a separate thread will be spawned.
This thread will keep a pool of pre-allocated IDs ready, so that
calls to obtainNewId() can be completed instantly.
The size of the pool will be dynamically adjusted to match your
usage rate.
NOTE: When using performance mode, you should only have 1 instance
of this class, or you will end up with one background thread for
each object instance.
- See Also:
obtainNewId()
obtainNewIds
protected int obtainNewIds(java.lang.String[] out,
int num)
throws IdGenerator.IdGeneratorException
- Obtain one or more unique ID number from the server.
obtainNewId
public java.lang.String obtainNewId()
throws IdGenerator.IdGeneratorException
- Returns 1 new unique ID.
The ID is either obtained from the server, or from the local pool of pre-allocated IDs.
This call is thread safe.
This is propriatary and confidential unpublished information. Copyright(c) 1999-2008, All rights reserved.