/*********************************************************************/
/* */
/* AgentService Framework */
/* www.agentservice.it */
/* */
/* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */
/* GNU Lesser General Public License */
/* */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */
/* License as published by the Free Software Foundation, */
/* version 2.1 of the License. */
/* */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with this library; if not, write to the */
/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
/* Boston, MA 02111-1307, USA. */
/* */
/*********************************************************************/
using System;
using AgentService.Platform.Modules;
namespace AgentService.Platform.Commands
{
#region ManagePlatformCommands
///
/// Class StartCommand. Command issued to start the platform.
///
public class StartCommand : PlatformCommand
{
///
/// Constructs a StartCommand object.
///
public StartCommand() : base(PlatformState.Ready, true)
{
}
public override void Execute(ICommandContext cmdCtx)
{
cmdCtx.StartPlatform();
}
public override bool ParseArguments(string args)
{
// TODO: implements method
return true;
}
}
///
/// Class StopCommand. Stops the AgentService platform.
///
public class StopCommand : PlatformCommand
{
///
/// Constructs a StopCommand object.
///
public StopCommand() : base(PlatformState.Running, true)
{
}
public override void Execute(ICommandContext cmdCtx)
{
cmdCtx.RunPlatform();
}
public override bool ParseArguments(string args)
{
// TODO: implements method
return true;
}
}
///
/// Class CloseCommand. Close a shell session.
///
public class CloseCommand : PlatformCommand
{
///
/// Constructs a CloseCommand object.
///
public CloseCommand() : base(PlatformState.FailStart,false)
{
}
public override void Execute(ICommandContext cmdCtx)
{
cmdCtx.BindToInput(null);
}
public override bool ParseArguments(string args)
{
// TODO: implements method
return true;
}
}
#endregion
#region ManageModuleCommands
// ///
// /// Class InstallModuleCommand. Command issued when we want ot install a module
// ///
// public class InstallModuleCommand : PlatformCommand
// {
// ///
// /// full type name of the module
// ///
// private string typeName;
// ///
// /// Gets the full type name of the module
// ///
// public string FullTypeName
// {
// get
// {
// return this.typeName;
// }
// }
//
// ///
// /// path to the assembly where the module is defined
// ///
// private string assemblyPath;
// ///
// /// Gets the path to the assembly where the module is defined
// ///
// public string AssemblyPath
// {
// get
// {
// return this.assemblyPath;
// }
// }
//
// ///
// /// path to the configuration file for the module
// ///
// private string configPath;
// ///
// /// Gets the path to the configuration file for the module
// ///
// public string ConfigPath
// {
// get
// {
// return this.configPath;
// }
// }
//
// ///
// /// module category
// ///
// private ModuleCategory category;
// ///
// /// Gets the module category
// ///
// public ModuleCategory Category
// {
// get
// {
// return this.category;
// }
// }
//
// ///
// /// Constructs an InstallModuleCommand, for common modules
// ///
// /// full name of the type that implements the module
// /// path to the assembly where the module is defined
// /// path to the configuration file
// public InstallModuleCommand(string typeName, string assemblyPath, string configFilePath) : base(Commands.InstallModule, CommandLevel.Ready)
// {
// if (typeName == null)
// throw new ArgumentNullException("typeName", "type name cannot be null");
//
// if (assemblyPath == null)
// throw new ArgumentNullException("assemblyPath", "null path to assembly");
//
// this.typeName = typeName;
// this.assemblyPath = assemblyPath;
// this.configPath = configFilePath;
// this.category = ModuleCategory.Other;
// }
//
// ///
// /// Constructs an InstallModuleCommand by specifying the type of the module
// ///
// /// full type name of the module
// /// path to the assembly where the module is defined
// /// path to configuration file of the module
// /// type of the module
// public InstallModuleCommand(string typeName, string assemblyPath, string configFilePath, ModuleCategory categoy)
// {
// if (typeName == null)
// throw new ArgumentNullException("typeName", "type name cannot be null");
//
// if (assemblyPath == null)
// throw new ArgumentNullException("assemblyPath", "null path to assembly");
//
// if (category == ModuleCategory.Core)
// throw new NotSupportedException("module category Core is not supported");
//
// this.typeName = typeName;
// this.assemblyPath = assemblyPath;
// this.configPath = configPath;
//
// this.category = category;
// }
// }
//
// ///
// /// Class UninstallModuleCommand. Command issued to uninstall a module from the platform
// ///
// public class UninstallModuleCommand : PlatformCommand
// {
// ///
// /// full type name of the module
// ///
// private string typeName;
// ///
// /// Gets the full type name of the module
// ///
// public string FullTypeName
// {
// get
// {
// return this.typeName;
// }
// }
//
// ///
// /// Constructs an UninstallModuleCommand by specifying the type of the module
// ///
// /// full type name of the module
// public UninstallModuleCommand(string typeName) : base(Commands.UninstallModule, CommandLevel.Ready)
// {
// if (typeName == null)
// throw new ArgumentNullException("typeName", "type name cannot be null");
//
// this.typeName = typeName;
// }
// }
//
// ///
// /// Class AttachModuleCommand. Command issued to attach a module from the platform
// ///
// public class AttachModuleCommand : PlatformCommand
// {
// ///
// /// full type name of the module
// ///
// private string typeName;
// ///
// /// Gets the full type name of the module
// ///
// public string FullTypeName
// {
// get
// {
// return this.typeName;
// }
// }
//
// ///
// /// Constructs an AttachModuleCommand by specifying the type of the module
// ///
// /// full type name of the module
// public AttachModuleCommand(string typeName) : base(Commands.AttachModule, CommandLevel.Ready)
// {
// if (typeName == null)
// throw new ArgumentNullException("typeName", "type name cannot be null");
//
// this.typeName = typeName;
// }
// }
//
// ///
// /// Class AttachModuleCommand. Command issued to detach a module from the platform
// ///
// public class DetachModuleCommand : PlatformCommand
// {
// ///
// /// full type name of the module
// ///
// private string typeName;
// ///
// /// Gets the full type name of the module
// ///
// public string FullTypeName
// {
// get
// {
// return this.typeName;
// }
// }
//
// ///
// /// Constructs an DetachModuleCommand by specifying the type of the module
// ///
// /// full type name of the module
// public DetachModuleCommand(string typeName) : base(Commands.DetachModule, CommandLevel.Ready)
// {
// if (typeName == null)
// throw new ArgumentNullException("typeName", "type name cannot be null");
//
// this.typeName = typeName;
// }
// }
#endregion
#region ManageAgentCommands
///
/// Class CreateAgentCommand. Command issued to create an agent
///
public class CreateAgentCommand : PlatformCommand
{
///
/// Agent Identifier
///
private AgentService.Agent.AID aid;
///
/// Gets the unique identifier of the agent
///
public AgentService.Agent.AID Aid
{
get
{
return this.aid;
}
}
///
/// full type name of the template
///
private string templateName;
///
/// Gets the full type name of the template
///
public string FullTemplateName
{
get
{
return this.templateName;
}
}
///
/// name of the agent
///
private string agentName;
///
/// Gets the name of the agent
///
public string AgentName
{
get
{
return this.agentName;
}
}
///
/// The full path to the configuration file
///
private string config;
///
/// Gets the path to the configuration file
///
public string Config
{
get
{
return this.config;
}
}
///
/// Flag that controls the persistene of the agent
///
private bool bPersist;
///
/// Gets the persistence flag of the agent
///
public bool IsPersistent
{
get
{
return this.bPersist;
}
}
///
/// Constructs a CreateAgentCommand object by specifying the agent name and the template type
///
/// name of the agent
/// full type name of the template
public CreateAgentCommand(string agentName, string templateName): base(PlatformState.Running, true)
{
if ((agentName == null) || (agentName == String.Empty))
throw new ArgumentNullException("agentName", "agent name cannot be null or empty");
if (templateName == null)
throw new ArgumentNullException("templateName", "null template name?");
this.agentName = agentName;
this.templateName = templateName;
}
public override void Execute(ICommandContext cmdCtx)
{
this.aid = cmdCtx.CreateAgent(this.agentName,this.FullTemplateName,this.config,this.bPersist);
}
public override bool ParseArguments(string args)
{
// TODO: implements method
return false;
}
}
///
/// Class TerminateAgentCommand. Command issued to terminate an agent
///
public class TerminateAgentCommand : PlatformCommand
{
///
/// name of the agent
///
private string agentName;
///
/// Gets the name of the agent
///
public string AgentName
{
get
{
return this.agentName;
}
}
///
/// Constructs a TerminateAgentCommand object by specifying the agent name and the template type
///
/// name of the agent
public TerminateAgentCommand(string agentName) : base(PlatformState.Running,true)
{
if ((agentName == null) || (agentName == String.Empty))
throw new ArgumentNullException("agentName", "agent name cannot be null or empty");
this.agentName = agentName;
}
public override void Execute(ICommandContext cmdCtx)
{
cmdCtx.KillAgent(this.agentName);
}
public override bool ParseArguments(string args)
{
// TODO: implements method
return false;
}
}
#endregion
#region ManageAssemblyCommand
///
/// Class LoadAssemblyCommand. Command issued to load an assembly into the platform
///
public class UpLoadAssemblyCommand : PlatformCommand
{
///
/// path to the assembly to load
///
private string assemblyPath;
///
/// Gets the path to the assembly to load
///
public string AssemblyPath
{
get
{
return this.assemblyPath;
}
}
///
/// Constructs a LoadAssemblyCommand by specifying the assembly path
///
///
public UpLoadAssemblyCommand(string assemblyPath) : base(PlatformState.Ready,false)
{
if (assemblyPath == null)
throw new ArgumentNullException("assemblyPath", "null path to assembly");
this.assemblyPath = assemblyPath;
}
public override void Execute(ICommandContext cmdCtx)
{
//TODO: implements method
}
public override bool ParseArguments(string args)
{
// TODO: implements method
return false;
}
}
///
/// Class RemoveAssemblyCommand. Command issued to remove an assembly into the platform
///
public class RemoveAssemblyCommand : PlatformCommand
{
///
/// name of the assembly to remove
///
private string assemblyFile;
///
/// Gets the name of the assembly to remove
///
public string AssemblyFile
{
get
{
return this.assemblyFile;
}
}
///
/// Constructs a LoadAssemblyCommand by specifying the assembly name
///
/// name of the assembly file to remove
public RemoveAssemblyCommand(string assemblyFile) : base(PlatformState.Ready,true)
{
if (assemblyFile == null)
throw new ArgumentNullException("assemblyPath", "null path to assembly");
this.assemblyFile = assemblyFile;
}
public override void Execute(ICommandContext cmdCtx)
{
// TODO: implements method
}
public override bool ParseArguments(string args)
{
// TODO: implements method
return false;
}
}
#endregion
}