Permalink
Browse files

Removed caching of assemblies

  • Loading branch information...
1 parent dad9530 commit 9257b5426dde0af2ec0bf89488460820d3d16b6c @libardo libardo committed Aug 14, 2012
@@ -203,14 +203,15 @@
<xs:attribute name="assembly" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
- <xs:element name="add" maxOccurs="unbounded">
+ <xs:element name="add" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="assembly" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="restrictToLoadingPattern" type="xs:string" use="optional" />
<xs:attribute name="skipLoadingPattern" type="xs:string" use="optional" />
+ <xs:attribute name="enableTypeCache" type="xs:boolean" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="globalization" minOccurs="0">
@@ -264,7 +265,7 @@
<xs:element name="components" minOccurs="0">
<xs:complexType>
<xs:sequence>
- <xs:element name="add" maxOccurs="unbounded">
+ <xs:element name="add" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="service" type="xs:string" use="required" />
<xs:attribute name="implementation" type="xs:string" use="required" />
@@ -350,7 +351,7 @@
<xs:element name="hibernateProperties" minOccurs="0">
<xs:complexType>
<xs:sequence>
- <xs:element name="add" maxOccurs="unbounded">
+ <xs:element name="add" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="value" type="xs:string" use="required" />
@@ -362,7 +363,7 @@
<xs:element name="mappings" minOccurs="0">
<xs:complexType>
<xs:sequence>
- <xs:element name="add" maxOccurs="unbounded">
+ <xs:element name="add" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>
@@ -13,5 +13,10 @@ public class AttributeInfo<T>
/// <summary>The particular type the attribute was describing.</summary>
public Type DecoratedType { get; set; }
+
+ public override string ToString()
+ {
+ return "[" + typeof(T).Name + "] " + DecoratedType != null ? DecoratedType.Name : "(null)";
+ }
}
}
@@ -34,7 +34,7 @@ public virtual void Configure(IEngine engine, EventBroker broker, ConfigurationM
AddComponentInstance(engine.Container, broker);
engine.Container.AddComponent("n2.tempHelper", typeof(BasicTemporaryFileHelper), typeof(BasicTemporaryFileHelper));
- engine.Container.AddComponent("n2.assemblyCache", typeof(TypeCache), typeof(TypeCache));
+ engine.Container.AddComponent("n2.typeCache", typeof(TypeCache), typeof(TypeCache));
engine.Container.AddComponent("n2.typeFinder", typeof(ITypeFinder), typeof(WebAppTypeFinder));
engine.Container.AddComponent("n2.webContext", typeof(N2.Web.IWebContext), typeof(N2.Web.AdaptiveContext));
engine.Container.AddComponent("n2.serviceRegistrator", typeof(ServiceRegistrator), typeof(ServiceRegistrator));
@@ -81,7 +81,7 @@ private IEnumerable<CachedAssembly> GetCache(Func<IEnumerable<Assembly>> factory
var path = GetAssemblyCachePath();
- var assemblies = new List<CachedAssembly>();
+ var assemblies = factory().Select(a => new CachedAssembly { Assembly = a, ModuleId = a.ManifestModule.ModuleVersionId }).ToList();
if (File.Exists(path))
{
lock (this)
@@ -97,41 +97,6 @@ private IEnumerable<CachedAssembly> GetCache(Func<IEnumerable<Assembly>> factory
.GroupBy(setting => setting.Key)
.ToDictionary(setting => setting.Key, setting => setting.Select(s => s.Value));
- if (!settings.ContainsKey("assembly") || !settings.ContainsKey("timestamp"))
- {
- assemblies = CreateCachedAssemblies(factory, "no assembly/timestamp settings in file");
- }
- else
- {
- var timestamp = DateTime.Parse(settings["timestamp"].FirstOrDefault());
- if (GetProbingPaths().SelectMany(pp => new DirectoryInfo(pp).GetFiles("*.dll")).Any(fi => timestamp < fi.LastWriteTimeUtc))
- {
- assemblies = CreateCachedAssemblies(factory, "assemblies newer than timestamp " + timestamp);
- }
- else
- {
- foreach (var value in settings["assembly"])
- {
- var semicolonIndex = value.IndexOf(';');
- if (semicolonIndex < 0)
- {
- assemblies = CreateCachedAssemblies(factory, "invalid entry in cache file");
- break;
- }
- var assembly = Assembly.Load(value.Substring(semicolonIndex + 1));
- if (assembly == null)
- {
- assemblies = CreateCachedAssemblies(factory, "unable to load " + value);
- break;
- }
-
- var moduleVersionId = assembly.ManifestModule.ModuleVersionId;
- logger.DebugFormat("Adding assembly {0} with module version id {1}", assembly, moduleVersionId);
- assemblies.Add(new CachedAssembly { Assembly = assembly, ModuleId = moduleVersionId });
- }
- }
- }
-
foreach (var assemblyWithQueries in assemblies)
{
if (settings.ContainsKey(assemblyWithQueries.ModuleId.ToString()))
@@ -161,21 +126,17 @@ private IEnumerable<CachedAssembly> GetCache(Func<IEnumerable<Assembly>> factory
}
}
}
- else
- {
- assemblies = CreateCachedAssemblies(factory, "no cache on disk");
- }
return cache = assemblies;
}
- private List<CachedAssembly> CreateCachedAssemblies(Func<IEnumerable<Assembly>> factory, string reason)
- {
- logger.InfoFormat("Retrieving assemblies from factory due to {0}", reason);
- var assemblies = factory().Select(a => new CachedAssembly { Assembly = a, ModuleId = a.ManifestModule.ModuleVersionId }).ToList();
- logger.DebugFormat("Got {0} assemblies", assemblies.Count);
- return assemblies;
- }
+ //private List<CachedAssembly> CreateCachedAssemblies(Func<IEnumerable<Assembly>> factory, string reason)
+ //{
+ // logger.InfoFormat("Retrieving assemblies from factory due to {0}", reason);
+ // var assemblies = factory().Select(a => new CachedAssembly { Assembly = a, ModuleId = a.ManifestModule.ModuleVersionId }).ToList();
+ // logger.DebugFormat("Got {0} assemblies", assemblies.Count);
+ // return assemblies;
+ //}
private void SaveCache()
{
@@ -39,7 +39,7 @@
<add key="ci_repo" service="N2.Persistence.IRepository`1[[N2.ContentItem, N2]]" implementation="N2.Tests.Fakes.FakeRepository`1[[N2.ContentItem, N2]], N2.Tests" />
<add key="ci_nhrepo" service="N2.Persistence.NH.INHRepository`1[[N2.ContentItem, N2]]" implementation="N2.Tests.Fakes.FakeRepository`1[[N2.ContentItem, N2]], N2.Tests" />
</components>
- <assemblies>
+ <assemblies enableTypeCache="false">
<clear/>
</assemblies>
</engine>
@@ -64,7 +64,7 @@
<add service="N2.Integrity.IIntegrityManager, N2" implementation="N2.Tests.Fakes.FakeIntegrityManager, N2.Tests"/>
<add service="N2.Persistence.NH.ISessionProvider, N2" implementation="N2.Tests.Fakes.FakeSessionProvider, N2.Tests" />
</components>
- <assemblies>
+ <assemblies enableTypeCache="false">
<remove assembly="N2.Management" />
</assemblies>
<definitions defineUnattributedTypes="true" />
@@ -99,7 +99,7 @@
</web>
</host>
<engine>
- <assemblies>
+ <assemblies enableTypeCache="false">
<clear/>
</assemblies>
</engine>

0 comments on commit 9257b54

Please sign in to comment.