public abstract class TransactionSession
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.util.Map<java.lang.String,TransactionSession> |
allSessions
A map of all active sessions.
|
private boolean |
completed
Has this session been completed?
|
private static java.util.logging.Logger |
logger |
Modifier | Constructor and Description |
---|---|
protected |
TransactionSession(java.lang.String key)
Protected constructor, we only really instantiate specific types
of transactions.
|
Modifier and Type | Method and Description |
---|---|
static void |
clearAll()
Clear all transactions.
|
void |
complete(ChangeSet cs)
All transaction types must implement a completion action.
|
static void |
completeAll(ChangeSet cs)
Complete all transactions.
|
static <T extends TransactionSession> |
lookup(java.lang.Class<T> type,
FreeColGameObject o1,
FreeColGameObject o2)
Look up a session of specified type given the game objects involved.
|
static <T extends TransactionSession> |
lookup(java.lang.Class<T> type,
java.lang.String s1,
java.lang.String s2)
Look up a session of specified type given the IDs of the game objects
involved.
|
protected static java.lang.String |
makeSessionKey(java.lang.Class type,
FreeColGameObject o1,
FreeColGameObject o2)
Make a transaction session key given two game objects.
|
protected static java.lang.String |
makeSessionKey(java.lang.Class type,
java.lang.String o1,
java.lang.String o2)
Make a transaction session key.
|
private static final java.util.logging.Logger logger
protected static final java.util.Map<java.lang.String,TransactionSession> allSessions
private boolean completed
protected TransactionSession(java.lang.String key)
key
- A unique key to lookup this transaction with.public void complete(ChangeSet cs)
cs
- A ChangeSet
to update with changes that
occur when completing this session.protected static java.lang.String makeSessionKey(java.lang.Class type, java.lang.String o1, java.lang.String o2)
type
- An identifier for the type of transaction.o1
- A string to uniquely identify the transaction.o2
- Another string to uniquely identify the transaction.protected static java.lang.String makeSessionKey(java.lang.Class type, FreeColGameObject o1, FreeColGameObject o2)
type
- An identifier for the type of transaction.o1
- A FreeColGameObject
involved in the session.o2
- Another FreeColGameObject
involved in the session.public static void completeAll(ChangeSet cs)
cs
- A ChangeSet
to update.public static void clearAll()
public static <T extends TransactionSession> T lookup(java.lang.Class<T> type, FreeColGameObject o1, FreeColGameObject o2)
type
- The class of session.o1
- The first FreeColGameObject
in the session.o2
- The second FreeColGameObject
in the session.public static <T extends TransactionSession> T lookup(java.lang.Class<T> type, java.lang.String s1, java.lang.String s2)
type
- The class of session.s1
- The identifier of the first object in the session.s2
- The identifier of the second object in the session.