Package fr.dyade.aaa.agent
Class AgentIdStamp
- java.lang.Object
-
- fr.dyade.aaa.agent.AgentIdStamp
-
- All Implemented Interfaces:
Serializable
final class AgentIdStamp extends Object implements Serializable
AgentIdStampclass defines static members, variable and functions, to manage the allocation of new identifiers. It locally maintains a pair of counters, one for local agent server, one for remote agent server, keeping track of the last allocated stamp for the given target domain. Stamps are allocated in growing order and are never reused once allocated, even after agents are deleted.
Some initial stamps are reserved for statically identifying system and well known services as factory. They are defined inAgentIdclass.
-
-
Field Summary
Fields Modifier and Type Field Description private intlocalStamp counter for local agent server.private intremoteStamp counter for remote agent server.private static longserialVersionUIDDefine serialVersionUID for interoperability.(package private) static AgentIdStampstampStatic reference to localAgentIdStampobject.
-
Constructor Summary
Constructors Constructor Description AgentIdStamp()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static voidinit()InitializesAgentIdStampclass.(package private) static AgentIdStampload()Restores the object state from the persistent storage.(package private) intnewStamp(short to)Allocates a new stamp for the target agent server.private voidreadObject(ObjectInputStream in)ThereadObjectis responsible for reading from the stream and restoring the classes fields.(package private) voidsave()Saves the object state on persistent storage.private voidwriteObject(ObjectOutputStream out)ThewriteObjectmethod is responsible for writing the state of the object for its particular class so that the correspondingreadObjectmethod can restore it.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Define serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
stamp
static AgentIdStamp stamp
Static reference to localAgentIdStampobject.
-
local
private int local
Stamp counter for local agent server.
-
remote
private int remote
Stamp counter for remote agent server.
-
-
Method Detail
-
init
static void init() throws IOException, ClassNotFoundExceptionInitializesAgentIdStampclass.- Throws:
IOException- IO problem during loading.ClassNotFoundException- should never happened
-
save
void save() throws IOException
Saves the object state on persistent storage.- Throws:
IOException- an error occurs.
-
load
static AgentIdStamp load() throws IOException, ClassNotFoundException
Restores the object state from the persistent storage.- Returns:
- the loaded AgentIdStamp object.
- Throws:
IOException- an error occurs.ClassNotFoundException- an error occurs.
-
writeObject
private void writeObject(ObjectOutputStream out) throws IOException
ThewriteObjectmethod is responsible for writing the state of the object for its particular class so that the correspondingreadObjectmethod can restore it.- Parameters:
out- the underlying output stream.- Throws:
IOException- an error occurs.
-
readObject
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
ThereadObjectis responsible for reading from the stream and restoring the classes fields.- Parameters:
in- the underlying input stream.- Throws:
IOException- an error occurs.ClassNotFoundException- an error occurs.
-
newStamp
int newStamp(short to) throws IOExceptionAllocates a new stamp for the target agent server.- Parameters:
to- The target agent server- Returns:
- the new allocated stamp.
- Throws:
IOException- an error occurs.
-
-