Code/SifCommonFramework/Systemic.Sif.Framework/Agent/BaseAgent.cs
/// <summary>
/// Configure the Agent based on the Agent configuration file, then initialise.
/// </summary>
/// <exception cref="System.IO.IOException">File or resource exception occurred, possibly while reading Agent configuration file.</exception>
/// <exception cref="System.Reflection.TargetException">Unable to create an instance of a Publisher or Subscriber for the Agent.</exception>
Configure the Agent based on the Agent configuration file, then initialise.
Configure the Agent based on the Agent configuration file then initialise .
public override void Initialize()
        {
            if (Initialized)
            {
                if (log.IsInfoEnabled) log.Info("Agent " + this.Id + " has already been initialised and will not be initialised again.");
            }
            else
            {
                Adk.Initialize();
                AgentConfig agentConfig = new AgentConfig();
                try
                {
                    agentConfig.Read(this.cfgFileName, false);
                }
                catch (IOException e)
                {
                    throw new IOException("Error reading Agent configuration file " + this.cfgFileName + " when initialising Agent " + this.Id + ".", e);
                }
                Id = agentConfig.SourceId;
                Adk.SifVersion = agentConfig.Version;
                try
                {
                    base.Initialize();
                }
                catch (Exception e)
                {
                    throw new IOException("Agent " + this.Id + " is unable to initialise due to a file or resource exception.", e);
                }
                agentConfig.Apply(this, true);
                AgentConfiguration = agentConfig;
                if (Properties.GetProperty("agent.debugAll", false))
                {
                    Adk.Debug = AdkDebugFlags.All;
                }
                else
                {
                    Adk.Debug = AdkDebugFlags.Minimal;
                }
                String displayName = Properties.GetProperty("agent.description", null);
                if (displayName != null)
                {
                    this.fName = displayName;
                }
                if (!Directory.Exists(this.WorkDir))
                {
                    Directory.CreateDirectory(this.WorkDir);
                }
                if (log.IsInfoEnabled) log.Info("Agent " + this.Id + " has been initialised using configuration file " + this.cfgFileName + "...");
                if (log.IsInfoEnabled) log.Info("Agent Property => Display name: " + this.fName);
                if (log.IsInfoEnabled) log.Info("Agent Property => Messaging mode: " + Properties.MessagingMode);
                if (log.IsInfoEnabled) log.Info("Agent Property => Transport protocol: " + Properties.TransportProtocol);
                if (log.IsInfoEnabled) log.Info("Agent Property => Pull frequency: " + Properties.PullFrequency);
                if (log.IsInfoEnabled) log.Info("Agent Property => Maximum buffer size: " + Properties.MaxBufferSize);
                if (log.IsInfoEnabled) log.Info("Agent Property => Override SIF versions: " + Properties.OverrideSifVersions);
                if (log.IsInfoEnabled) log.Info("Agent Property => Home directory: " + this.HomeDir);
                if (log.IsInfoEnabled) log.Info("Agent Property => Work directory: " + this.WorkDir);
                StartAgent();
            }
        }
public override void Initialize ( ) { if ( Initialized ) { if ( log . IsInfoEnabled ) log . Info ( " " + this . Id + " " ) ; } else { Adk . Initialize ( ) ; AgentConfig agentConfig = new AgentConfig ( ) ; try { agentConfig . Read ( this . cfgFileName , false ) ; } catch ( IOException e ) { throw new IOException ( " " + this . cfgFileName + " " + this . Id + " " , e ) ; } Id = agentConfig . SourceId ; Adk . SifVersion = agentConfig . Version ; try { base . Initialize ( ) ; } catch ( Exception e ) { throw new IOException ( " " + this . Id + " " , e ) ; } agentConfig . Apply ( this , true ) ; AgentConfiguration = agentConfig ; if ( Properties . GetProperty ( " " , false ) ) { Adk . Debug = AdkDebugFlags . All ; } else { Adk . Debug = AdkDebugFlags . Minimal ; } String displayName = Properties . GetProperty ( " " , null ) ; if ( displayName != null ) { this . fName = displayName ; } if ( ! Directory . Exists ( this . WorkDir ) ) { Directory . CreateDirectory ( this . WorkDir ) ; } if ( log . IsInfoEnabled ) log . Info ( " " + this . Id + " " + this . cfgFileName + " " ) ; if ( log . IsInfoEnabled ) log . Info ( " " + this . fName ) ; if ( log . IsInfoEnabled ) log . Info ( " " + Properties . MessagingMode ) ; if ( log . IsInfoEnabled ) log . Info ( " " + Properties . TransportProtocol ) ; if ( log . IsInfoEnabled ) log . Info ( " " + Properties . PullFrequency ) ; if ( log . IsInfoEnabled ) log . Info ( " " + Properties . MaxBufferSize ) ; if ( log . IsInfoEnabled ) log . Info ( " " + Properties . OverrideSifVersions ) ; if ( log . IsInfoEnabled ) log . Info ( " " + this . HomeDir ) ; if ( log . IsInfoEnabled ) log . Info ( " " + this . WorkDir ) ; StartAgent ( ) ; } }
Configure the Agent based on the Agent configuration file, then initialise.
Configure the Agent based on the Agent configuration file then initialise .
// Initialise the ADK to use the latest SIF version and all SIF Data Object modules? // Read the Agent configuration file. // Override the SourceId passed to the constructor with the SourceID specified in the configuration // file. // Inform the ADK of the version of SIF specified in the sifVersion= attribute of the <agent> element. // Call the superclass initialise once the configuration file has been read. // Ask the AgentConfig instance to "apply" all configuration settings to this Agent. This includes // parsing and registering all <zone> elements with the Agent's ZoneFactory. // Set the level of debugging applied to the ADK. // Override the Agent display name if provided.
File or resource exception occurred, possibly while reading Agent configuration file.
File or resource exception occurred possibly while reading Agent configuration file .
Unable to create an instance of a Publisher or Subscriber for the Agent.
Unable to create an instance of a Publisher or Subscriber for the Agent .