structures
Interface DBInterface

All Known Implementing Classes:
DBImplementation

public abstract interface DBInterface

Defines the methods that allow the agents to manipulate the roots, the groups and establish associations between roots and groups (to control which groups will read or write an specific root) stored in a database. The methods defined in this interface can be classified in three groups:


Method Summary
 void associate(String threadName, String groupName, String agentName)
          Associates a thread with an agent and its group.
 void createGroup(String groupName, long time)
          Creates a new group and specifies the lifetime of the agents that will belong to the group.
 void createRoot(String rootName)
          Creates an empty root in the database.
 void deleteGroup(String groupName)
          Deletes an existing group.
 void deleteRoot(String rootName)
          Deletes an existing group of the database.
 Object get(String rootName)
          Gets a root content.
 String getAgentName(String threadName)
          Gets the name of the agent associated to the specified thread.
 String getGroup(String threadName)
          Gets the name of the group associated to the specified thread.
 String[] getGroups()
          Gets the names of all the groups stored in the database.
 String[] getGroupsToRead(String rootName)
          Gets the names of the groups with read permission to a specific root.
 String[] getGroupsToWrite(String rootName)
          Gets the names of the groups with write and delete permissions to a specific root.
 String[] getRoots()
          Gets the names of all the roots stored in the database.
 String[] getRootsToRead(String groupName)
          Gets the names of the roots that this group has permission to read.
 String[] getRootsToWrite(String groupName)
          Gets the names of the roots that this group has permission to write and delete.
 long getTime(String groupName)
          Gets the lifetime of the agents that belongs to this group.
 void initialize()
          Initializes the database with the firsts groups.
 boolean isGroup(String groupName)
          Tests if this group name already exists in the database.
 boolean isReadable(String rootName, String groupName)
          Tests if a group has permission to read a root.
 boolean isRoot(String rootName)
          Tests if a root exists in the database.
 boolean isWriteable(String rootName, String groupName)
          Tests if a group has permission to write and delete a root.
 void removeAssociation(String threadName)
          Removes the association between an agent and a thread.
 void set(String rootName, Object root)
          Updates a root content.
 void setGroupToRead(String rootName, String groupToRead)
          Gives permission for a group to read a specified root.
 void setGroupToWrite(String rootName, String groupToWrite)
          Gives permission for a group to write and delete a specified root.
 

Method Detail

initialize

public void initialize()
Initializes the database with the firsts groups.

createGroup

public void createGroup(String groupName,
                        long time)
Creates a new group and specifies the lifetime of the agents that will belong to the group.
Parameters:
groupName - the group name
time - the lifetime of the agents that belongs to this group.

deleteGroup

public void deleteGroup(String groupName)
Deletes an existing group.
Parameters:
groupName - the name of the group to be deleted

getRootsToRead

public String[] getRootsToRead(String groupName)
Gets the names of the roots that this group has permission to read.
Parameters:
groupName - the group name
Returns:
the names of the roots

getRootsToWrite

public String[] getRootsToWrite(String groupName)
Gets the names of the roots that this group has permission to write and delete.
Parameters:
groupName - the group name
Returns:
the names of the roots

getTime

public long getTime(String groupName)
Gets the lifetime of the agents that belongs to this group.
Parameters:
groupName - the group name
Returns:
the lifetime of this group's agents

isGroup

public boolean isGroup(String groupName)
Tests if this group name already exists in the database.
Parameters:
groupName - the group name
Returns:
true if the group already exists, false otherwise.

getGroups

public String[] getGroups()
Gets the names of all the groups stored in the database.
Returns:
the names of the stored groups.

createRoot

public void createRoot(String rootName)
Creates an empty root in the database.
Parameters:
rootName - the name of the root to be created

deleteRoot

public void deleteRoot(String rootName)
Deletes an existing group of the database.
Parameters:
rootName - the name of the root to be deleted

get

public Object get(String rootName)
Gets a root content.
Parameters:
rootName - the root name
Returns:
the contents of this root stored in the database

set

public void set(String rootName,
                Object root)
Updates a root content.
Parameters:
rootName - the name of the root to be updated.
root - the contents to be stored.

setGroupToRead

public void setGroupToRead(String rootName,
                           String groupToRead)
Gives permission for a group to read a specified root.
Parameters:
rootName - the root name
groupToRead - the group name

setGroupToWrite

public void setGroupToWrite(String rootName,
                            String groupToWrite)
Gives permission for a group to write and delete a specified root.
Parameters:
rootName - the root name
groupToRead - the group name

getRoots

public String[] getRoots()
Gets the names of all the roots stored in the database.
Returns:
the roots names

isRoot

public boolean isRoot(String rootName)
Tests if a root exists in the database.
Parameters:
rootName - the root name
Returns:
true if the roor already exists, false otherwise.

getGroupsToRead

public String[] getGroupsToRead(String rootName)
Gets the names of the groups with read permission to a specific root.
Parameters:
rootName - the root name
Returns:
the names of the groups that can read this root

getGroupsToWrite

public String[] getGroupsToWrite(String rootName)
Gets the names of the groups with write and delete permissions to a specific root.
Parameters:
rootName - the root name
Returns:
the names of the groups that can write and delete this root

isReadable

public boolean isReadable(String rootName,
                          String groupName)
Tests if a group has permission to read a root.
Parameters:
rootName - the root name
groupName - the group name
Returns:
true if the group has permission to read the root, false otherwise.

isWriteable

public boolean isWriteable(String rootName,
                           String groupName)
Tests if a group has permission to write and delete a root.
Parameters:
rootName - the root name
groupName - the group name
Returns:
true if the group has permission to write and delete the root, false otherwise.

associate

public void associate(String threadName,
                      String groupName,
                      String agentName)
Associates a thread with an agent and its group. It is necessary when a new agent starts running. If each agent is executed in a thread its possible to know to which group the thread belongs to.
Parameters:
threadName - the thread name
groupName - the group name
agentName - the agent name

getGroup

public String getGroup(String threadName)
Gets the name of the group associated to the specified thread.
Parameters:
threadName - the thread name
Returns:
the group name

getAgentName

public String getAgentName(String threadName)
Gets the name of the agent associated to the specified thread.
Parameters:
threadName - the thread name
Returns:
the agent name

removeAssociation

public void removeAssociation(String threadName)
Removes the association between an agent and a thread. It is necessary when an agent finishes its execution or when its lifetime ends.
Parameters:
threadName - the name of the thread to be excluded