Skip to content

Commit 25a38b9

Browse files
committed
removed path injection
1 parent 16ee464 commit 25a38b9

File tree

3 files changed

+3
-37
lines changed

3 files changed

+3
-37
lines changed

common/src/main/kotlin/com/lambda/command/CommandRegistry.kt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import com.lambda.config.Configurable
44
import com.lambda.config.configurations.LambdaConfig
55
import com.lambda.core.Loadable
66
import com.lambda.util.reflections.getInstances
7-
import org.reflections.Reflections
8-
import org.reflections.scanners.Scanners
9-
import org.reflections.util.ClasspathHelper.forPackage
10-
import org.reflections.util.ConfigurationBuilder
117

128
/**
139
* The [CommandRegistry] object is responsible for managing all [LambdaCommand] instances in the system.
@@ -16,15 +12,7 @@ object CommandRegistry : Configurable(LambdaConfig), Loadable {
1612
override val name = "command"
1713
val prefix by setting("prefix", ';')
1814

19-
private val extraPackages = mutableSetOf<String>()
20-
val commands = getInstances<LambdaCommand> { forPackages("com.lambda.command.commands", *extraPackages.toTypedArray()) }
21-
22-
/**
23-
* Injects a package into the [CommandRegistry] for scanning.
24-
*
25-
* @param packageName The package to inject into the [CommandRegistry].
26-
*/
27-
fun injectPath(packageName: String) = extraPackages.add(packageName)
15+
val commands = getInstances<LambdaCommand> { forPackages("com.lambda.command.commands") }.toMutableList()
2816

2917
override fun load(): String {
3018
return "Registered ${commands.size} commands"

common/src/main/kotlin/com/lambda/module/ModuleRegistry.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@ import org.reflections.util.ConfigurationBuilder
1010
* The [ModuleRegistry] object is responsible for managing all [Module] instances in the system.
1111
*/
1212
object ModuleRegistry : Loadable {
13-
private val extraPackages = mutableSetOf<String>()
14-
val modules = getInstances<Module> { forPackages("com.lambda.module.modules", *extraPackages.toTypedArray()) }
13+
val modules = getInstances<Module> { forPackages("com.lambda.module.modules") }.toMutableList()
1514

1615
val moduleNames: Set<String>
1716
get() = modules.map { it.name }.toSet()
1817

19-
/**
20-
* Injects a package into the [ModuleRegistry] for scanning.
21-
*
22-
* @param packageName The package to inject into the [ModuleRegistry].
23-
*/
24-
fun injectPath(packageName: String) = extraPackages.add(packageName)
25-
2618
override fun load(): String {
2719
return "Registered ${modules.size} modules with ${modules.sumOf { it.settings.size }} settings"
2820
}

common/src/main/kotlin/com/lambda/util/reflections/ReflectionsConfigDsl.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class ReflectionConfigDsl {
1818
private val packages = mutableListOf<String>()
1919
private val scanners = mutableListOf<Scanners>()
2020
private val urls = mutableListOf<URL>()
21-
private var inputsFilter: (String) -> Boolean = { true }
2221
private val classLoaders = mutableListOf<ClassLoader>()
2322
private var parallel = false
2423
private var shouldExpandSuperTypes = true
@@ -56,17 +55,6 @@ class ReflectionConfigDsl {
5655
return this
5756
}
5857

59-
/**
60-
* Sets a filter for input names.
61-
*
62-
* @param filter A lambda function that takes a [String] and returns a [Boolean], indicating whether the input should be included.
63-
* @return The current instance of [ReflectionConfigDsl] for method chaining.
64-
*/
65-
fun filterInputsBy(filter: (String) -> Boolean): ReflectionConfigDsl {
66-
inputsFilter = filter
67-
return this
68-
}
69-
7058
/**
7159
* Adds class loaders to the configuration.
7260
*
@@ -101,13 +89,11 @@ class ReflectionConfigDsl {
10189

10290
/**
10391
* Builds a [ConfigurationBuilder] based on the current configuration.
104-
*
105-
* @return A [ConfigurationBuilder] configured with the specified packages, scanners, URLs, filters, and class loaders.
10692
*/
10793
fun build(): ConfigurationBuilder = ConfigurationBuilder()
10894
.forPackages(*packages.toTypedArray())
10995
.addUrls(*urls.toTypedArray())
110-
.filterInputsBy(inputsFilter)
96+
.filterInputsBy { it.contains("com.lambda") }
11197
.addClassLoaders(*classLoaders.toTypedArray())
11298
.setExpandSuperTypes(shouldExpandSuperTypes)
11399
}

0 commit comments

Comments
 (0)