|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.kaariboga.core.KaaribogaBase
A class to host mobile agents called kaaribogas. It is able to dispatch and receive kaaribogas, handle their requests and messages.
Inner Class Summary | |
(package private) class |
KaaribogaBase.ListenThread
Listens on the specified port and spawns new threads to receive incoming agents. |
(package private) class |
KaaribogaBase.ReceiveMessageThread
Handles a messages incoming through a socket connection. |
protected class |
KaaribogaBase.SendMessageThread
Sends a KaaribogaMessage to another base. |
Field Summary | |
private KaaribogaAddress |
baseAddress
The KaaribogaAddress of this base |
private java.util.Vector |
baseListeners
Classes that listen to the fired base events. |
private KaaribogaAddress |
boServer
Base online server that registers all servers in this domain. |
(package private) java.util.Hashtable |
boxes
Stores all agents and related information. |
protected ClassManager |
classManager
Handles classes and their byte codes. |
private long |
counter
Used to generate a unique name for a kaariboga. |
(package private) long |
delay
Delay time in milliseconds after which an anused agent class is removed from memory. |
private KaaribogaAddress |
ipServer
Server that serves dynamic IP addresses |
private boolean |
isOnline
Is this server on- or offline? |
private KaaribogaBase.ListenThread |
listenThread
Thread that accepts network connections. |
private java.util.HashMap |
messageHandlers
Message handlers that have registered on this base to handle certain kinds of messages. |
private java.lang.Object |
parent
The object that created this base. |
private int |
port
The port number on which the server listens. |
(package private) java.net.ServerSocket |
serverSocket
Listens on the main port. |
private java.util.HashMap |
services
The base can be extended by services, that are provided by plug-ins. |
int |
version
Not used. |
Constructor Summary | |
KaaribogaBase(java.lang.Object parent,
ClassManager clManager)
Creats a new Kaariboga Base. |
Method Summary | |
void |
addBaseListener(BaseListener l)
Adds a base event listener. |
void |
addKaaribogaOnArrival(Kaariboga kaariboga,
java.net.InetAddress sender)
Adds a kaariboga to the base and starts it's thread. |
void |
addKaaribogaOnCreation(Kaariboga kaariboga,
java.net.InetAddress sender)
Adds a kaariboga to the base, performs some initialisation and starts it's thread. |
boolean |
addMessageHandler(KbMessageHandler handler,
java.lang.String kind)
Adds a message handler for a specified kind of message to this base. |
boolean |
addService(KbPlugIn plugIn,
java.lang.String name)
Adds a service to this base. |
void |
destroyKaariboga(java.lang.Object sender,
java.lang.String name)
Destroys a kaariboga agent with all necessary clean up. |
protected void |
dispatch(Kaariboga kaariboga,
KaaribogaAddress address)
Dispatches a kaariboga to another base. |
void |
dispatchKaariboga(java.lang.Object sender,
java.lang.String name,
KaaribogaAddress destination)
Dispatches a kaariboga agent with all necessary clean up. |
void |
dispose()
Shuts down the network connection. |
protected void |
fireKaaribogaArrived(java.lang.String name)
Fires an event if a new kaariboga has arrived. |
protected void |
fireKaaribogaCreated(java.lang.String name)
Fires an event if a new kaariboga was created. |
protected void |
fireKaaribogaDestroyed(java.lang.String name)
Fires an event if a kaariboga has been destroyed. |
protected void |
fireKaaribogaLeft(java.lang.String name)
Fires an event if a kaariboga was dispatched to another base. |
java.lang.String |
generateName()
Generates a unique name that can be used to initialize agents. |
KaaribogaAddress |
getBaseAddress(java.lang.Object sender)
Returns the KaaribogaAddress of this base. |
java.util.Enumeration |
getKaaribogaNames(java.lang.Object sender)
Gets the names of all kaariboga agents on this base. |
boolean |
getOnlineStatus()
Determines if the server is online. |
java.lang.String[] |
getServiceNames(java.lang.Object sender)
Returns the names of all the services currently available. |
java.lang.Object |
getServiceObject(java.lang.Object sender,
java.lang.String name)
Returns a service object for a specified service name. |
void |
goOffline(java.lang.Object sender)
Performs all neccessary actions to go offline |
void |
goOnline(java.lang.Object sender,
int portNo,
KaaribogaAddress boServer,
KaaribogaAddress ipServer)
Performs all neccessary actions to go online |
void |
goOnlineForDynamicIP(java.lang.Object sender)
If the server has no static IP address this method is called to determine the dynamic IP address. |
void |
handleMessage(KaaribogaMessage msg)
Handles incoming messages from other bases and kaaribogas. |
void |
kaaribogaDestroyRequest(KaaribogaEvent e)
Handles the destroy request of a kaariboga. |
void |
kaaribogaDispatchRequest(KaaribogaEvent e)
Handles the dispatch request of a kaariboga. |
void |
kaaribogaMessage(KaaribogaMessageEvent e)
Handles messages that are fired by kaaribogas. |
void |
kaaribogaSleepRequest(KaaribogaEvent e)
Handles the sleep request of a kaariboga. |
void |
removeBaseListener(BaseListener l)
Removes a base event listener. |
boolean |
removeMessageHandler(KbMessageHandler handler,
java.lang.String kind)
Removes a message handler for a specified kind of message to this base. |
boolean |
removeService(KbPlugIn plugIn,
java.lang.String name)
Removes the service named name from this base. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public final int version
private boolean isOnline
private java.lang.Object parent
private java.util.HashMap messageHandlers
private java.util.HashMap services
private KaaribogaAddress boServer
private KaaribogaAddress ipServer
private java.util.Vector baseListeners
long delay
private int port
private KaaribogaAddress baseAddress
private long counter
private volatile KaaribogaBase.ListenThread listenThread
protected ClassManager classManager
java.util.Hashtable boxes
java.net.ServerSocket serverSocket
Constructor Detail |
public KaaribogaBase(java.lang.Object parent, ClassManager clManager)
clManager
- The ClassManager to use.Method Detail |
public void handleMessage(KaaribogaMessage msg)
protected void dispatch(Kaariboga kaariboga, KaaribogaAddress address)
kaariboga
- The agent that has to be dispatched.address
- Address of the destination.public void dispose()
public void addKaaribogaOnArrival(Kaariboga kaariboga, java.net.InetAddress sender)
public void addKaaribogaOnCreation(Kaariboga kaariboga, java.net.InetAddress sender)
public void kaaribogaDispatchRequest(KaaribogaEvent e)
kaaribogaDispatchRequest
in interface KaaribogaListener
public void kaaribogaSleepRequest(KaaribogaEvent e)
kaaribogaSleepRequest
in interface KaaribogaListener
public void kaaribogaDestroyRequest(KaaribogaEvent e)
kaaribogaDestroyRequest
in interface KaaribogaListener
public java.util.Enumeration getKaaribogaNames(java.lang.Object sender)
sender
- The object that sends the request.public java.lang.String generateName()
public KaaribogaAddress getBaseAddress(java.lang.Object sender)
sender
- The object that requests the address.public void goOnlineForDynamicIP(java.lang.Object sender) throws java.net.UnknownHostException, java.io.IOException, java.lang.InterruptedException
sender
- The object that calls this methodpublic void goOnline(java.lang.Object sender, int portNo, KaaribogaAddress boServer, KaaribogaAddress ipServer)
sender
- The object that calls this method.
Only the parent of this class may call this method,
agents are not allowed to do this.portNo
- The port on which the server should listenboServer
- The domain server, if there is one. May be null.ipServer
- The server that determines this host's IP address
if dynamic IP addresses are usedpublic void goOffline(java.lang.Object sender)
sender
- The object that calls this method.
Only the parent of this class may call this method,
agents are not allowed to do this.
XXX This method performs no check for the threads that are still runningpublic boolean getOnlineStatus()
public void destroyKaariboga(java.lang.Object sender, java.lang.String name)
sender
- Object that calls this method.name
- Name of the kaariboga agent.public void dispatchKaariboga(java.lang.Object sender, java.lang.String name, KaaribogaAddress destination)
sender
- Object that calls this method.name
- Name of the kaariboga agent.destination
- Where to send the kaariboga.public void addBaseListener(BaseListener l)
public void removeBaseListener(BaseListener l)
protected void fireKaaribogaCreated(java.lang.String name)
name
- Name of the kaariboga agent.protected void fireKaaribogaArrived(java.lang.String name)
name
- Name of the kaariboga agent.protected void fireKaaribogaDestroyed(java.lang.String name)
name
- Name of the kaariboga agent.protected void fireKaaribogaLeft(java.lang.String name)
name
- Name of the kaariboga agent.public void kaaribogaMessage(KaaribogaMessageEvent e)
kaaribogaMessage
in interface KaaribogaMessageListener
public boolean addMessageHandler(KbMessageHandler handler, java.lang.String kind)
handler
- The message handler, that wants to receive the specified kind of messagekind
- The kind of message, that should be delivered to the message handlerKaaribogaMessage
public boolean removeMessageHandler(KbMessageHandler handler, java.lang.String kind)
handler
- The message handler, that wants to receive the specified kind of messagekind
- The kind of message, that should be delivered to the message handlerKaaribogaMessage
public boolean addService(KbPlugIn plugIn, java.lang.String name)
plugIn
- The plugIn that provides the servicename
- Name of the servicepublic boolean removeService(KbPlugIn plugIn, java.lang.String name)
plugIn
- The plugIn that provides the servicename
- Name of the servicepublic java.lang.String[] getServiceNames(java.lang.Object sender)
sender
- The object that calls this method.public java.lang.Object getServiceObject(java.lang.Object sender, java.lang.String name)
sender
- The object that calls this method.name
- Name of the requested service
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |