diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs
index eda2cf494c..9884fab1ce 100644
--- a/src/Umbraco.Core/CoreBootManager.cs
+++ b/src/Umbraco.Core/CoreBootManager.cs
@@ -30,10 +30,21 @@ namespace Umbraco.Core
private bool _isInitialized = false;
private bool _isStarted = false;
private bool _isComplete = false;
-
+ private readonly UmbracoApplicationBase _umbracoApplication;
protected ApplicationContext ApplicationContext { get; private set; }
- public virtual IBootManager Initialize()
+ protected UmbracoApplicationBase UmbracoApplication
+ {
+ get { return _umbracoApplication; }
+ }
+
+ public CoreBootManager(UmbracoApplicationBase umbracoApplication)
+ {
+ if (umbracoApplication == null) throw new ArgumentNullException("umbracoApplication");
+ _umbracoApplication = umbracoApplication;
+ }
+
+ public virtual IBootManager Initialize()
{
if (_isInitialized)
throw new InvalidOperationException("The boot manager has already been initialized");
@@ -56,15 +67,41 @@ namespace Umbraco.Core
//initialize the DatabaseContext
dbContext.Initialize();
+ InitializeApplicationEventsResolver();
+
InitializeResolvers();
+
+ //now we need to call the initialize methods
+ ApplicationEventsResolver.Current.ApplicationEventHandlers
+ .ForEach(x => x.OnApplicationInitialized(UmbracoApplication, ApplicationContext));
+
_isInitialized = true;
return this;
}
+ ///
+ /// Special method to initialize the ApplicationEventsResolver and any modifications required for it such
+ /// as adding custom types to the resolver.
+ ///
+ protected virtual void InitializeApplicationEventsResolver()
+ {
+ //find and initialize the application startup handlers, we need to initialize this resolver here because
+ //it is a special resolver where they need to be instantiated first before any other resolvers in order to bind to
+ //events and to call their events during bootup.
+ //ApplicationStartupHandler.RegisterHandlers();
+ //... and set the special flag to let us resolve before frozen resolution
+ ApplicationEventsResolver.Current = new ApplicationEventsResolver(
+ PluginManager.Current.ResolveApplicationStartupHandlers())
+ {
+ CanResolveBeforeFrozen = true
+ };
+ }
+
///
- /// Fires after initialization and calls the callback to allow for customizations to occur
+ /// Fires after initialization and calls the callback to allow for customizations to occur &
+ /// Ensure that the OnApplicationStarting methods of the IApplicationEvents are called
///
///
///
@@ -78,6 +115,10 @@ namespace Umbraco.Core
afterStartup(ApplicationContext.Current);
}
+ //call OnApplicationStarting of each application events handler
+ ApplicationEventsResolver.Current.ApplicationEventHandlers
+ .ForEach(x => x.OnApplicationStarting(UmbracoApplication, ApplicationContext));
+
_isStarted = true;
return this;
@@ -104,8 +145,15 @@ namespace Umbraco.Core
afterComplete(ApplicationContext.Current);
}
+ //call OnApplicationStarting of each application events handler
+ ApplicationEventsResolver.Current.ApplicationEventHandlers
+ .ForEach(x => x.OnApplicationStarted(UmbracoApplication, ApplicationContext));
+
_isComplete = true;
+ // we're ready to serve content!
+ ApplicationContext.IsReady = true;
+
return this;
}
diff --git a/src/Umbraco.Web/IApplicationEventHandler.cs b/src/Umbraco.Core/IApplicationEventHandler.cs
similarity index 60%
rename from src/Umbraco.Web/IApplicationEventHandler.cs
rename to src/Umbraco.Core/IApplicationEventHandler.cs
index 63c34d1589..e382aa8568 100644
--- a/src/Umbraco.Web/IApplicationEventHandler.cs
+++ b/src/Umbraco.Core/IApplicationEventHandler.cs
@@ -1,7 +1,6 @@
-using Umbraco.Core;
using umbraco.interfaces;
-namespace Umbraco.Web
+namespace Umbraco.Core
{
///
/// Custom IApplicationStartupHandler that auto subscribes to the applications events
@@ -11,23 +10,23 @@ namespace Umbraco.Web
///
/// ApplicationContext is created and other static objects that require initialization have been setup
///
- ///
+ ///
///
- void OnApplicationInitialized(UmbracoApplication httpApplication, ApplicationContext applicationContext);
+ void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext);
///
/// All resolvers have been initialized but resolution is not frozen so they can be modified in this method
///
- ///
+ ///
///
- void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext);
+ void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext);
///
/// Bootup is completed, this allows you to perform any other bootup logic required for the application.
/// Resolution is frozen so now they can be used to resolve instances.
///
- ///
+ ///
///
- void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext);
+ void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext);
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/ApplicationEventsResolver.cs b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
similarity index 90%
rename from src/Umbraco.Web/ApplicationEventsResolver.cs
rename to src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
index 93edaae441..7f5b6f6365 100644
--- a/src/Umbraco.Web/ApplicationEventsResolver.cs
+++ b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Umbraco.Core.ObjectResolution;
using umbraco.interfaces;
-namespace Umbraco.Web
+namespace Umbraco.Core.ObjectResolution
{
///
/// A resolver to return all IApplicationEvents objects
diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs
index 4f1f18c2ab..f0514af628 100644
--- a/src/Umbraco.Core/PluginManager.cs
+++ b/src/Umbraco.Core/PluginManager.cs
@@ -396,6 +396,15 @@ namespace Umbraco.Core
private readonly HashSet _types = new HashSet();
private IEnumerable _assemblies;
+ ///
+ /// Returns all available IApplicationStartupHandler objects
+ ///
+ ///
+ internal IEnumerable ResolveApplicationStartupHandlers()
+ {
+ return ResolveTypes();
+ }
+
///
/// Returns all classes attributed with XsltExtensionAttribute attribute
///
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 96e43ad6a7..2d8ea1de40 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -137,6 +137,7 @@
+
@@ -195,6 +196,7 @@
+
@@ -650,6 +652,7 @@
+
diff --git a/src/Umbraco.Core/UmbracoApplicationBase.cs b/src/Umbraco.Core/UmbracoApplicationBase.cs
new file mode 100644
index 0000000000..df241c2bd3
--- /dev/null
+++ b/src/Umbraco.Core/UmbracoApplicationBase.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Web;
+using System.Web.Hosting;
+using Umbraco.Core.Logging;
+
+namespace Umbraco.Core
+{
+
+ ///
+ /// The abstract class for the Umbraco HttpApplication
+ ///
+ ///
+ /// This is exposed in the core so that we can have the IApplicationEventHandler in the core project so that
+ /// IApplicationEventHandler's can fire/execute outside of the web contenxt (i.e. in console applications)
+ ///
+ public abstract class UmbracoApplicationBase : System.Web.HttpApplication
+ {
+
+ public static event EventHandler ApplicationStarting;
+ public static event EventHandler ApplicationStarted;
+
+ ///
+ /// Boots up the Umbraco application
+ ///
+ internal void StartApplication(object sender, EventArgs e)
+ {
+ //boot up the application
+ GetBootManager()
+ .Initialize()
+ .Startup(appContext => OnApplicationStarting(sender, e))
+ .Complete(appContext => OnApplicationStarted(sender, e));
+ }
+
+ ///
+ /// Initializes the Umbraco application
+ ///
+ ///
+ ///
+ protected void Application_Start(object sender, EventArgs e)
+ {
+ StartApplication(sender, e);
+ }
+
+ ///
+ /// Developers can override this method to modify objects on startup
+ ///
+ ///
+ ///
+ protected virtual void OnApplicationStarting(object sender, EventArgs e)
+ {
+ if (ApplicationStarting != null)
+ ApplicationStarting(sender, e);
+ }
+
+ ///
+ /// Developers can override this method to do anything they need to do once the application startup routine is completed.
+ ///
+ ///
+ ///
+ protected virtual void OnApplicationStarted(object sender, EventArgs e)
+ {
+ if (ApplicationStarted != null)
+ ApplicationStarted(sender, e);
+ }
+
+ ///
+ /// A method that can be overridden to invoke code when the application has an error.
+ ///
+ ///
+ ///
+ protected virtual void OnApplicationError(object sender, EventArgs e)
+ {
+
+ }
+
+ protected void Application_Error(object sender, EventArgs e)
+ {
+ // Code that runs when an unhandled error occurs
+
+ // Get the exception object.
+ var exc = Server.GetLastError();
+
+ // Ignore HTTP errors
+ if (exc.GetType() == typeof(HttpException))
+ {
+ return;
+ }
+
+ LogHelper.Error("An unhandled exception occurred", exc);
+
+ OnApplicationError(sender, e);
+ }
+
+ ///
+ /// A method that can be overridden to invoke code when the application shuts down.
+ ///
+ ///
+ ///
+ protected virtual void OnApplicationEnd(object sender, EventArgs e)
+ {
+
+ }
+
+ protected void Application_End(object sender, EventArgs e)
+ {
+ if (SystemUtilities.GetCurrentTrustLevel() == AspNetHostingPermissionLevel.Unrestricted)
+ {
+ LogHelper.Info("Application shutdown. Reason: " + HostingEnvironment.ShutdownReason);
+ }
+ OnApplicationEnd(sender, e);
+ }
+
+ protected abstract IBootManager GetBootManager();
+
+ }
+}
diff --git a/src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs b/src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs
new file mode 100644
index 0000000000..92212506ba
--- /dev/null
+++ b/src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Web;
+using NUnit.Framework;
+using Umbraco.Core;
+using Umbraco.Core.ObjectResolution;
+
+namespace Umbraco.Tests.BootManagers
+{
+ [TestFixture]
+ public class CoreBootManagerTests
+ {
+
+ private TestApp _testApp;
+
+ [SetUp]
+ public void Setup()
+ {
+ _testApp = new TestApp();
+ }
+
+ ///
+ /// test application using a CoreBootManager instance to boot
+ ///
+ public class TestApp : UmbracoApplicationBase
+ {
+ protected override IBootManager GetBootManager()
+ {
+ return new TestBootManager(this);
+ }
+ }
+
+ ///
+ /// Test boot manager to add a custom application event handler
+ ///
+ public class TestBootManager : CoreBootManager
+ {
+ public TestBootManager(UmbracoApplicationBase umbracoApplication)
+ : base(umbracoApplication)
+ {
+ }
+
+ protected override void InitializeApplicationEventsResolver()
+ {
+ //create an empty resolver so we can add our own custom ones (don't type find)
+ ApplicationEventsResolver.Current = new ApplicationEventsResolver(
+ Enumerable.Empty())
+ {
+ CanResolveBeforeFrozen = true
+ };
+ ApplicationEventsResolver.Current.AddType();
+ }
+ }
+
+ ///
+ /// test event handler
+ ///
+ public class TestApplicationEventHandler : IApplicationEventHandler
+ {
+ public static bool Initialized = false;
+ public static bool Starting = false;
+ public static bool Started = false;
+
+ public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
+ {
+ Initialized = true;
+ }
+
+ public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
+ {
+ Starting = true;
+ }
+
+ public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
+ {
+ Started = true;
+ }
+ }
+
+ [Test]
+ public void Handle_IApplicationEventHandler_Objects_Outside_Web_Context()
+ {
+ _testApp.StartApplication(_testApp, new EventArgs());
+
+ Assert.IsTrue(TestApplicationEventHandler.Initialized);
+ Assert.IsTrue(TestApplicationEventHandler.Starting);
+ Assert.IsTrue(TestApplicationEventHandler.Started);
+ }
+
+ }
+}
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index a729aacabb..814bdb938e 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -123,6 +123,7 @@
+
diff --git a/src/Umbraco.Web/CacheHelperExtensions.cs b/src/Umbraco.Web/CacheHelperExtensions.cs
index 6e81bd844d..9ecc14e785 100644
--- a/src/Umbraco.Web/CacheHelperExtensions.cs
+++ b/src/Umbraco.Web/CacheHelperExtensions.cs
@@ -24,31 +24,31 @@ namespace Umbraco.Web
///
public sealed class CacheHelperApplicationEventListener : IApplicationEventHandler
{
- public void OnApplicationInitialized(UmbracoApplication httpApplication, ApplicationContext applicationContext)
+ public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
- if (ApplicationContext.Current != null)
+ if (applicationContext != null)
{
//bind to events to clear the cache, after publish, after media save and after member save
Document.AfterPublish
+= (sender, args) =>
- ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
+ applicationContext.ApplicationCache.ClearPartialViewCache();
global::umbraco.cms.businesslogic.media.Media.AfterSave
+= (sender, args) =>
- ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
+ applicationContext.ApplicationCache.ClearPartialViewCache();
global::umbraco.cms.businesslogic.member.Member.AfterSave
+= (sender, args) =>
- ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
+ applicationContext.ApplicationCache.ClearPartialViewCache();
}
}
- public void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext)
+ public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
- public void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext)
+ public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
}
diff --git a/src/Umbraco.Web/LegacyScheduledTasks.cs b/src/Umbraco.Web/LegacyScheduledTasks.cs
index 1ebf9d7903..f79b383b06 100644
--- a/src/Umbraco.Web/LegacyScheduledTasks.cs
+++ b/src/Umbraco.Web/LegacyScheduledTasks.cs
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading;
using System.Web;
using System.Web.Caching;
+using Umbraco.Core;
using Umbraco.Core.Logging;
using global::umbraco.BusinessLogic;
@@ -17,17 +18,20 @@ namespace Umbraco.Web
internal sealed class LegacyScheduledTasks : IApplicationEventHandler
{
- Timer pingTimer;
- Timer publishingTimer;
- CacheItemRemovedCallback OnCacheRemove;
+ Timer _pingTimer;
+ Timer _publishingTimer;
+ CacheItemRemovedCallback _onCacheRemove;
- public void OnApplicationInitialized(UmbracoApplication httpApplication, Core.ApplicationContext applicationContext)
+ public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, Core.ApplicationContext applicationContext)
{
// nothing yet
}
- public void OnApplicationStarting(UmbracoApplication httpApplication, Core.ApplicationContext applicationContext)
- {
+ public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, Core.ApplicationContext applicationContext)
+ {
+ if (umbracoApplication.Context == null)
+ return;
+
// time to setup the tasks
// these are the legacy tasks
@@ -35,16 +39,16 @@ namespace Umbraco.Web
// of course we should have a proper scheduler, see #U4-809
// ping/keepalive
- pingTimer = new Timer(new TimerCallback(global::umbraco.presentation.keepAliveService.PingUmbraco), httpApplication.Context, 60000, 300000);
+ _pingTimer = new Timer(new TimerCallback(global::umbraco.presentation.keepAliveService.PingUmbraco), umbracoApplication.Context, 60000, 300000);
// (un)publishing _and_ also run scheduled tasks (!)
- publishingTimer = new Timer(new TimerCallback(global::umbraco.presentation.publishingService.CheckPublishing), httpApplication.Context, 30000, 60000);
+ _publishingTimer = new Timer(new TimerCallback(global::umbraco.presentation.publishingService.CheckPublishing), umbracoApplication.Context, 30000, 60000);
// log scrubbing
AddTask(LOG_SCRUBBER_TASK_NAME, GetLogScrubbingInterval());
}
- public void OnApplicationStarted(UmbracoApplication httpApplication, Core.ApplicationContext applicationContext)
+ public void OnApplicationStarted(UmbracoApplicationBase httpApplication, Core.ApplicationContext applicationContext)
{
// nothing
}
@@ -88,10 +92,10 @@ namespace Umbraco.Web
private void AddTask(string name, int seconds)
{
- OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
+ _onCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
HttpRuntime.Cache.Insert(name, seconds, null,
DateTime.Now.AddSeconds(seconds), System.Web.Caching.Cache.NoSlidingExpiration,
- CacheItemPriority.NotRemovable, OnCacheRemove);
+ CacheItemPriority.NotRemovable, _onCacheRemove);
}
public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 5ce59b214e..24cc484f92 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -245,7 +245,6 @@
Properties\SolutionInfo.cs
-
@@ -290,7 +289,6 @@
ASPXCodeBehind
-
diff --git a/src/Umbraco.Web/UmbracoApplication.cs b/src/Umbraco.Web/UmbracoApplication.cs
index c3d32c2ce2..7a47847b5e 100644
--- a/src/Umbraco.Web/UmbracoApplication.cs
+++ b/src/Umbraco.Web/UmbracoApplication.cs
@@ -15,99 +15,12 @@ namespace Umbraco.Web
///
/// The Umbraco global.asax class
///
- public class UmbracoApplication : System.Web.HttpApplication
+ public class UmbracoApplication : UmbracoApplicationBase
{
- public UmbracoApplication()
- {
- _bootManager = new WebBootManager(this);
- }
-
- private readonly IBootManager _bootManager;
-
- public static event EventHandler ApplicationStarting;
- public static event EventHandler ApplicationStarted;
-
- ///
- /// Initializes the Umbraco application
- ///
- ///
- ///
- protected void Application_Start(object sender, EventArgs e)
- {
- //boot up the application
- _bootManager
- .Initialize()
- .Startup(appContext => OnApplicationStarting(sender, e))
- .Complete(appContext => OnApplicationStarted(sender, e));
- }
-
- ///
- /// Developers can override this method to modify objects on startup
- ///
- ///
- ///
- protected virtual void OnApplicationStarting(object sender, EventArgs e)
- {
- if (ApplicationStarting != null)
- ApplicationStarting(sender, e);
- }
-
- ///
- /// Developers can override this method to do anything they need to do once the application startup routine is completed.
- ///
- ///
- ///
- protected virtual void OnApplicationStarted(object sender, EventArgs e)
- {
- if (ApplicationStarted != null)
- ApplicationStarted(sender, e);
- }
-
- ///
- /// A method that can be overridden to invoke code when the application has an error.
- ///
- ///
- ///
- protected virtual void OnApplicationError(object sender, EventArgs e)
- {
-
- }
-
- protected void Application_Error(object sender, EventArgs e)
- {
- // Code that runs when an unhandled error occurs
-
- // Get the exception object.
- var exc = Server.GetLastError();
-
- // Ignore HTTP errors
- if (exc.GetType() == typeof(HttpException))
- {
- return;
- }
-
- LogHelper.Error("An unhandled exception occurred", exc);
-
- OnApplicationError(sender, e);
- }
-
- ///
- /// A method that can be overridden to invoke code when the application shuts down.
- ///
- ///
- ///
- protected virtual void OnApplicationEnd(object sender, EventArgs e)
- {
-
- }
-
- protected void Application_End(object sender, EventArgs e)
- {
- if (SystemUtilities.GetCurrentTrustLevel() == AspNetHostingPermissionLevel.Unrestricted)
- {
- LogHelper.Info("Application shutdown. Reason: " + HostingEnvironment.ShutdownReason);
- }
- OnApplicationEnd(sender, e);
- }
+
+ protected override IBootManager GetBootManager()
+ {
+ return new WebBootManager(this);
+ }
}
}
diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs
index 58992253ff..2127f0f014 100644
--- a/src/Umbraco.Web/WebBootManager.cs
+++ b/src/Umbraco.Web/WebBootManager.cs
@@ -7,6 +7,7 @@ using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Dynamics;
+using Umbraco.Core.ObjectResolution;
using Umbraco.Core.PropertyEditors;
using Umbraco.Web.Dictionary;
using Umbraco.Web.Media;
@@ -27,9 +28,8 @@ namespace Umbraco.Web
public class WebBootManager : CoreBootManager
{
private readonly bool _isForTesting;
- private readonly UmbracoApplication _umbracoApplication;
- public WebBootManager(UmbracoApplication umbracoApplication)
+ public WebBootManager(UmbracoApplicationBase umbracoApplication)
: this(umbracoApplication, false)
{
@@ -40,11 +40,10 @@ namespace Umbraco.Web
///
///
///
- internal WebBootManager(UmbracoApplication umbracoApplication, bool isForTesting)
+ internal WebBootManager(UmbracoApplicationBase umbracoApplication, bool isForTesting)
+ : base(umbracoApplication)
{
- _isForTesting = isForTesting;
- _umbracoApplication = umbracoApplication;
- if (umbracoApplication == null) throw new ArgumentNullException("umbracoApplication");
+ _isForTesting = isForTesting;
}
///
@@ -71,43 +70,18 @@ namespace Umbraco.Web
//set model binder
ModelBinders.Binders.Add(new KeyValuePair(typeof(RenderModel), new RenderModelBinder()));
-
- //find and initialize the application startup handlers, we need to initialize this resolver here because
- //it is a special resolver where they need to be instantiated first before any other resolvers in order to bind to
- //events and to call their events during bootup.
- //ApplicationStartupHandler.RegisterHandlers();
- //... and set the special flag to let us resolve before frozen resolution
- ApplicationEventsResolver.Current = new ApplicationEventsResolver(
- PluginManager.Current.ResolveApplicationStartupHandlers())
- {
- CanResolveBeforeFrozen = true
- };
- //add the internal types since we don't want to mark these public
- ApplicationEventsResolver.Current.AddType();
- ApplicationEventsResolver.Current.AddType();
-
- //now we need to call the initialize methods
- ApplicationEventsResolver.Current.ApplicationEventHandlers
- .ForEach(x => x.OnApplicationInitialized(_umbracoApplication, ApplicationContext));
-
return this;
}
- ///
- /// Ensure that the OnApplicationStarting methods of the IApplicationEvents are called
- ///
- ///
- ///
- public override IBootManager Startup(Action afterStartup)
- {
- base.Startup(afterStartup);
-
- //call OnApplicationStarting of each application events handler
- ApplicationEventsResolver.Current.ApplicationEventHandlers
- .ForEach(x => x.OnApplicationStarting(_umbracoApplication, ApplicationContext));
-
- return this;
- }
+ ///
+ /// Adds custom types to the ApplicationEventsResolver
+ ///
+ protected override void InitializeApplicationEventsResolver()
+ {
+ base.InitializeApplicationEventsResolver();
+ ApplicationEventsResolver.Current.AddType();
+ ApplicationEventsResolver.Current.AddType();
+ }
///
/// Ensure that the OnApplicationStarted methods of the IApplicationEvents are called
@@ -121,13 +95,6 @@ namespace Umbraco.Web
base.Complete(afterComplete);
- //call OnApplicationStarting of each application events handler
- ApplicationEventsResolver.Current.ApplicationEventHandlers
- .ForEach(x => x.OnApplicationStarted(_umbracoApplication, ApplicationContext));
-
- // we're ready to serve content!
- ApplicationContext.IsReady = true;
-
return this;
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Search/ExamineEvents.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Search/ExamineEvents.cs
index f122e2013b..1f1471bc7e 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/Search/ExamineEvents.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Search/ExamineEvents.cs
@@ -15,20 +15,20 @@ namespace umbraco.presentation.umbraco.Search
public class ExamineEvents : IApplicationEventHandler
{
- public void OnApplicationInitialized(UmbracoApplication httpApplication, ApplicationContext applicationContext)
+ public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
- public void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext)
+ public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
///
/// Once the app has booted, then bind to the events
///
- ///
+ ///
///
- public void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext)
+ public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
//do not continue if the app context or database is not ready
if (!applicationContext.IsConfigured || !applicationContext.DatabaseContext.IsDatabaseConfigured)
diff --git a/src/umbraco.businesslogic/PluginManagerExtensions.cs b/src/umbraco.businesslogic/PluginManagerExtensions.cs
index da8fdea46b..7a61414315 100644
--- a/src/umbraco.businesslogic/PluginManagerExtensions.cs
+++ b/src/umbraco.businesslogic/PluginManagerExtensions.cs
@@ -10,16 +10,6 @@ namespace umbraco.businesslogic
///
public static class PluginManagerExtensions
{
- ///
- /// Returns all available IApplicationStartupHandler objects
- ///
- ///
- ///
- internal static IEnumerable ResolveApplicationStartupHandlers(this PluginManager resolver)
- {
- return resolver.ResolveTypes();
- }
-
///
/// Returns all available IApplication in application
///