fix: reduce frequence of 'creating resource table' log messages (closes #1265)

This commit is contained in:
Akash Yadav
2023-09-12 10:57:03 +05:30
parent dbdb8fcfa5
commit 461bded415
7 changed files with 34 additions and 16 deletions
@@ -347,6 +347,7 @@ open class AndroidModule( // Class must be open because BaseXMLTest mocks this..
/** Get the resource tables for external dependencies (not local module project dependencies). */
fun getDependencyResourceTables(): Set<ResourceTable> {
return mutableSetOf<ResourceTable>().also {
var deps = 0
it.addAll(
libraryMap.values
.filter { library ->
@@ -354,14 +355,22 @@ open class AndroidModule( // Class must be open because BaseXMLTest mocks this..
library.androidLibraryData!!.resFolder.exists() &&
library.findPackageName() != UNKNOWN_PACKAGE
}
.also { libs -> deps = libs.size }
.mapNotNull { library ->
ResourceTableRegistry.getInstance()
.forPackage(
library.packageName,
library.androidLibraryData!!.resFolder,
)
.let { registry ->
registry.isLoggingEnabled = false
registry.forPackage(
library.packageName,
library.androidLibraryData!!.resFolder,
).also {
registry.isLoggingEnabled = true
}
}
}
)
log.info("Created ${it.size} resource tables for $deps dependencies of module '$path'")
}
}
@@ -52,7 +52,7 @@ import java.util.concurrent.ConcurrentHashMap
* @author Akash Yadav
*/
@AutoService(ResourceTableRegistry::class)
internal class DefaultResourceTableRegistry : ResourceTableRegistry {
class DefaultResourceTableRegistry : ResourceTableRegistry {
/**
* Represents the type of single line entries read from files.
@@ -36,7 +36,7 @@ import java.util.concurrent.ConcurrentHashMap
* @author Akash Yadav
*/
@AutoService(ApiVersionsRegistry::class)
internal class DefaultApiVersionsRegistry : ApiVersionsRegistry {
class DefaultApiVersionsRegistry : ApiVersionsRegistry {
private val log = ILogger.newInstance(javaClass.simpleName)
private val versions = ConcurrentHashMap<String, ApiVersions>()
@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap
* @author Akash Yadav
*/
@AutoService(WidgetTableRegistry::class)
internal class DefaultWidgetTableRegistry : WidgetTableRegistry {
class DefaultWidgetTableRegistry : WidgetTableRegistry {
private val tables = ConcurrentHashMap<String, WidgetTable>()
private val log = ILogger.newInstance(WidgetTableRegistry::class.java.simpleName)
@@ -32,14 +32,21 @@ import java.io.File
interface ResourceTableRegistry : XmlRegistry<ResourceTable> {
companion object {
const val PCK_ANDROID = "android"
@JvmStatic val COMPLETION_MODULE_RES = Lookup.Key<Set<ResourceTable>>()
@JvmStatic val COMPLETION_DEP_RES = Lookup.Key<Set<ResourceTable>>()
@JvmStatic val COMPLETION_FRAMEWORK_RES = Lookup.Key<ResourceTable>()
@JvmStatic val COMPLETION_MANIFEST_ATTR_RES = Lookup.Key<ResourceTable>()
@JvmStatic fun getInstance(): ResourceTableRegistry {
return ServiceLoader.load(ResourceTableRegistry::class.java).findFirstOrThrow()
const val PCK_ANDROID = "android"
@JvmStatic
val COMPLETION_MODULE_RES = Lookup.Key<Set<ResourceTable>>()
@JvmStatic
val COMPLETION_DEP_RES = Lookup.Key<Set<ResourceTable>>()
@JvmStatic
val COMPLETION_FRAMEWORK_RES = Lookup.Key<ResourceTable>()
@JvmStatic
val COMPLETION_MANIFEST_ATTR_RES = Lookup.Key<ResourceTable>()
@JvmStatic
fun getInstance(): ResourceTableRegistry {
val klass = ResourceTableRegistry::class.java
return ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
}
}
@@ -34,7 +34,8 @@ interface ApiVersionsRegistry : XmlRegistry<ApiVersions> {
/** Get the default instance of [ApiVersionsRegistry]. */
@JvmStatic fun getInstance(): ApiVersionsRegistry {
return ServiceLoader.load(ApiVersionsRegistry::class.java).findFirstOrThrow()
val klass = ApiVersionsRegistry::class.java
return ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
}
}
}
@@ -33,7 +33,8 @@ interface WidgetTableRegistry : XmlRegistry<WidgetTable> {
/** Get the default instance of [WidgetTableRegistry]. */
@JvmStatic
fun getInstance(): WidgetTableRegistry {
return ServiceLoader.load(WidgetTableRegistry::class.java).findFirstOrThrow()
val klass = WidgetTableRegistry::class.java
return ServiceLoader.load(klass, klass.classLoader).findFirstOrThrow()
}
}
}