Skip to content

Commit

Permalink
简单优化对于核心boot模块下的类扫描提示
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Feb 27, 2022
1 parent 229fce8 commit 844e30c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .changelog/v3.0.0.preview.4.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- 简单优化对于核心boot模块下的类扫描提示


## 其他日志
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2021-2022 ForteScarlet <ForteScarlet@163.com>
* Copyright (c) 2021-2022 ForteScarlet <https://github.com/ForteScarlet>
*
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x ) 的一部分。
* 本文件是 simply-robot (或称 simple-robot 3.x、simbot 3.x、simbot3) 的一部分。
*
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
*
Expand All @@ -12,7 +12,6 @@
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
*
*
*/

package love.forte.simboot.core.internal
Expand Down Expand Up @@ -161,7 +160,7 @@ internal class CoreBootEntranceContextImpl(


if (allListenerInterceptor.isNotEmpty()) {
addListenerInterceptors(allListenerInterceptor.filterValues { it !is AnnotatedEventListenerInterceptor }) // 不追加注解拦截器
addListenerInterceptors(allListenerInterceptor.filterValues { it !is AnnotatedEventListenerInterceptor }) // 不追加注解拦截器
}

if (context != null) {
Expand Down Expand Up @@ -212,7 +211,7 @@ internal class CoreBootEntranceContextImpl(
}


private fun packagesToClassesGetter(vararg scannerPackages: String): () -> Collection<KClass<*>> {
private fun CoreBootEntranceContext.packagesToClassesGetter(vararg scannerPackages: String): () -> Collection<KClass<*>> {
if (scannerPackages.isEmpty()) return { emptyList() }

// scanner.
Expand All @@ -229,8 +228,20 @@ private fun packagesToClassesGetter(vararg scannerPackages: String): () -> Colle
val classname = entry.name.replace(pathReplace, ".").substringBeforeLast(".class")
val loadClass = runCatching {
scanner.classLoader.loadClass(classname)
}.getOrElse { e -> throw SimbotIllegalStateException("Class load filed: $classname", e) }
sequenceOf(loadClass.kotlin)
}.getOrElse { e ->
logger.warn("Class [{}] failed to load and will be skipped.", classname)
if (logger.isDebugEnabled) {
logger.debug("Reason for failure: $e", e)
}
// just warn
// throw SimbotIllegalStateException("Class load failed: $classname", e)
null
}
if (loadClass != null) {
sequenceOf(loadClass.kotlin)
} else {
emptySequence()
}
}
.visitPath { (_, r) ->
// '/Xxx.class'
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sealed class P : SimbotProject() {
val SNAPSHOT = System.getProperty("isSnapshot")?.equals("true", true) ?: false
const val GROUP = "love.forte.simbot"
const val BOOT_GROUP = "love.forte.simbot.boot"
private const val REAL_VERSION = "3.0.0.preview.4.0"
private const val REAL_VERSION = "3.0.0.preview.4.1"


val VERSION = if (SNAPSHOT) "$REAL_VERSION-SNAPSHOT" else REAL_VERSION
Expand Down

0 comments on commit 844e30c

Please sign in to comment.