/*********************************************************************/ /* */ /* 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.Collections.Generic; using System.Text; using AgentService.Platform.AMS; using AgentService.Platform.Modules; namespace AgentService.Agent.Runtime { /// /// Class LogModuleProxy. Creates a proxy of the LoggingModule /// in the current Application Domain, this class is used to /// connect logging module clients to the LoggingModule instance /// when clients are in a different application domain. /// class LogModuleProxy : MarshalByRefObject, ILoggingModule { #region members /// /// the reference to the LoggingModule /// private ILoggingModule logmodule; /// /// Gets, sets the logging level /// public LoggingLevel Level { get { return this.logmodule.Level; } set { this.logmodule.Level = value; } } /// /// Gets, sets the logging format. /// public string Format { get { return this.logmodule.Format; } set { this.logmodule.Format = value; } } /// /// Gets the base logging directory for the log files /// of agents /// public string BaseLoggingDirectory { get { return this.logmodule.BaseLoggingDirectory; } } /// /// Gets the log file extension used /// public string LogExtension { get { return this.logmodule.LogExtension; } } #endregion #region ILoggingModule Members /// /// Appends a message to the logging system with the given level. /// Note: messages are logged only if the given level is higher /// or equal to logging level set with "Level" property /// /// Logging level of the message /// message content public void Append(LoggingLevel level, string message) { this.logmodule.Append(level, message); } /// /// Clear all the messages stored in the log. /// public void Clear() { this.logmodule.Clear(); } /// /// Retrieves the collection of messages stored in the logging system. /// /// The collection of messages. public System.Collections.Specialized.StringCollection GetMessages() { return this.logmodule.GetMessages(); } /// /// Gets true if the module provides a custom client. /// public bool HasClient { get { return this.logmodule.HasClient; } } /// /// Creates a client of the logging system for a given agent. /// /// agent identifier. /// session identifier /// client to the logging system. public ILogClient CreateClient(AID aid, int token) { return this.logmodule.CreateClient(aid, token); } #endregion #region IPlatformModule Members /// /// Gets the name of the module /// public string Name { get { return this.logmodule.Name; } } /// /// Gets a summary description of the module /// public string Description { get { return this.logmodule.Description; } } /// /// Gets the belonging category of the module /// public ModuleCategory Category { get { return this.logmodule.Category; } } /// /// Gets a bool value indicating if the module is /// able to perform the main functionality of the /// belonging category. If the bool value is false /// the maodule is not a main module. This means that /// in the case of the Messaging Category the module /// can be a filter. If the bool value is true insted /// the module can perform all the base functionalities /// required by the messaging subsystem /// public bool IsMain { get { return this.logmodule.IsMain; } } /// /// Checks wheter the module supports features defined in a given interface. /// If the these features are supported the module reference can be subject to /// cast against the requested interface. /// /// full name of the interface that /// true if the specified interface is supported public bool CanSupport(string capabiltyInterface) { return this.logmodule.CanSupport(capabiltyInterface); } /// /// Returns the last error occurred in the module, null if there /// are no errors to return /// /// Reference to the error. public IModuleError GetLastError() { return this.logmodule.GetLastError(); } /// /// Attaches the module to the platform. Called by the platform /// when the module is loaded. /// /// reference to the instance of the hosting platform /// installation information of the module /// returns true is the operation has been successfulland with no errors public bool Attach(Platform.IPlatformContext hostingPlatform, ModuleInfo info) { return this.logmodule.Attach(hostingPlatform, info); } /// /// Detaches the module from the platform Called by the platform when /// the module is unloaded /// /// true if the operation has been successful public bool Detach() { return this.logmodule.Detach(); } /// /// Installs a the module in the platform. Called by the pltaform when the module is /// installed. /// /// platform context, accessible platform data from modules /// information about the module /// installation info object used to store install information /// true if the installation process has been successful public bool Install(Platform.IPlatformContext context, ModuleInfo info, ref InstallationInfo instInfo) { return this.logmodule.Install(context, info, ref instInfo); } /// /// Uninstall the module. Called by the platform when the module is removed permanently /// from the platform /// /// installation info object used to install the module /// true if the uninstallation process has been successful public bool UnInstall(InstallationInfo instInfo) { return this.logmodule.UnInstall(instInfo); } #endregion /// /// Creates a LogModuleProxy instance connected /// to the logging module. /// /// public LogModuleProxy(ILoggingModule obj) { this.logmodule = obj; } } }