Skip to content

Commit 08acb0f

Browse files
committed
#51 mention that DependencyInjectionTest in quick Registry docs
1 parent 8ea2b40 commit 08acb0f

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

core/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Some core concepts that can be useful without [klite-server](../server). Depende
77
* [Logger](src/Logger.kt) - convenient extensions for JDK System.Logger
88
* [toValues/create](src/Values.kt) - functions for conversion of objects to maps and back; can be used for DTO mapping, but also jdbc/json/etc
99
* [Decimal](src/Decimal.kt) - an alternative for BigDecimal for monetary amounts
10+
* [Registry/DependencyInjectingRegistry](src/Registry.kt) - simple registry of class instances and Dependency Injection

server/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,18 @@ For SPA client-side routing support, create AssetsHandler with `useIndexForUnkno
6262

6363
Use `Config.fromEnvFile()` if you want to load default config from an `.env`. This is useful for local development.
6464

65-
## Registry
65+
## Registry (and Dependency Injection)
6666

6767
[Registry](../core/src/Registry.kt) and it's default implementation - `DependencyInjectingRegistry` - provide
6868
a simple way to register and require both Klite components and repositories/services of your application.
6969

7070
`DependencyInjectingRegistry` is used by default and can create any classes by recursively creating their constructor
7171
arguments (dependencies).
7272

73+
You can use `register<MyInterface>(MyImplementation::class)` or `register<MyImplementation>()` to register a specific implementation that needs to be used for an interface.
74+
75+
See [it's tests](test/klite/DependencyInjectingRegistry.kt) for usage examples.
76+
7377
## Decorators
7478

7579
You can add both global and context-specific [decorators](src/klite/Decorators.kt), including `Before` and `After` handlers.

server/test/klite/DependencyInjectingRegistryTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DependencyInjectingRegistryTest {
1818
expect(registry.optional<BodyParser>()).toBeAnInstanceOf<TextBodyParser>()
1919
}
2020

21-
@Test fun `use existing instance even for arguments with default values`() {
21+
@Test fun `use registered instance even for arguments having default values`() {
2222
class Subject(val nonDefault: BodyParser = TextBodyParser(), val default: FormUrlEncodedParser = FormUrlEncodedParser())
2323

2424
val registeredParser = TextBodyParser()

0 commit comments

Comments
 (0)