|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lightdev.app.trec.server.Agent
com.lightdev.app.trec.server.ServerAdministrator
public class ServerAdministrator
An agent that is used by the Light Development Transparent Remote Computing (TREC) platform to enable users to do administration of a TREC server.
The agent makes available methods to upload agents and libraries as well as to add and remove agents as running services. It can be used to make backups of the SAM user and role database too.
| Field Summary | |
|---|---|
static String |
DEFAULT_NAME
name of agent this class is addressed under on a TREC server by default |
| Fields inherited from class com.lightdev.app.trec.server.Agent |
|---|
communicator |
| Constructor Summary | |
|---|---|
ServerAdministrator()
create a new instance of a ServerAdministrator object |
|
| Method Summary | |
|---|---|
boolean |
addAgent(String agentName,
String className)
add an agent existing on the server to the group of running agents on this server |
boolean |
deleteAgent(String fileName)
delete an agent archive file and its extracted contents When the agent creates files on the server, it has to remove these itself using its destroy method. |
boolean |
deleteBackup(String backupDir)
|
boolean |
deleteLibrary(String libName)
|
void |
destroy()
required by abstract Agent class but unsused here |
byte[] |
downloadBackup(String backupDirectory)
download a SAM backup file This method assumes all backups in directory WEB-INF/sambackup |
Vector |
getAgentArchives()
get the names of all archive files on the server |
Vector |
getAgentNames()
get the names of all agents running on this server |
Vector |
getLibraries()
|
String[] |
getRequiredRoleIds()
get id of all roles required by this agent |
byte[] |
getRolesForAgent(String agentName)
get all roles required by the agent with a given name |
Vector |
getUserDataStoreSettings()
|
void |
init()
required by abstract Agent class but unsused here |
protected void |
initMethodRoleMappings()
initialize the mapping between method names, that require a role and respective role id This method is called automatically upon construction but the developer must implement it individually for all methods that are to be guarded by SAM. |
protected void |
initRoleNames()
initialize names of the roles required by this agent This method is called automatically upon construction but the developer must implement it individually for roles that are required by this agent. |
boolean |
removeAgent(String agentName)
remove an agent from the group of running agents on this server |
void |
setServer(Server server)
set the TREC server this ServerAdministrator should use |
boolean |
setUserDataStore(int storeType,
String driverName,
String connectString)
set the user data store the TREC server should use |
boolean |
uploadAgent(String fileName,
byte[] agentArchive)
load an agent up to the server Contents of the uploaded archive will be extracted as found in the archive to the WEB-INF/classes directory of the TREC server. |
boolean |
uploadBackup(String fileName,
byte[] file)
upload a backup file This method assumes to receive a ZIP file with a backup directory. |
boolean |
uploadLibrary(String fileName,
byte[] library)
load a library up to the server The uploaded library will be saved to the WEB-INF/lib directory of the TREC server. |
| Methods inherited from class com.lightdev.app.trec.server.Agent |
|---|
getNameForRole, getRoleForMethod, mapRoleToMethod, setCommunicator, setNameForRoleId |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_NAME
| Constructor Detail |
|---|
public ServerAdministrator()
| Method Detail |
|---|
public boolean setUserDataStore(int storeType,
String driverName,
String connectString)
storeType - the type of data store, one of STORE_TYPE_ROOT, STORE_TYPE_EMBEDDED or
STORE_TYPE_SHARED_JDBCdriverName - full name of database driver class, e.g. com.mysql.jdbc.DriverconnectString - the connect string, e.g.
jdbc:mysql://server/database?user=name&password=pw
public Vector getUserDataStoreSettings()
throws IOException
IOExceptionpublic void setServer(Server server)
server - the TREC server
public byte[] downloadBackup(String backupDirectory)
throws Exception
download a SAM backup file
This method assumes all backups in directory WEB-INF/sambackup
backupDirectory - the backup directory
Exception
public boolean deleteBackup(String backupDir)
throws Exception
Exception
public boolean uploadBackup(String fileName,
byte[] file)
throws Exception
This method assumes to receive a ZIP file with a backup directory. The ZIP file will be extracted to directory WEB-INF/sambackup/[zip file name].
fileName - name of ZIP filefile - ZIP file contents
Exceptionpublic void init()
init in class Agentpublic void destroy()
destroy in class Agent
public boolean uploadAgent(String fileName,
byte[] agentArchive)
throws Exception
Contents of the uploaded archive will be extracted as found in the archive to the WEB-INF/classes directory of the TREC server. Files with the same name are overwritten.
fileName - name of file for agent archiveagentArchive - content of agent archive as byte array
Exception
public Vector getAgentArchives()
throws Exception
Exception
public Vector getLibraries()
throws Exception
Exception
public boolean deleteLibrary(String libName)
throws Exception
Exception
public boolean deleteAgent(String fileName)
throws Exception
When the agent creates files on the server, it has to remove these itself using its destroy method. Method destroy is called when the agent is stopped thus removing all files created by the agent before the agent itself is removed.
fileName - agent archive file name, e.g. my_agent.zip
Exception
public boolean uploadLibrary(String fileName,
byte[] library)
throws Exception
The uploaded library will be saved to the WEB-INF/lib directory of the TREC server. A file with the same name is overwritten.
fileName - name of library filelibrary - contents of library as byte array
Exception
public boolean addAgent(String agentName,
String className)
throws InstantiationException,
IllegalAccessException,
ClassNotFoundException,
IOException
agentName - name under which agent should be addressedclassName - class name of agent, e.g. com.lightdev.app.trec.sample.SampleSAMApplication
InstantiationException
IllegalAccessException
ClassNotFoundException
IOException
public boolean removeAgent(String agentName)
throws IOException
agentName - name of agent to remove
IOExceptionpublic Vector getAgentNames()
public byte[] getRolesForAgent(String agentName)
agentName - name of agent to get all requred roles for
public String[] getRequiredRoleIds()
getRequiredRoleIds in interface SAMApplicationgetRequiredRoleIds in class Agentprotected void initMethodRoleMappings()
This method is called automatically upon construction but the developer must implement it individually for all methods that are to be guarded by SAM.
initMethodRoleMappings in class Agentprotected void initRoleNames()
This method is called automatically upon construction but the developer must implement it individually for roles that are required by this agent.
initRoleNames in class Agent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||