|
Agent System POND 1.2 (28.2.2002) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--FIM.Util.Threads.CancellableThread | +--PkgAgentSystem.AgentSystem | +--PkgAgentSystem.GUI.GUIAgentSystem
Base class for agent systems with a graphical user interface. To be used with class MainFrame
.
Can be used as stand-alone:
java PkgAgentSystem.GUI.GUIAgentSystem agentDir libraryDir [Port [savedFile]]
Field Summary | |
protected MainFrame |
mainframe
The main window of the system |
Fields inherited from class PkgAgentSystem.AgentSystem |
DEBUG, HAND_OFF, MAX_DEFER_DELAY, MIN_DEFER_DELAY, priceCurrency, SECURE_CONNECTION, securityStore, servingThreads, STD_PORT |
Fields inherited from class java.lang.Thread |
inheritableThreadLocals, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, threadLocals |
Constructor Summary | |
GUIAgentSystem(int port,
String libraryDir,
String agentDir,
String systemDir,
boolean exitOnLast,
String savedFile)
Creates a new GUI agent system with the security turned on. |
|
GUIAgentSystem(int port,
String libraryDir,
String agentDir,
String systemDir,
boolean exitOnLast,
String savedFile,
boolean useSecurity)
Creates a new GUI agent system and shows the main window. |
Method Summary | |
(package private) void |
addKeyPair(NamedKeyPair nkp)
Adds a general key pair to the security store. |
(package private) void |
addTrustedCertificate(String name,
Certificate cert)
Adds a trusted certificate to the security store. |
(package private) boolean |
agentsExist()
Returns whether there is at least one agent (either active or persisted) in this system. |
protected void |
dePersist(AgentData data)
Restores a persisted agent to the running state. |
protected void |
destroyPersistedAgent(AgentData data)
Terminates a currently persisted agent. |
(package private) void |
doCreateAgent()
Create a new agent. |
protected void |
doMoveAgent(AgentBase agent,
URL destination)
Transfers an agent to another host. |
(package private) boolean |
existsTrustedCertificateName(String name)
Checks whether a trusted certificate with this name already exists. |
protected void |
flushSecurityStore()
|
protected String |
getAgentDirectory()
Returns the directory from where the agents are loaded. |
protected String |
getSystemDirectory()
Returns the directory where the agentsystem is located. |
static void |
main(String[] args)
This class can also be used directly to show a GUI agent system: java PkgAgentSystem.GUI.GUIAgentSystem agentDir libraryDir [Port [savedFile]] |
protected void |
move(AgentBase agent,
URL destination)
Helper function for transfering an agent. |
protected void |
onAgentCreated(AgentData data)
Notify the mainframefor updating the user interface after an agent was created. |
protected void |
onAgentDepersisted(AgentData data)
Notify the mainframe for updating the user interface after an agent was depersisted. |
protected void |
onAgentDestroyed(AgentData data)
Notify the mainframe for updating the user interface after an agent was destroyed. |
protected void |
onAgentPersisted(AgentData data)
Notify the mainframe for updating the user interface after an agent was persisted. |
protected void |
onAgentReceived(AgentData data)
Notify the mainframe for updating the user interface after an agent was received. |
(package private) String |
openFile(String filename,
String password)
Reades the agent system with all contained agents from a file. |
protected void |
persist(AgentBase agent)
Persists an agent to the disk. |
protected void |
reportError(String msg)
Report an error to the user. |
(package private) String |
saveFile(String password)
Saves the agent system with all contained agents to the default file. |
(package private) String |
saveFileAs(String filename,
String password)
Saves the agent system with all contained agents to a file. |
protected AgentBase |
startAgent(String className,
String codeOrigin,
boolean forceLocalCode,
AgentIdentity identity,
PrivateKey privateKey,
Object param,
boolean start)
For starting an agent by the system. |
protected void |
stopAgent(AgentBase agent,
boolean destroyed)
Terminates a running agent. |
Methods inherited from class FIM.Util.Threads.CancellableThread |
isCancelled |
Methods inherited from class java.lang.Thread |
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected MainFrame mainframe
Constructor Detail |
public GUIAgentSystem(int port, String libraryDir, String agentDir, String systemDir, boolean exitOnLast, String savedFile)
port
- the port the system will listen on (must be >1024 or -1)libraryDir
- the directory, where the common libraries are from; All agents will load classes
first from there and only after not finding them there from their local path/package. Must be provided.agentDir
- the directory, where the AGENTS are from, NOT where the JDK or the agent system is locatedsytemDir
- the directory, where the system is located; the keystores are located there as well as logfiles and payment-files, etc.exitOnLast
- if true the system will terminate after the last agent is destroyed (may start empty however)savedFile
- if not null, the agentsystem will load the state from this filepublic GUIAgentSystem(int port, String libraryDir, String agentDir, String systemDir, boolean exitOnLast, String savedFile, boolean useSecurity)
port
- the port the system will listen on (must be >1024 or -1)libraryDir
- the directory, where the common libraries are from; All agents will load classes
first from there and only after not finding them there from their local path/package. Must be provided.agentDir
- the directory, where the AGENTS are from, NOT where the JDK or the agent system is locatedsytemDir
- the directory, where the system is located; the keystores are located there as well as logfiles and payment-files, etc.exitOnLast
- if true the system will terminate after the last agent is destroyed (may start empty however)savedFile
- if not null, the agentsystem will load the state from this fileuseSecurity
- false if no security system is wantedMethod Detail |
protected void onAgentCreated(AgentData data)
onAgentCreated
in class AgentSystem
data
- the management data of the new agentprotected void onAgentReceived(AgentData data)
onAgentReceived
in class AgentSystem
data
- the management data of the new agentprotected void onAgentPersisted(AgentData data)
onAgentPersisted
in class AgentSystem
data
- the management data of the now persisted agentprotected void onAgentDepersisted(AgentData data)
onAgentDepersisted
in class AgentSystem
data
- the management data of the restored agentprotected void onAgentDestroyed(AgentData data)
onAgentDestroyed
in class AgentSystem
data
- the management data of the removed agentprotected void stopAgent(AgentBase agent, boolean destroyed)
Mainframe
can access it.stopAgent
in class AgentSystem
agent
- the agent to stopdestroy
- if the agent should be completely destroyed (false when persisting)protected void destroyPersistedAgent(AgentData data)
Mainframe
can access it.destroyPersistedAgent
in class AgentSystem
data
- the management data of the agent to destroyprotected void persist(AgentBase agent) throws NotSerializableException
Mainframe
can access it.persist
in class AgentSystem
agent
- the agent to persistNotSerializableException
- if the agent cannot be serializedAgentBase
,
PersistingDeniedException
protected void dePersist(AgentData data) throws CreateAgentFailureException
Mainframe
can access it.dePersist
in class AgentSystem
data
- the management data of the agent to depersistCreateAgentFailureException
- if an error occured when starting the agent (class not found or stream error during reading)AgentBase
protected void move(AgentBase agent, URL destination) throws ReceiveAgentDeniedException, CannotSendException
move
in class AgentSystem
agent
- the agent to movedestination
- URL
of the system the agent shall be moved toReceiveAgentDeniedException
- if the other host denies to receive the agent (problem on remote host)CannotSendException
- if an error occured during sending (problem on this host)protected void doMoveAgent(AgentBase agent, URL destination) throws ReceiveAgentDeniedException, CannotSendException
Mainframe
can access it.agent
- the agent to movedestination
- URL
of the system the agent shall be moved toReceiveAgentDeniedException
- if the other host denies to receive the agent (problem on remote host)CannotSendException
- if an error occured during sending (problem on this host)protected AgentBase startAgent(String className, String codeOrigin, boolean forceLocalCode, AgentIdentity identity, PrivateKey privateKey, Object param, boolean start) throws CreateAgentFailureException, InitializationException
doCreateAgent
)startAgent
in class AgentSystem
className
- name of the class of the agent to start (including all packages)codeOrigin
- file or directory where from where the code should be loaded. If null, searches for it in the agent-directory.forceLocalCode
- if true, the code will be marked as from the local host, even if it is notidentity
- the identity of the agentprivateKey
- the private key of the agent (might be null if identity has no public key or just not provided)param
- the parameter passed to the method initialize, which is called after starting the agentstart
- true if the agent should be started (if false, it can be started later with "CreateAgentFailureException
- if any exception or error happens while creating thre agentInitializationException
- if an error occured during initializationvoid doCreateAgent()
Mainframe
.CreateAgentDialog
,
SelectIdentityDialog
protected String getAgentDirectory()
Mainframe
can access it.getAgentDirectory
in class AgentSystem
protected String getSystemDirectory()
Mainframe
can access it.getSystemDirectory
in class AgentSystem
boolean agentsExist()
true
if at least one agent existsString saveFileAs(String filename, String password) throws FileNotFoundException
Mainframe
can access it.filename
- the name of the file to which the system is savedpassword
- the password used for encrypting the fileFileNotFoundException
- if the file could not be written toString saveFile(String password) throws FileNotFoundException
Mainframe
can access it.password
- the password used for encrypting the fileFileNotFoundException
- if the file could not be written toString openFile(String filename, String password) throws FileNotFoundException
Mainframe
can access it.filename
- the name of the file from which the system is restoredpassword
- the password used for decrypting the fileFileNotFoundException
- if the file could not be foundboolean existsTrustedCertificateName(String name) throws KeyStoreException
name
- the name under which the trusted certificate should be storedtrue
if this name already exists as an trusted certificateKeyStoreException
- if an error occured during checking the namevoid addTrustedCertificate(String name, Certificate cert) throws KeyStoreException
name
- the name under which the trusted certificate should be storedcert
- the trusted certificateKeyStoreException
- if an error occured during storing the certificatevoid addKeyPair(NamedKeyPair nkp) throws KeyStoreException
nkp
- the named pair of keys to be storedKeyStoreException
- if an error occured during storing the keysprotected void reportError(String msg)
super.reportError(msg)
.reportError
in class AgentSystem
msg
- the error message to reportprotected void flushSecurityStore()
public static void main(String[] args)
java PkgAgentSystem.GUI.GUIAgentSystem agentDir libraryDir [Port [savedFile]]
|
Agent System POND 1.2 (28.2.2002) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |