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; }
|
||||
}
|
||||
|
||||
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 string m_ConfigName = "IntegrationService";
|
||||
|
||||
protected IPresenceService m_PresenceService;
|
||||
protected IGridService m_GridService;
|
||||
// protected IPresenceService m_PresenceService;
|
||||
// protected IGridService m_GridService;
|
||||
protected IHttpServer m_Server;
|
||||
|
||||
protected string m_IntegrationConfig;
|
||||
protected PluginManager m_PluginManager;
|
||||
IConfig m_IntegrationServerConfig;
|
||||
string m_IntegrationConfigLoc;
|
||||
AddinManager am;
|
||||
|
||||
// Our individual pluggin configs
|
||||
protected IConfig m_IntegrationServerConfig;
|
||||
protected string m_IntegrationConfigLoc;
|
||||
|
||||
// Our server config
|
||||
IConfigSource m_ConfigSource;
|
||||
|
||||
public IntegrationServiceBase(IConfigSource config, IHttpServer server)
|
||||
: base(config)
|
||||
|
@ -77,6 +86,7 @@ namespace OpenSim.Services.IntegrationService
|
|||
// defaults to the ./bin directory
|
||||
string RegistryLocation = serverConfig.GetString("PluginRegistryLocation",
|
||||
".");
|
||||
|
||||
AddinRegistry registry = new AddinRegistry(RegistryLocation, ".");
|
||||
m_PluginManager = new PluginManager(registry);
|
||||
|
||||
|
@ -88,6 +98,7 @@ namespace OpenSim.Services.IntegrationService
|
|||
AddinManager.AddinLoaded += on_addinloaded_;
|
||||
AddinManager.AddinLoadError += on_addinloaderror_;
|
||||
AddinManager.AddinUnloaded += HandleAddinManagerAddinUnloaded;
|
||||
AddinManager.AddinEngine.ExtensionChanged += HandleAddinManagerAddinEngineExtensionChanged;
|
||||
m_Server = server;
|
||||
|
||||
m_IntegrationServerConfig = config.Configs["IntegrationService"];
|
||||
|
@ -102,6 +113,10 @@ namespace OpenSim.Services.IntegrationService
|
|||
AddinManager.Registry.Update ();
|
||||
suppress_console_output_(false);
|
||||
|
||||
|
||||
AddinManager.AddExtensionNodeHandler ("/OpenSim/IntegrationService", OnExtensionChanged);
|
||||
|
||||
|
||||
foreach (IntegrationPlugin cmd in AddinManager.GetExtensionObjects("/OpenSim/IntegrationService"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
return new IniConfigSource();
|
||||
|
@ -169,6 +189,30 @@ namespace OpenSim.Services.IntegrationService
|
|||
+ 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)
|
||||
{
|
||||
m_log.Info ("[INTEGRATION SERVICE]: Plugin Loaded: " + args.AddinId);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
@ -260,11 +261,19 @@ namespace OpenSim.Services.IntegrationService
|
|||
m_Registry.Update();
|
||||
}
|
||||
|
||||
// Show plugin info
|
||||
public string AddinInfo(string[] args)
|
||||
{
|
||||
Addin[] addins = GetSortedAddinList("IntegrationPlugin");
|
||||
|
||||
string id = args[2];
|
||||
Addin addin = Registry.GetAddin(id, true);
|
||||
int n = Convert.ToInt16(args[2]);
|
||||
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}",
|
||||
addin.Name, addin.Description.Url,
|
||||
addin.Description.FileName);
|
||||
|
@ -304,16 +313,33 @@ namespace OpenSim.Services.IntegrationService
|
|||
|
||||
Addin addin = addins[n];
|
||||
addin.Enabled = true;
|
||||
AddinManager.Registry.EnableAddin(addin.Id);
|
||||
AddinManager.Registry.Update();
|
||||
AddinManager.AddinEngine.LoadAddin(null, addin.Id);
|
||||
return;
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
list.AddRange(m_Registry.GetAddins());
|
||||
ArrayList xlist = new ArrayList();
|
||||
|
||||
|
||||
|
||||
foreach (Addin addin in list)
|
||||
{
|
||||
if (addin.Description.Category == category)
|
||||
|
|
Loading…
Reference in New Issue