|
Agent System POND 1.0 (1.7.2000) | ||||||||
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
Main class of the agent system.
Field Summary | |
static boolean |
DEBUG
Flag for debugging. |
static int |
MAX_DEFER_DELAY
Maximum allowed for delaying persisting or moving through request of the agent |
static int |
MIN_DEFER_DELAY
Minimum allowed for delaying persisting or moving through request of the agent |
static boolean |
SECURE_CONNECTION
If true, the connection to another agent-system will be cryptographically secure. |
protected PersonalSecurityStore |
securityStore
The security store of the owner of this agent system |
(package private) Vector |
servingThreads
List of all serving threads currently active. |
(package private) static int |
STD_PORT
The standard port of the agent system. |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY,
MIN_PRIORITY,
NORM_PRIORITY,
values |
Constructor Summary | |
|
AgentSystem(int port,
String libraryDir,
String agentDir,
boolean exitOnLast,
String savedFile)
Creates a new agent system with the security turned on. |
protected |
AgentSystem(int port,
String libraryDir,
String agentDir,
boolean exitOnLast,
String savedFile,
boolean useSecurity)
Creates a new agent system. |
|
AgentSystem(String libraryDir)
Creates a new agent system with the default value for the port and the users home directory as directory from where the agents are loaded. |
Method Summary | |
protected int |
agentCount()
Returns the number of agents in this system. |
protected boolean |
allowArrivalOfAgent(URL whereFrom,
AgentIdentity identity,
CertificateWrapper[] codeSigners,
String agentClass)
Checks whether this agent is allowed to arrive at this host. |
Permission |
buyPermission(AgentBase agent,
Permission perm,
double payment)
Allows the agent to buy a permission. |
PermissionCollection |
buyPermissionSet(AgentBase agent,
PermissionCollection perms,
double payment)
Allows the agent to buy a set of permissions. |
void |
cancel()
Method to stop the agent system gracefully. |
protected void |
challengeAgent(AgentData data)
Challenges the agent for the knowledge of its private key. |
protected boolean |
checkAdditionalClassification(AgentData agData,
AgentClassification classification)
Checks whether an additional classification is accepted. |
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 |
doTimerAction(long id)
Handles delayed requests. |
void |
dumpClassification(AgentBase agent)
Prints the classification information to System.out .
|
protected AgentData |
findAgentContext(AgentIdentity identity)
Get the management data of an agent from its identity. |
protected AgentData |
getAgentContext(AgentBase agent)
Get the management data of an agent from a supplied reference to it. |
protected String |
getAgentDirectory()
Returns the directory from where the agents are loaded. |
ClassificationSet |
getClassificationStatus(AgentBase agent)
Allows an agent to get information on his current status of additional classifications. |
protected String |
getLibraryDirectory()
Returns the directory where the shared libraries are located. |
URL |
getLocation()
Returns the URL of the local agent system. |
PermissionCollection |
getOptionalPermissions(AgentBase agent)
Returns a collection of all optional permissions. |
double |
getPrice(AgentBase agent,
Permission perm)
Return the price of a permission for an agent. |
URL |
getResource(AgentBase agent,
String name)
Finds the resource with the given name. |
InputStream |
getResourceAsStream(AgentBase agent,
String name)
Finds the resource with the given name and returns an input stream for reading it. |
Enumeration |
getResources(AgentBase agent,
String name)
Finds all the resources with the given name. |
double |
getSetPrice(AgentBase agent,
PermissionCollection perms)
Return the price of a set of permissions for an agent. |
(package private) void |
localBroadcastMessage(AgentBase sender,
BroadcastMessage msg)
Sends a message to all agents in the local system, except the sender and the persisted ones. |
protected void |
move(AgentBase agent,
URL destination)
Transfers an agent to another host. |
ClassificationSet |
offerAdditionalClassification(AgentBase agent,
ClassificationSet offer)
Allows an agent to offer additional classifications to receive more/cheaper permissions. |
protected void |
onAgentCreated(AgentData data)
Placeholder for updating the user interface after an agent was created. |
protected void |
onAgentDepersisted(AgentData data)
Placeholder for updating the user interface after an agent was depersisted. |
protected void |
onAgentDestroyed(AgentData data)
Placeholder for updating the user interface after an agent was destroyed. |
protected void |
onAgentPersisted(AgentData data)
Placeholder for updating the user interface after an agent was persisted. |
protected void |
onAgentReceived(AgentData data)
Placeholder for updating the user interface after an agent was received. |
protected String |
open(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. |
(package private) void |
receiveAgent(AgentData data)
Starts a received agent. |
protected void |
reportError(String msg)
Report an error to the user. |
void |
returnPermission(AgentBase agent,
Permission perm)
An agent can return a permission, indicating that he no longer needs it. |
void |
returnPermissionSet(AgentBase agent,
PermissionCollection perms)
An agent can return permissions, indicating that he no longer needs them. |
void |
run()
Main method of the system: Wait for incoming requests and handle them. |
protected String |
save(String password)
Saves the agent system with all contained agents to the default file. |
protected String |
saveAs(String filename,
String password)
Saves the agent system with all contained agents to a file. |
(package private) void |
sendMessage(AgentBase sender,
Message msg)
Sends a message to another agent. |
AgentBase |
startAgent(AgentBase requester,
String className,
boolean fromMyCodePackage,
AgentIdentity identity,
PrivateKey privateKey,
Object param)
For starting an agent by another agent. |
protected AgentBase |
startAgent(String className,
String codeOrigin,
boolean forceLocalCode,
AgentIdentity identity,
PrivateKey privateKey,
Object param,
boolean start)
For starting an agent by the system: there is no requester. |
protected void |
stopAgent(AgentBase agent,
boolean destroy)
Terminates a running agent. |
boolean |
terminate(long maxWaitToDie)
Method to stop the agent system. |
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 |
public static final boolean DEBUG
public static final boolean SECURE_CONNECTION
public static final int MIN_DEFER_DELAY
public static final int MAX_DEFER_DELAY
static final int STD_PORT
Vector servingThreads
protected PersonalSecurityStore securityStore
Constructor Detail |
public AgentSystem(String libraryDir)
libraryDir
- the directory where the common libraries are stored. Must be provided.public AgentSystem(int port, String libraryDir, String agentDir, 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 locatedexitOnLast
- 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 fileprotected AgentSystem(int port, String libraryDir, String agentDir, 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 locatedexitOnLast
- 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 |
public void run()
ServingThread
public void cancel()
public boolean terminate(long maxWaitToDie)
maxWaitToDie
- number of secods to wait befor forceful termination (0 = wait indefinitely)Thread
public URL getLocation()
URL
of the local agent system. Can be used to move agents to this one.protected String getAgentDirectory()
protected String getLibraryDirectory()
protected int agentCount()
void doTimerAction(long id)
id
- the id of the action to takeprotected void stopAgent(AgentBase agent, boolean destroy)
agent
- the agent to stopdestroy
- if the agent should be completely destroyed (false when persisting)protected void destroyPersistedAgent(AgentData data)
data
- the management data of the agent to destroyprotected void persist(AgentBase agent) throws NotSerializableException
PersistingDeniedException
.
In this implementation this works only once. If after the allotted time the agent denies being
persisted agein, it is terminated.agent
- the agent to persistAgentBase
,
PersistingDeniedException
protected void dePersist(AgentData data) throws CreateAgentFailureException
data
- the management data of the agent to depersistAgentBase
public AgentBase startAgent(AgentBase requester, String className, boolean fromMyCodePackage, AgentIdentity identity, PrivateKey privateKey, Object param) throws CreateAgentFailureException, InitializationException
requester
- the agent who wants to create another agentclassName
- name of the class of the agent to start (including all packages)fromMyCodePackage
- if true, the code will be loaded from the package of the requesting agent. Otherwise it will be searched for normallyidentity
- the identity of the new 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 agentprotected AgentBase startAgent(String className, String codeOrigin, boolean forceLocalCode, AgentIdentity identity, PrivateKey privateKey, Object param, boolean start) throws CreateAgentFailureException, InitializationException
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 "protected void move(AgentBase agent, URL destination) throws ReceiveAgentDeniedException, CannotSendException
agent
- the agent to movedestination
- URL
of the system the agent shall be moved tovoid receiveAgent(AgentData data) throws ReceiveAgentDeniedException
data
- management data of the agent to receivepublic URL getResource(AgentBase agent, String name)
agent
- the agent who wants a resourcename
- name of the resourceURL
to the resource or null if not foundpublic final Enumeration getResources(AgentBase agent, String name) throws IOException
agent
- the agent who wants a resourcename
- name of the resourceEnumeration
of the resources. If none found, the enumeration is emptypublic InputStream getResourceAsStream(AgentBase agent, String name)
agent
- the agent who wants a resourcename
- name of the resourceInputStream
for reading the resource or null if not foundprotected final AgentData getAgentContext(AgentBase agent) throws AgentNotRegisteredException
agent
- the reference to the agent, for which the data shall be returnedprotected final AgentData findAgentContext(AgentIdentity identity) throws AgentNotRegisteredException
identity
- the identity of the agent, for which the data shall be returnedprotected void onAgentCreated(AgentData data)
data
- the management data of the new agentprotected void onAgentReceived(AgentData data)
data
- the management data of the new agentprotected void onAgentPersisted(AgentData data)
data
- the management data of the now persisted agentprotected void onAgentDepersisted(AgentData data)
data
- the management data of the restored agentprotected void onAgentDestroyed(AgentData data)
data
- the management data of the removed agentfinal void sendMessage(AgentBase sender, Message msg) throws MessageException
sender
- the agent who wants to send the message. Must be the same as the sender that is contained in the message.msg
- the message to sendfinal void localBroadcastMessage(AgentBase sender, BroadcastMessage msg) throws MessageException
sender
- the agent who wants to send the message. Must be the same as the sender that is contained in the message.msg
- the message to sendprotected String save(String password) throws FileNotFoundException
password
- the password used for encrypting the fileprotected String saveAs(String filename, String password) throws FileNotFoundException
filename
- the name of the file to which the system is savedpassword
- the password used for encrypting the fileprotected String open(String filename, String password) throws FileNotFoundException
filename
- the name of the file from which the system is restoredpassword
- the password used for decrypting the fileprotected void reportError(String msg)
msg
- the error message to reportpublic double getPrice(AgentBase agent, Permission perm)
agent
- the agent who asks for the priceperm
- the permission the agent wantspublic double getSetPrice(AgentBase agent, PermissionCollection perms)
agent
- the agent who asks for the priceperms
- the permissions the agent wantspublic Permission buyPermission(AgentBase agent, Permission perm, double payment)
agent
- the agent who buys the permissionperm
- the permission the agent wantspayment
- the payment for the permission (must currently be exact the price of the permission)public PermissionCollection buyPermissionSet(AgentBase agent, PermissionCollection perms, double payment)
agent
- the agent who buys the permissionsperms
- the permissions the agent wantspayment
- the payment for the permission (must currently be exact the price of the set)public void returnPermission(AgentBase agent, Permission perm)
agent
- the agent returning the permissionperm
- the returned permissionpublic void returnPermissionSet(AgentBase agent, PermissionCollection perms)
agent
- the agent returning the set of permissionsperms
- the returned permissionspublic PermissionCollection getOptionalPermissions(AgentBase agent)
agent
- the inquiring agentprotected void challengeAgent(AgentData data)
data
- the management data of the agent to challengePolicyByValue
,
AgentBase.replyToChallenge(String,byte[])
protected boolean allowArrivalOfAgent(URL whereFrom, AgentIdentity identity, CertificateWrapper[] codeSigners, String agentClass)
whereForm
- from where the agent arrivesidentity
- the identity of the agentcodeSigners
- array of all certificates, who signed the codeagentClass
- name of the main class of the agentpublic ClassificationSet getClassificationStatus(AgentBase agent)
agent
- the agent which requests its statuspublic ClassificationSet offerAdditionalClassification(AgentBase agent, ClassificationSet offer)
agent
- the agent offering additional classificationsoffer
- the additional classificationsprotected boolean checkAdditionalClassification(AgentData agData, AgentClassification classification)
agData
- the management data of the agent requesting the checkclassification
- the classification to inspect and verifypublic void dumpClassification(AgentBase agent)
System.out
.
Used for testing purposes only.
To be removed for final version.agent
- the agent whose classification should be printed
|
Agent System POND 1.0 (1.7.2000) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |