Merge pull request #44 from thomast74/ComponentScan-Logging
Enhance ComponentScan logging messages
This commit is contained in:
@@ -70,6 +70,9 @@ namespace Spring.Context.Attributes
|
||||
{
|
||||
var definition = new ScannedGenericObjectDefinition(type, Defaults);
|
||||
string objectName = ObjectNameGenerator.GenerateObjectName(definition, registry);
|
||||
string fullname = type.FullName;
|
||||
|
||||
Logger.Debug(m => m("Register Type: {0} with object name '{1}'", fullname, objectName));
|
||||
registry.RegisterObjectDefinition(objectName, definition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +179,7 @@ namespace Spring.Context.Attributes
|
||||
{
|
||||
if (IsCompoundPredicateSatisfiedBy(type))
|
||||
{
|
||||
Logger.Debug(m => m("Satisfied Type: {0}", type.FullName));
|
||||
types.Add(type);
|
||||
}
|
||||
}
|
||||
@@ -274,6 +275,9 @@ namespace Spring.Context.Attributes
|
||||
|
||||
if (null != loadedAssembly)
|
||||
{
|
||||
string fullname = loadedAssembly.FullName;
|
||||
Logger.Debug(m => m("Add Assembly: {0}", fullname));
|
||||
|
||||
assemblies.Add(loadedAssembly);
|
||||
}
|
||||
}
|
||||
@@ -313,9 +317,12 @@ namespace Spring.Context.Attributes
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerable<Assembly> ApplyAssemblyFiltersTo(IEnumerable<Assembly> assemblyCandidates)
|
||||
{
|
||||
return
|
||||
assemblyCandidates.Where(IsIncludedAssembly).
|
||||
AsEnumerable();
|
||||
var filteredAssemblies = assemblyCandidates.Where(IsIncludedAssembly).
|
||||
AsEnumerable();
|
||||
|
||||
Logger.Debug(m => m("Filtered Assemblies: {0}", StringUtils.ArrayToCommaDelimitedString(filteredAssemblies.ToArray())));
|
||||
|
||||
return filteredAssemblies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -351,7 +358,15 @@ namespace Spring.Context.Attributes
|
||||
/// </returns>
|
||||
protected virtual bool IsIncludedAssembly(Assembly assembly)
|
||||
{
|
||||
return AssemblyInclusionPredicates.Any(include => include(assembly));
|
||||
bool result = AssemblyInclusionPredicates.Any(include => include(assembly));
|
||||
|
||||
if (result)
|
||||
{
|
||||
string fullname = assembly.FullName;
|
||||
Logger.Debug(m => m("Include Assembly: {0}", fullname));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -52,5 +52,16 @@ namespace Spring.Context.Attributes.TypeFilters
|
||||
return (type.GetInterfaces().Any(i => i.Equals(RequiredType)) || RequiredType.Equals(type.BaseType));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A string that represents the current object.
|
||||
/// </returns>
|
||||
/// <filterpriority>2</filterpriority>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Required Type: {0}", RequiredType != null ? RequiredType.FullName : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,5 +52,17 @@ namespace Spring.Context.Attributes.TypeFilters
|
||||
return (Attribute.GetCustomAttribute(type, RequiredType) != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A string that represents the current object.
|
||||
/// </returns>
|
||||
/// <filterpriority>2</filterpriority>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Required Type: {0}", RequiredType != null ? RequiredType.FullName : "");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,17 @@ namespace Spring.Context.Attributes.TypeFilters
|
||||
{
|
||||
return Regex.IsMatch(type.FullName, _pattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A string that represents the current object.
|
||||
/// </returns>
|
||||
/// <filterpriority>2</filterpriority>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Pattern: {0}", _pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,9 @@ namespace Spring.Context.Config
|
||||
|
||||
foreach (var baseAssembly in baseAssemblies.Split(','))
|
||||
{
|
||||
if (Logger.IsDebugEnabled)
|
||||
Logger.Debug("Start With Assembly Filter: " + baseAssembly);
|
||||
|
||||
scanner.WithAssemblyFilter(assy => assy.FullName.StartsWith(baseAssembly));
|
||||
}
|
||||
}
|
||||
@@ -111,7 +114,10 @@ namespace Spring.Context.Config
|
||||
var nameGeneratorString = element.GetAttribute(NAME_GENERATOR_ATTRIBUTE);
|
||||
var nameGenerator = CustomTypeFactory.GetNameGenerator(nameGeneratorString);
|
||||
if (nameGenerator != null)
|
||||
{
|
||||
Logger.Debug(m => m("Use NameTable Generator: {0}", nameGeneratorString));
|
||||
scanner.ObjectNameGenerator = nameGenerator;
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseTypeFilters(AssemblyObjectDefinitionScanner scanner, XmlElement element)
|
||||
@@ -119,9 +125,17 @@ namespace Spring.Context.Config
|
||||
foreach (XmlNode node in element.ChildNodes)
|
||||
{
|
||||
if (node.Name.Contains(INCLUDE_FILTER_ELEMENT))
|
||||
scanner.WithIncludeFilter(CreateTypeFilter(node));
|
||||
{
|
||||
var filter = CreateTypeFilter(node);
|
||||
Logger.Debug(m => m("Inlude Filter: {0}", filter));
|
||||
scanner.WithIncludeFilter(filter);
|
||||
}
|
||||
else if (node.Name.Contains(EXCLUDE_FILTER_ELEMENT))
|
||||
scanner.WithExcludeFilter(CreateTypeFilter(node));
|
||||
{
|
||||
var filter = CreateTypeFilter(node);
|
||||
Logger.Debug(m => m("Exclude Filter: {0}", filter));
|
||||
scanner.WithExcludeFilter(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +168,5 @@ namespace Spring.Context.Config
|
||||
throw new InvalidEnumArgumentException(string.Format("Filter type {0} is not defined", type));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user