mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fix enable feature from command line
If we enable a feature from the command line, we need the host to recompute it's list of shell topologies on the next request of the web application. We enable this by making the OrchardHost watch for file changes on the "cache.dat" file (topology cache) --HG-- branch : dev
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Orchard.Environment {
|
|||||||
private readonly ControllerBuilder _controllerBuilder;
|
private readonly ControllerBuilder _controllerBuilder;
|
||||||
private readonly IShellSettingsManager _shellSettingsManager;
|
private readonly IShellSettingsManager _shellSettingsManager;
|
||||||
private readonly IShellContextFactory _shellContextFactory;
|
private readonly IShellContextFactory _shellContextFactory;
|
||||||
|
private readonly IShellDescriptorCache _shellDescriptorCache;
|
||||||
private readonly IRunningShellTable _runningShellTable;
|
private readonly IRunningShellTable _runningShellTable;
|
||||||
private readonly IProcessingEngine _processingEngine;
|
private readonly IProcessingEngine _processingEngine;
|
||||||
private readonly IExtensionLoaderCoordinator _extensionLoaderCoordinator;
|
private readonly IExtensionLoaderCoordinator _extensionLoaderCoordinator;
|
||||||
@@ -32,6 +33,7 @@ namespace Orchard.Environment {
|
|||||||
public DefaultOrchardHost(
|
public DefaultOrchardHost(
|
||||||
IShellSettingsManager shellSettingsManager,
|
IShellSettingsManager shellSettingsManager,
|
||||||
IShellContextFactory shellContextFactory,
|
IShellContextFactory shellContextFactory,
|
||||||
|
IShellDescriptorCache shellDescriptorCache,
|
||||||
IRunningShellTable runningShellTable,
|
IRunningShellTable runningShellTable,
|
||||||
IProcessingEngine processingEngine,
|
IProcessingEngine processingEngine,
|
||||||
IExtensionLoaderCoordinator extensionLoaderCoordinator,
|
IExtensionLoaderCoordinator extensionLoaderCoordinator,
|
||||||
@@ -40,6 +42,7 @@ namespace Orchard.Environment {
|
|||||||
|
|
||||||
_shellSettingsManager = shellSettingsManager;
|
_shellSettingsManager = shellSettingsManager;
|
||||||
_shellContextFactory = shellContextFactory;
|
_shellContextFactory = shellContextFactory;
|
||||||
|
_shellDescriptorCache = shellDescriptorCache;
|
||||||
_runningShellTable = runningShellTable;
|
_runningShellTable = runningShellTable;
|
||||||
_processingEngine = processingEngine;
|
_processingEngine = processingEngine;
|
||||||
_extensionLoaderCoordinator = extensionLoaderCoordinator;
|
_extensionLoaderCoordinator = extensionLoaderCoordinator;
|
||||||
@@ -149,6 +152,7 @@ namespace Orchard.Environment {
|
|||||||
_cacheManager.Get("OrchardHost_Extensions",
|
_cacheManager.Get("OrchardHost_Extensions",
|
||||||
ctx => {
|
ctx => {
|
||||||
_extensionLoaderCoordinator.MonitorExtensions(ctx.Monitor);
|
_extensionLoaderCoordinator.MonitorExtensions(ctx.Monitor);
|
||||||
|
_shellDescriptorCache.Monitor(ctx.Monitor);
|
||||||
_current = null;
|
_current = null;
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using Orchard.Caching;
|
||||||
using Orchard.Environment.Descriptor.Models;
|
using Orchard.Environment.Descriptor.Models;
|
||||||
using Orchard.FileSystems.AppData;
|
using Orchard.FileSystems.AppData;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -26,6 +27,11 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
/// Loss of storage is expected.
|
/// Loss of storage is expected.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Store(string shellName, ShellDescriptor descriptor);
|
void Store(string shellName, ShellDescriptor descriptor);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Monitor changes on the persistent storage.
|
||||||
|
/// </summary>
|
||||||
|
void Monitor(Action<IVolatileToken> monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ShellDescriptorCache : IShellDescriptorCache {
|
public class ShellDescriptorCache : IShellDescriptorCache {
|
||||||
@@ -55,7 +61,7 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
var serializer = new DataContractSerializer(typeof(ShellDescriptor));
|
var serializer = new DataContractSerializer(typeof(ShellDescriptor));
|
||||||
var reader = new StringReader(tenantNode.InnerText);
|
var reader = new StringReader(tenantNode.InnerText);
|
||||||
using (var xmlReader = XmlReader.Create(reader)) {
|
using (var xmlReader = XmlReader.Create(reader)) {
|
||||||
return (ShellDescriptor) serializer.ReadObject(xmlReader, true);
|
return (ShellDescriptor)serializer.ReadObject(xmlReader, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +79,7 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
XmlNode rootNode = xmlDocument.DocumentElement;
|
XmlNode rootNode = xmlDocument.DocumentElement;
|
||||||
foreach (XmlNode tenantNode in rootNode.ChildNodes) {
|
foreach (XmlNode tenantNode in rootNode.ChildNodes) {
|
||||||
if (String.Equals(tenantNode.Name, name, StringComparison.OrdinalIgnoreCase)) {
|
if (String.Equals(tenantNode.Name, name, StringComparison.OrdinalIgnoreCase)) {
|
||||||
var serializer = new DataContractSerializer(typeof (ShellDescriptor));
|
var serializer = new DataContractSerializer(typeof(ShellDescriptor));
|
||||||
var writer = new StringWriter();
|
var writer = new StringWriter();
|
||||||
using (var xmlWriter = XmlWriter.Create(writer)) {
|
using (var xmlWriter = XmlWriter.Create(writer)) {
|
||||||
serializer.WriteObject(xmlWriter, descriptor);
|
serializer.WriteObject(xmlWriter, descriptor);
|
||||||
@@ -98,6 +104,10 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
_appDataFolder.CreateFile(DescriptorCacheFileName, saveWriter.ToString());
|
_appDataFolder.CreateFile(DescriptorCacheFileName, saveWriter.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Monitor(Action<IVolatileToken> monitor) {
|
||||||
|
monitor(_appDataFolder.WhenPathChanges(DescriptorCacheFileName));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void VerifyCacheFile() {
|
private void VerifyCacheFile() {
|
||||||
|
Reference in New Issue
Block a user