Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/Loader.cs (14653 => 14654)
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/Loader.cs 2009-08-27 22:58:55 UTC (rev 14653)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/Loader.cs 2009-08-28 07:57:19 UTC (rev 14654)
@@ -133,7 +133,17 @@
}
static void watcher_Changed(object sender, FileSystemEventArgs e) {
- Action<string> queueFile = x => { lock (watcherLock) { watcherFiles.Add(x); } };
+ Action<string> queueFile = fileName => {
+ var currentPi = pluginInfos.FirstOrDefault(p => string.Compare(fileName, p.FileName, StringComparison.OrdinalIgnoreCase) == 0);
+ if (currentPi != null) {
+ var noReload = currentPi.Manager.ApiExecutors.Any(x => (x.PluginOptions & PluginOptions.NoAutoReload) == PluginOptions.NoAutoReload) ||
+ currentPi.Manager.AppExecutors.Any(x => (x.PluginOptions & PluginOptions.NoAutoReload) == PluginOptions.NoAutoReload);
+ if (noReload) return;
+ }
+ lock (watcherLock) {
+ watcherFiles.Add(fileName);
+ }
+ };
try {
if (!initialLoadComplete) return;
var file = e.FullPath;
Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/PluginInterfaces.cs (14653 => 14654)
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/PluginInterfaces.cs 2009-08-27 22:58:55 UTC (rev 14653)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/PluginInterfaces.cs 2009-08-28 07:57:19 UTC (rev 14654)
@@ -88,4 +88,14 @@
bool Load();
}
+ [Flags]
+ public enum PluginOptions {
+ None = 0,
+ NoAutoReload = 1,
+ }
+
+ public interface IPluginOptionsProvider {
+ PluginOptions GetOptions();
+ }
+
}
Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/PluginManager.cs (14653 => 14654)
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/PluginManager.cs 2009-08-27 22:58:55 UTC (rev 14653)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/PluginManager.cs 2009-08-28 07:57:19 UTC (rev 14654)
@@ -51,11 +51,15 @@
public string Name { get { return name; } }
readonly string name;
- protected PluginExecutor(string name, List<string> aliases) {
+ public PluginOptions PluginOptions { get { return pluginOptions; } }
+ readonly PluginOptions pluginOptions;
+
+ protected PluginExecutor(string name, List<string> aliases, PluginOptions pluginOptions) {
if (string.IsNullOrEmpty(name)) throw new ArgumentException("No name provided.");
if (aliases == null || aliases.Count == 0) throw new ArgumentException("No aliases provided.");
this.name = name;
this.aliases = aliases.Distinct().ToList();
+ this.pluginOptions = pluginOptions;
}
int useCount = 0;
@@ -85,8 +89,8 @@
readonly Func<IAppPlugin> createPlugin;
- public AppPluginExecutor(string name, List<string> aliases, Func<IAppPlugin> creator)
- : base(name, aliases) {
+ public AppPluginExecutor(string name, List<string> aliases, Func<IAppPlugin> creator, PluginOptions pluginOptions)
+ : base(name, aliases, pluginOptions) {
if (creator == null) throw new ArgumentNullException("Creator cannot be null.");
this.createPlugin = creator;
}
@@ -117,8 +121,8 @@
readonly Func<IApiPlugin> createPlugin;
- public ApiPluginExecutor(string name, List<string> aliases, Func<IApiPlugin> creator)
- : base(name, aliases) {
+ public ApiPluginExecutor(string name, List<string> aliases, Func<IApiPlugin> creator, PluginOptions pluginOptions)
+ : base(name, aliases, pluginOptions) {
if (creator == null) throw new ArgumentNullException("Creator cannot be null.");
this.createPlugin = creator;
}
@@ -196,7 +200,7 @@
var pluginTypes = allTypes.Where(x => ty.IsAssignableFrom(x) && !x.IsAbstract).ToList();
if (pluginTypes.Count == 0) return true;
foreach (var pt in pluginTypes) {
- var load = ((ILoadNotificationPlugin)Activator.CreateInstance(pt, false));
+ var load = ((ILoadNotificationPlugin)Activator.CreateInstance(pt, true));
if (!load.Load()) {
Log.WriteLine(LogLevel.Notice, "Type {0} requested no loading. Assembly will not be loaded.", pt.FullName);
return false;
@@ -205,20 +209,29 @@
return true;
}
- protected void AddApiPlugins(Type[] allTypes) {
+ protected PluginOptions GetOptions(Type[] allTypes) {
+ var ty = typeof(IPluginOptionsProvider);
+ var pluginTypes = allTypes.Where(x => ty.IsAssignableFrom(x) && !x.IsAbstract).ToList();
+ return pluginTypes.Aggregate(PluginOptions.None, (opts, t) => {
+ var x = ((IPluginOptionsProvider)Activator.CreateInstance(t, true));
+ return opts | x.GetOptions();
+ });
+ }
+
+ protected void AddApiPlugins(Type[] allTypes, PluginOptions pluginOptions) {
var iApiTy = typeof(IApiPlugin);
foreach (var ty in allTypes.Where(x => iApiTy.IsAssignableFrom(x) && !x.IsAbstract)) {
var del = CreateConstructorDelegate<IApiPlugin>(ty);
- var exec = new ApiPluginExecutor(ty.FullName, new List<string> { ty.FullName, ty.Name }, del);
+ var exec = new ApiPluginExecutor(ty.FullName, new List<string> { ty.FullName, ty.Name }, del, pluginOptions);
this.ApiExecutors.Add(exec);
}
}
- protected void AddAppPlugins(Type[] allTypes) {
+ protected void AddAppPlugins(Type[] allTypes, PluginOptions pluginOptions) {
var iAppTy = typeof(IAppPlugin);
foreach (var ty in allTypes.Where(x => iAppTy.IsAssignableFrom(x) && !x.IsAbstract)) {
var del = CreateConstructorDelegate<IAppPlugin>(ty);
- var exec = new AppPluginExecutor(ty.FullName, new List<string> { ty.FullName, ty.Name }, del);
+ var exec = new AppPluginExecutor(ty.FullName, new List<string> { ty.FullName, ty.Name }, del, pluginOptions);
this.AppExecutors.Add(exec);
}
}
@@ -283,9 +296,11 @@
var allTypes = asm.GetExportedTypes();
if (!RunLoadNotify(allTypes)) return false;
- AddApiPlugins(allTypes);
- AddAppPlugins(allTypes);
+ var opts = GetOptions(allTypes);
+ AddApiPlugins(allTypes, opts);
+ AddAppPlugins(allTypes, opts);
+
return true;
}
Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/ScriptPluginManager.cs (14653 => 14654)
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/ScriptPluginManager.cs 2009-08-27 22:58:55 UTC (rev 14653)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/ScriptPluginManager.cs 2009-08-28 07:57:19 UTC (rev 14654)
@@ -161,14 +161,15 @@
if (!RunLoadNotify(allTypes)) return false;
// Scripts can specify classes too
- AddApiPlugins(allTypes);
- AddAppPlugins(allTypes);
+ var opts = GetOptions(allTypes);
+ AddApiPlugins(allTypes, opts);
+ AddAppPlugins(allTypes, opts);
// Add the script executors
var name = Path.GetFileName(fileName);
var aliases = new List<string> { name };
- this.ApiExecutors.Add(new ApiPluginExecutor(name, aliases, () => new ScriptApiWrapper(entryPoint)));
- this.AppExecutors.Add(new AppPluginExecutor(name, aliases, () => new ScriptAppWrapper(entryPoint)));
+ this.ApiExecutors.Add(new ApiPluginExecutor(name, aliases, () => new ScriptApiWrapper(entryPoint), opts));
+ this.AppExecutors.Add(new AppPluginExecutor(name, aliases, () => new ScriptAppWrapper(entryPoint), opts));
return true;
}