fr.lifl.magique.platform
Class Platform

java.lang.Object
  extended byfr.lifl.magique.platform.Platform

public class Platform
extends java.lang.Object

A platform is used to gather and manage all the agents on a given host. Communications between remote agents is achieved using a communication layer between platform through RMI. When 2 remote agents try to communicate, the "connection" between their platform is automatically performed. Registry is automatically launched and port 4444 is the default registry port. Agent must be added to the platform using addAgent


Field Summary
static int DEFAULT_PORT
           
static java.lang.String PLATFORMMAGIQUEAGENTNAME
           
 
Constructor Summary
Platform()
          default port (4444) is used
Platform(int port)
           
Platform(java.lang.Integer port)
           
 
Method Summary
 void addAgent(AtomicAgent agent)
          the given agent is added to the platform
 void connect(java.lang.String platformName)
          perform a connection (via rmi) to the given platform
 Agent createAgent(java.lang.String agentName)
          dynamically creates a magique agent (class fr.lifl.magique.Agent).
 AtomicAgent createAgent(java.lang.String agentClassName, java.lang.String agentName)
          dynamically creates an agent from its class an name.
 AtomicAgent createAgent(java.lang.String agentClassName, java.lang.String agentName, java.lang.Object[] args)
          dynamically creates an agent from its class an name.
 void disconnectFrom(java.lang.String platformName)
          disconnects from a given plaform
 void disconnectFromAll()
          disconnect from all otherplatfroms this platform is connected to
 MessageList getMessages()
          returns my message list
 java.util.Hashtable getMyAgents()
          returns the hashtable of the agents active in the platform, it associates an agent name with the corresponding Agent object
 java.lang.String getName()
          returns the name of the platform (of the form hostIpAddredd:port)
 java.util.Hashtable getPlatformAgenda()
          returns the agenda of the platform, agenda associates a platform name name with the corresponding Communicate rmi interface implementation
 int getPort()
          returns the port of the server of the platform
 PlatformServer getServer()
          returns the RMI server asociated with this platform
 void haveAMessage(Message msg)
          used when a message is sent by anther platform
 java.lang.Boolean ping(java.lang.String platformName)
          test if the platform hostname is alive
 void removeAgent(java.lang.String agentName)
          given agent is removed from platform
 void sendMessage(java.lang.String to, Message msg)
           
 void stop()
          stops the platform by killing all agents located on it and stopping it.
 void treatMessage(PlatformMessage msg)
          given message is treated : send to the recipient agent if he belongs to this platform, or send (after connection if required) to the platform who contains the recipient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLATFORMMAGIQUEAGENTNAME

public static final java.lang.String PLATFORMMAGIQUEAGENTNAME
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values
Constructor Detail

Platform

public Platform()
default port (4444) is used


Platform

public Platform(int port)
Parameters:
port - the port for the server associated with this platform

Platform

public Platform(java.lang.Integer port)
Parameters:
port - the port for the server associated with this platform
Method Detail

getPlatformAgenda

public java.util.Hashtable getPlatformAgenda()
returns the agenda of the platform, agenda associates a platform name name with the corresponding Communicate rmi interface implementation

Returns:
the agenda of the platform,
See Also:
Communicate

getName

public java.lang.String getName()
returns the name of the platform (of the form hostIpAddredd:port)

Returns:
the name of the platform

getPort

public int getPort()
returns the port of the server of the platform

Returns:
the port of the server of the platform

getServer

public PlatformServer getServer()
returns the RMI server asociated with this platform

Returns:
the RMI server asociated with this platform

getMyAgents

public java.util.Hashtable getMyAgents()
returns the hashtable of the agents active in the platform, it associates an agent name with the corresponding Agent object

Returns:
the hashtable of the agents active in the platform
See Also:
Agent

getMessages

public MessageList getMessages()
returns my message list

Returns:
my message list

addAgent

public void addAgent(AtomicAgent agent)
              throws AlreadyExistingAgentException
the given agent is added to the platform

Parameters:
agent - the agent to be added
Throws:
AlreadyExistingAgentException

createAgent

public Agent createAgent(java.lang.String agentName)
                  throws AlreadyExistingAgentException
dynamically creates a magique agent (class fr.lifl.magique.Agent). Agent is added to the platform

Parameters:
agentName - the name of the created agent
Throws:
AlreadyExistingAgentException

createAgent

public AtomicAgent createAgent(java.lang.String agentClassName,
                               java.lang.String agentName)
                        throws AlreadyExistingAgentException
dynamically creates an agent from its class an name. Agent is added to the platform

Parameters:
agentClassName - the class of the to be created agent
agentName - the name of the crated agent
Throws:
AlreadyExistingAgentException

createAgent

public AtomicAgent createAgent(java.lang.String agentClassName,
                               java.lang.String agentName,
                               java.lang.Object[] args)
                        throws AlreadyExistingAgentException
dynamically creates an agent from its class an name. Agent is added to the platform

Parameters:
agentClassName - the class of the to be created agent
agentName - the name of the crated agent
args - the arguments for the constructor of the agent
Throws:
AlreadyExistingAgentException

removeAgent

public void removeAgent(java.lang.String agentName)
given agent is removed from platform

Parameters:
agentName - the name of the agent to be removed

treatMessage

public void treatMessage(PlatformMessage msg)
given message is treated : send to the recipient agent if he belongs to this platform, or send (after connection if required) to the platform who contains the recipient

Parameters:
msg - the msg to be treated

haveAMessage

public void haveAMessage(Message msg)
used when a message is sent by anther platform

Parameters:
msg - the sent message

sendMessage

public void sendMessage(java.lang.String to,
                        Message msg)

connect

public void connect(java.lang.String platformName)
perform a connection (via rmi) to the given platform

Parameters:
platformName - the platform to connect to

disconnectFromAll

public void disconnectFromAll()
disconnect from all otherplatfroms this platform is connected to


disconnectFrom

public void disconnectFrom(java.lang.String platformName)
disconnects from a given plaform

Parameters:
platformName - the platform to disconnect from

stop

public void stop()
stops the platform by killing all agents located on it and stopping it. Note : the rmiregistry is killed to.


ping

public java.lang.Boolean ping(java.lang.String platformName)
test if the platform hostname is alive

Parameters:
platformName - the platform to test
Returns:
Boolean.TRUE iff alive