Skip to content

feat: enable injection of services from the service registry#1232

Merged
derklaro merged 4 commits intonightlyfrom
service-registry-injection
May 17, 2023
Merged

feat: enable injection of services from the service registry#1232
derklaro merged 4 commits intonightlyfrom
service-registry-injection

Conversation

@0utplay
Copy link
Member

@0utplay 0utplay commented May 16, 2023

Motivation

We wanted to replace the service registry fully with injection but that would result in a weird injection tree and instead we can just make it easier to use the service registry when using injection.

Modification

Added a new @Service annotation which retrieves the declared element from the service registry instead of any injection binding.

Result

Injection and the service registry go hand in hand and there is no need to remove the service registry

@0utplay 0utplay added v: 4.X This pull should be included in the 4.0 release in: driver An issue/pull request releated to the driver module code t: improvement The pull request improves existing code labels May 16, 2023
@0utplay 0utplay added this to the 4.0.0-RC9 milestone May 16, 2023
@0utplay 0utplay requested a review from derklaro May 16, 2023 18:24
@0utplay 0utplay self-assigned this May 16, 2023
@github-actions
Copy link

github-actions bot commented May 16, 2023

Test Results

  47 files  ±0    47 suites  ±0   1m 35s ⏱️ +18s
322 tests +1  322 ✔️ +1  0 💤 ±0  0 ±0 
652 runs  +1  652 ✔️ +1  0 💤 ±0  0 ±0 

Results for commit 73f5b04. ± Comparison against base commit e560b59.

This pull request removes 16 and adds 17 tests. Note that renamed tests count towards both.
eu.cloudnetservice.driver.document.DocumentSerialisationTest ‑ [4] {"b":1,"s":2,"i":3,"l":4,"f":5.0,"d":6.0,"c":"/","string":"Hello, World!","bol":true,"cloud":["Ben?","Yes","No","HoHoHoHo"],"world":{"this":"is","insane":"!","hello":"world"}}, PRETTY
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [10] 6268, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [1] {test2=test3, test=test1}, class java.lang.String, class java.lang.String
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [2] R51HBFYYOG6SLFHR2CLKBIUXL, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [2] {test2=456, test=123}, class java.lang.String, class java.lang.Integer
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [3] 23137799, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [3] Lobbyhello156:bd4fe001-4416-4afe-8b09-a61a9fa9605d
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [3] {test2=[678, 456], test=[123, 456]}, class java.lang.String, java.util.List<java.lang.Integer>
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [4] 6342737901398807372, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [4] Optional[{test2=test3, test=test1}], java.util.Map<java.lang.String, java.lang.String>
…
eu.cloudnetservice.driver.document.DocumentSerialisationTest ‑ [4] {"b":1,"s":2,"i":3,"l":4,"f":5.0,"d":6.0,"c":"/","string":"Hello, World!","bol":true,"cloud":["Ben?","Yes","No","HoHoHoHo"],"world":{"insane":"!","hello":"world","this":"is"}}, PRETTY
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [10] 14855, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [1] {test=test1, test2=test3}, class java.lang.String, class java.lang.String
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [2] 3NLI4EYIOP22P6Y52IG23OFCM, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [2] {test=123, test2=456}, class java.lang.String, class java.lang.Integer
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [3] -2122874734, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [3] Lobbyhello156:ef1740a7-cc26-4dd7-be08-516234f62f97
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [3] {test=[123, 456], test2=[678, 456]}, class java.lang.String, java.util.List<java.lang.Integer>
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [4] -7986003458545901877, null
eu.cloudnetservice.driver.network.rpc.object.DefaultObjectMapperTest ‑ [4] Optional[{test=test1, test2=test3}], java.util.Map<java.lang.String, java.lang.String>
…

♻️ This comment has been updated with latest results.

@derklaro derklaro merged commit 48c818c into nightly May 17, 2023
@derklaro derklaro deleted the service-registry-injection branch May 17, 2023 15:05
derklaro pushed a commit that referenced this pull request Jun 8, 2023
…#1234)

### Motivation
#1232 introduced a new `@Service` annotation that allows to injection
providers from the service registry directly instead of injecting the
service registry and retrieving it from the registry afterwards. This PR
makes use of the new annotation and replaces the service registry where
possible.

### Modification
Deprecated the ServiceRegistry.first(Class) method as it requires
injection abuse to work. Replaced other usages of the service registry
with the new annotation where possible.

### Result
We are using the new Service annotation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: driver An issue/pull request releated to the driver module code t: improvement The pull request improves existing code v: 4.X This pull should be included in the 4.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants