@@ -3,6 +3,7 @@ package code.util
33import java .io .File
44
55import com .openbankproject .commons .model .Bank
6+ import code .util .Helper .MdcLoggable
67import org .apache .commons .lang3 .StringUtils
78import org .clapper .classutil .{ClassFinder , ClassInfo }
89import com .openbankproject .commons .util .ReflectUtils
@@ -13,7 +14,7 @@ import scala.reflect.runtime.universe.TypeTag
1314 * this is some util method to scan any class according some rules
1415 * @author shuang
1516 */
16- object ClassScanUtils {
17+ object ClassScanUtils extends MdcLoggable {
1718
1819 lazy val finder = ClassFinder (getClassPath(this .getClass, classOf [Bank ], classOf [String ]))
1920
@@ -36,14 +37,23 @@ object ClassScanUtils {
3637 def getSubTypeObjects [T : TypeTag ]: List [T ] = {
3738 val clazz = ReflectUtils .typeTagToClass[T ]
3839 val classes = try {
39- finder.getClasses().toList
40+ val allClasses = finder.getClasses().toList
41+ logger.info(s " ClassScanUtils successfully scanned ${allClasses.size} classes from classpath " )
42+ allClasses
4043 } catch {
41- case _ : UnsupportedOperationException =>
44+ case e : UnsupportedOperationException =>
4245 // ASM version is too old for some class files (e.g. requires ASM7). In that case,
4346 // skip scanned APIs instead of failing the whole application.
47+ logger.warn(s " Class scanning failed with UnsupportedOperationException: ${e.getMessage}" )
48+ logger.warn(" This is expected when running from a Fat JAR. Scanned APIs will not be auto-registered." )
49+ Seq .empty
50+ case e : Exception =>
51+ logger.warn(s " Class scanning failed with ${e.getClass.getSimpleName}: ${e.getMessage}" )
4452 Seq .empty
4553 }
46- classes.filter(_.implements(clazz.getName)).map(_.name).map(companion[T ](_)).toList
54+ val filtered = classes.filter(_.implements(clazz.getName))
55+ logger.info(s " Found ${filtered.size} classes implementing ${clazz.getName}" )
56+ filtered.map(_.name).map(companion[T ](_)).toList
4757 }
4858
4959 /**
0 commit comments