diff --git a/umbraco/cms/Actions/Action.cs b/umbraco/cms/Actions/Action.cs index 91824213d0..93d54df8fc 100644 --- a/umbraco/cms/Actions/Action.cs +++ b/umbraco/cms/Actions/Action.cs @@ -27,15 +27,33 @@ namespace umbraco.BusinessLogic.Actions /// public class Action { - private static readonly List _actions = new List(); - private static readonly Dictionary _actionJs = new Dictionary(); - private static readonly List _actionHandlers = new List(); + private static List _actions = new List(); + private static List _actionHandlers = new List(); + private static readonly List _actionJSReference = new List(); + private static readonly Dictionary _actionJs = new Dictionary(); + + private static readonly object m_Lock = new object(); + private static readonly object m_LockerReRegister = new object(); static Action() { - RegisterIActions(); - RegisterIActionHandlers(); + ReRegisterActionsAndHandlers(); + } + + /// + /// This is used when an IAction or IActionHandler is installed into the system + /// and needs to be loaded into memory. + /// + public static void ReRegisterActionsAndHandlers() + { + lock (m_Lock) + { + _actions.Clear(); + _actionHandlers.Clear(); + RegisterIActions(); + RegisterIActionHandlers(); + } } /// @@ -43,17 +61,20 @@ namespace umbraco.BusinessLogic.Actions /// private static void RegisterIActionHandlers() { - if (_actionHandlers.Count > 0) - return; - List foundIActionHandlers = TypeFinder.FindClassesOfType(true); - foreach (Type type in foundIActionHandlers) + if (_actionHandlers.Count == 0) { - IActionHandler typeInstance; - typeInstance = Activator.CreateInstance(type) as IActionHandler; - if (typeInstance != null) - _actionHandlers.Add(typeInstance); + + List foundIActionHandlers = TypeFinder.FindClassesOfType(true); + foreach (Type type in foundIActionHandlers) + { + IActionHandler typeInstance; + typeInstance = Activator.CreateInstance(type) as IActionHandler; + if (typeInstance != null) + _actionHandlers.Add(typeInstance); + } } + } /// @@ -61,28 +82,29 @@ namespace umbraco.BusinessLogic.Actions /// private static void RegisterIActions() { - if (_actions.Count > 0) - return; - List foundIActions = TypeFinder.FindClassesOfType(true); - foreach (Type type in foundIActions) + if (_actions.Count == 0) { - IAction typeInstance; - PropertyInfo instance = type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static); - //if the singletone initializer is not found, try simply creating an instance of the IAction if it supports public constructors - if (instance == null) - typeInstance = Activator.CreateInstance(type) as IAction; - else - typeInstance = instance.GetValue(null, null) as IAction; - - if (typeInstance != null) + List foundIActions = TypeFinder.FindClassesOfType(true); + foreach (Type type in foundIActions) { - if (!string.IsNullOrEmpty(typeInstance.JsSource)) - _actionJSReference.Add(typeInstance.JsSource); - _actions.Add(typeInstance); - } + IAction typeInstance; + PropertyInfo instance = type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static); + //if the singletone initializer is not found, try simply creating an instance of the IAction if it supports public constructors + if (instance == null) + typeInstance = Activator.CreateInstance(type) as IAction; + else + typeInstance = instance.GetValue(null, null) as IAction; + if (typeInstance != null) + { + if (!string.IsNullOrEmpty(typeInstance.JsSource)) + _actionJSReference.Add(typeInstance.JsSource); + _actions.Add(typeInstance); + } + } } + } /// diff --git a/umbraco/presentation/umbraco/developer/Packages/installedPackage.aspx.cs b/umbraco/presentation/umbraco/developer/Packages/installedPackage.aspx.cs index b47439c15d..071ca6bf8b 100644 --- a/umbraco/presentation/umbraco/developer/Packages/installedPackage.aspx.cs +++ b/umbraco/presentation/umbraco/developer/Packages/installedPackage.aspx.cs @@ -18,6 +18,7 @@ using runtimeMacro = umbraco.macro; using System.Xml; using umbraco.IO; using umbraco.cms.presentation.Trees; +using BizLogicAction = umbraco.BusinessLogic.Actions.Action; namespace umbraco.presentation.developer.packages { @@ -567,6 +568,8 @@ namespace umbraco.presentation.developer.packages TreeDefinitionCollection.Instance.ReRegisterTrees(); + BizLogicAction.ReRegisterActionsAndHandlers(); + } private bool isManifestEmpty() diff --git a/umbraco/presentation/umbraco/developer/Packages/installer.aspx.cs b/umbraco/presentation/umbraco/developer/Packages/installer.aspx.cs index 31b154947a..c64f125608 100644 --- a/umbraco/presentation/umbraco/developer/Packages/installer.aspx.cs +++ b/umbraco/presentation/umbraco/developer/Packages/installer.aspx.cs @@ -13,6 +13,7 @@ using System.Xml.XPath; using umbraco.BasePages; using umbraco.IO; using umbraco.cms.presentation.Trees; +using BizLogicAction = umbraco.BusinessLogic.Actions.Action; namespace umbraco.presentation.developer.packages { @@ -254,6 +255,8 @@ namespace umbraco.presentation.developer.packages TreeDefinitionCollection.Instance.ReRegisterTrees(); + BizLogicAction.ReRegisterActionsAndHandlers(); + break; default: break;