/*********************************************************************/ /* */ /* 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 System.IO; using System.Reflection; using AgentService.Agent; using AgentService.Agent.Runtime; using AgentService.Platform.Modules; using AgentService.Platform.Configuration; using AgentService.Platform.Commands; using AgentService.Platform.AMS; using AgentService.Interop; namespace AgentService.Platform { /// /// Class PlatformProxy. Proxy object used to mantain a /// cross-domain reference to the platform instance. /// public class PlatformProxy: MarshalByRefObject, IPlatform { #region Platform structure constant strings #endregion #region Data Member private IPlatform platform; public string amsName { get { return this.platform.amsName; } } /// /// Name of the MTS agent. /// public string mtsName { get { return this.platform.mtsName; } } /// /// Name of the DF agent. /// public string dfName { get { return this.platform.dfName; } } public IPlatformDescription Description { get { return this.platform.Description; } } /// /// Gets the Yellow Pages Service. /// public IYellowPagesServer YellowPageSvc { get { return this.platform.YellowPageSvc; } } /// /// Gets the White Pages Service. /// public IWhitePagesServer WhitePageSvc { get { return this.platform.WhitePageSvc; } } #endregion #region Platform Startup and Configuration /// /// Gets the Platform Configuration Information. /// public Configuration.Configuration Configuration { get { return this.platform.Configuration; } } /// /// Gets the platform State. /// public PlatformState State { get { return this.platform.State; } } #endregion #region Support Members public IPlatformConsole Console { get { return this.platform.Console; } } #endregion #region Platform Modules /// /// Gets the Storage Module. /// public IStorageModule Storage { get { return this.platform.Storage; } } /// /// Gets the Messaging Module. /// public IMessagingModule Messaging { get { return this.platform.Messaging; } } /// /// Gets the Persistence Module. /// public IPersistenceModule Persistence { get { return this.platform.Persistence; } } /// /// Gets the Logging Module. /// public ILoggingModule Logging { get { return this.platform.Logging; } } /// /// Gets the additional modules loaded in the platform. /// public IPlatformModule[] Modules { get { return this.platform.Modules; } } #endregion #region Core Agents References public AgentService.Platform.AMS.AMS ams { get { return this.platform.ams; } } public AgentService.Platform.MTS.IMTSGateway mts { get { return this.platform.mts; } } #endregion #region Constructors public PlatformProxy(IPlatform obj) { this.platform = obj; } #endregion #region Platform Control Methods /// /// Installs a module into the AgentService platform /// /// full name of the type that define the module /// path to the assembly where the type is defined /// name of the file to store configuration information /// true if the installation is successful public bool InstallModule(ModuleInfo modInfo) { return this.platform.InstallModule(modInfo); } /// /// Uninstalls a module from the AgentService platform /// /// full name of the type that implements the module /// true if the assembly need to be removed after uninstall /// true if the uninstallation has been successful public bool UninstallModule(string typeName, bool bRemoveAssembly) { return this.platform.UninstallModule(typeName,bRemoveAssembly); } #endregion #region Worker Private Methods #endregion #region Agent Management Methods /// /// Create an agent with the given agent template, name, and configuration file /// /// name of the agent template /// name of the agent to be created /// name of the configuration file including the path /// persistence flag /// True if the agent is been created, false otherwise public AID CreateAgent(string agentTemplate, string agentName, string configFile, bool bPersist) { return this.platform.CreateAgent(agentTemplate, agentName, configFile, bPersist); } /// /// Create an agent with the given agent template, name, and configuration file /// /// name of the agent template /// name of the agent to be created /// name of the configuration file including the path /// persistence flag /// if true do not perform agent initialization /// domain flag /// True if the agent is been created, false otherwise public AID CreateAgent(string agentTemplate, string agentName, string configFile, bool bPersist, bool bCreateForResume, bool bDomain) { return this.platform.CreateAgent(agentTemplate, agentName, configFile, bPersist, bCreateForResume, bDomain); } /// /// Create an agent with the given agent template, name, and configuration file /// /// name of the agent template /// name of the agent to be created /// name of the configuration file including the path /// persistence flag /// if true do not perform agent initialization /// domain flag /// the name of the AppDomain in which the Agent is created /// True if the agent is been created, false otherwise public AID CreateAgent(string agentTemplate, string agentName, string configFile, bool bPersist, bool bCreateForResume, bool bDomain, string domainName) { return this.platform.CreateAgent(agentTemplate, agentName, configFile, bPersist, bCreateForResume, bDomain, domainName); } /// /// persistence event handler /// /// source of the event /// event args public void persistAgent(object sender, PersistenceEventArgs args) { this.platform.persistAgent(sender, args); } /// /// Callback or agent activation /// /// aid of the activted agent public void onActivateAgent(AID sender) { this.platform.onActivateAgent(sender); } /// /// Callback for agent termination /// /// aid of the terminated agent public void onTerminateAgent(AID sender) { this.platform.onTerminateAgent(sender); } #endregion } }