Working on run-time init
Working on build-up and tear-down for loading/unloading plugginsintegration
parent
4b278c64d6
commit
35fa8b454d
|
@ -52,19 +52,28 @@ namespace OpenSim.Services.IntegrationService
|
||||||
string DefaultConfig { get; }
|
string DefaultConfig { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IntegrationServiceBase : ServiceBase
|
// Hide the nasty stuff in here, let the IntegrationService be clean for
|
||||||
|
// our command and request handlers
|
||||||
|
public class IntegrationServiceBase : ServiceBase
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private string m_ConfigName = "IntegrationService";
|
private string m_ConfigName = "IntegrationService";
|
||||||
|
|
||||||
protected IPresenceService m_PresenceService;
|
// protected IPresenceService m_PresenceService;
|
||||||
protected IGridService m_GridService;
|
// protected IGridService m_GridService;
|
||||||
protected IHttpServer m_Server;
|
protected IHttpServer m_Server;
|
||||||
|
|
||||||
protected string m_IntegrationConfig;
|
protected string m_IntegrationConfig;
|
||||||
protected PluginManager m_PluginManager;
|
protected PluginManager m_PluginManager;
|
||||||
IConfig m_IntegrationServerConfig;
|
AddinManager am;
|
||||||
string m_IntegrationConfigLoc;
|
|
||||||
|
// Our individual pluggin configs
|
||||||
|
protected IConfig m_IntegrationServerConfig;
|
||||||
|
protected string m_IntegrationConfigLoc;
|
||||||
|
|
||||||
|
// Our server config
|
||||||
|
IConfigSource m_ConfigSource;
|
||||||
|
|
||||||
public IntegrationServiceBase(IConfigSource config, IHttpServer server)
|
public IntegrationServiceBase(IConfigSource config, IHttpServer server)
|
||||||
: base(config)
|
: base(config)
|
||||||
|
@ -77,6 +86,7 @@ namespace OpenSim.Services.IntegrationService
|
||||||
// defaults to the ./bin directory
|
// defaults to the ./bin directory
|
||||||
string RegistryLocation = serverConfig.GetString("PluginRegistryLocation",
|
string RegistryLocation = serverConfig.GetString("PluginRegistryLocation",
|
||||||
".");
|
".");
|
||||||
|
|
||||||
AddinRegistry registry = new AddinRegistry(RegistryLocation, ".");
|
AddinRegistry registry = new AddinRegistry(RegistryLocation, ".");
|
||||||
m_PluginManager = new PluginManager(registry);
|
m_PluginManager = new PluginManager(registry);
|
||||||
|
|
||||||
|
@ -88,6 +98,7 @@ namespace OpenSim.Services.IntegrationService
|
||||||
AddinManager.AddinLoaded += on_addinloaded_;
|
AddinManager.AddinLoaded += on_addinloaded_;
|
||||||
AddinManager.AddinLoadError += on_addinloaderror_;
|
AddinManager.AddinLoadError += on_addinloaderror_;
|
||||||
AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded;
|
AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded;
|
||||||
|
AddinManager.AddinEngine.ExtensionChanged += HandleAddinManagerAddinEngineExtensionChanged;
|
||||||
m_Server = server;
|
m_Server = server;
|
||||||
|
|
||||||
m_IntegrationServerConfig = config.Configs["IntegrationService"];
|
m_IntegrationServerConfig = config.Configs["IntegrationService"];
|
||||||
|
@ -102,6 +113,10 @@ namespace OpenSim.Services.IntegrationService
|
||||||
AddinManager.Registry.Update ();
|
AddinManager.Registry.Update ();
|
||||||
suppress_console_output_(false);
|
suppress_console_output_(false);
|
||||||
|
|
||||||
|
|
||||||
|
AddinManager.AddExtensionNodeHandler ("/OpenSim/IntegrationService", OnExtensionChanged);
|
||||||
|
|
||||||
|
|
||||||
foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService"))
|
foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService"))
|
||||||
{
|
{
|
||||||
string ConfigPath = String.Format("{0}/(1)", m_IntegrationConfigLoc,cmd.ConfigName);
|
string ConfigPath = String.Format("{0}/(1)", m_IntegrationConfigLoc,cmd.ConfigName);
|
||||||
|
@ -148,6 +163,11 @@ namespace OpenSim.Services.IntegrationService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HandleAddinManagerAddinEngineExtensionChanged (object sender, ExtensionEventArgs args)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Plugin Extension Change");
|
||||||
|
}
|
||||||
|
|
||||||
private IConfigSource GetConfig(string configName)
|
private IConfigSource GetConfig(string configName)
|
||||||
{
|
{
|
||||||
return new IniConfigSource();
|
return new IniConfigSource();
|
||||||
|
@ -169,6 +189,30 @@ namespace OpenSim.Services.IntegrationService
|
||||||
+ args.Exception.StackTrace);
|
+ args.Exception.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is out init
|
||||||
|
// We can do build-up and tear-down of our plugin
|
||||||
|
void OnExtensionChanged (object s, ExtensionNodeEventArgs args)
|
||||||
|
{
|
||||||
|
IntegrationPlugin ip = (IntegrationPlugin) args.ExtensionObject;
|
||||||
|
|
||||||
|
m_log.Info ("[INTEGRATION SERVICE]: Plugin Change");
|
||||||
|
|
||||||
|
switch (args.Change)
|
||||||
|
{
|
||||||
|
// Build up
|
||||||
|
case ExtensionChange.Add:
|
||||||
|
|
||||||
|
m_log.InfoFormat("[INTEGRATION SERVICE]: Plugin Added {0}", ip.Name);
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Tear down
|
||||||
|
case ExtensionChange.Remove:
|
||||||
|
|
||||||
|
m_log.InfoFormat("[INTEGRATION SERVICE]: Plugin Remove {0}", ip.Name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void on_addinloaded_(object sender, AddinEventArgs args)
|
private void on_addinloaded_(object sender, AddinEventArgs args)
|
||||||
{
|
{
|
||||||
m_log.Info ("[INTEGRATION SERVICE]: Plugin Loaded: " + args.AddinId);
|
m_log.Info ("[INTEGRATION SERVICE]: Plugin Loaded: " + args.AddinId);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Linq;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
@ -260,11 +261,19 @@ namespace OpenSim.Services.IntegrationService
|
||||||
m_Registry.Update();
|
m_Registry.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show plugin info
|
||||||
public string AddinInfo(string[] args)
|
public string AddinInfo(string[] args)
|
||||||
{
|
{
|
||||||
|
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||||
|
|
||||||
string id = args[2];
|
int n = Convert.ToInt16(args[2]);
|
||||||
Addin addin = Registry.GetAddin(id, true);
|
if (n > (addins.Length -1))
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Selection out of range");
|
||||||
|
return "XXX";
|
||||||
|
}
|
||||||
|
|
||||||
|
Addin addin = addins[n];
|
||||||
MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\n{2}",
|
MainConsole.Instance.OutputFormat("Name: {0}\nURL: {1}\n{2}",
|
||||||
addin.Name, addin.Description.Url,
|
addin.Name, addin.Description.Url,
|
||||||
addin.Description.FileName);
|
addin.Description.FileName);
|
||||||
|
@ -304,16 +313,33 @@ namespace OpenSim.Services.IntegrationService
|
||||||
|
|
||||||
Addin addin = addins[n];
|
Addin addin = addins[n];
|
||||||
addin.Enabled = true;
|
addin.Enabled = true;
|
||||||
|
AddinManager.Registry.EnableAddin(addin.Id);
|
||||||
|
AddinManager.Registry.Update();
|
||||||
|
AddinManager.AddinEngine.LoadAddin(null, addin.Id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Util
|
#region Util
|
||||||
|
private void Testing()
|
||||||
|
{
|
||||||
|
Addin[] list = Registry.GetAddins();
|
||||||
|
|
||||||
|
var addins = list.Where( a => a.Description.Category == "IntegrationPlugin");
|
||||||
|
|
||||||
|
foreach (Addin addin in addins)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.OutputFormat("Addin {0}", addin.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Addin[] GetSortedAddinList(string category)
|
private Addin[] GetSortedAddinList(string category)
|
||||||
{
|
{
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
list.AddRange(m_Registry.GetAddins());
|
list.AddRange(m_Registry.GetAddins());
|
||||||
ArrayList xlist = new ArrayList();
|
ArrayList xlist = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (Addin addin in list)
|
foreach (Addin addin in list)
|
||||||
{
|
{
|
||||||
if (addin.Description.Category == category)
|
if (addin.Description.Category == category)
|
||||||
|
|
Loading…
Reference in New Issue