-
Notifications
You must be signed in to change notification settings - Fork 126
feat: implementation of gestalt-DI #622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
e2fc0ad
feat: expirmental work for gestalt-DI
pollend ea7a02b
tweak implementation
pollend 735bd6a
start basic implementation for SolGame
pollend 3729443
fix(DI): resolve Circular reference between `OggSoundManager` and `So…
DarkWeird c38a3c9
fix(DI): inject `DisplayDimensions` in some classes. main menu works.
DarkWeird fde7aa9
fix(DI): fix running game.
DarkWeird fcef6ae
refactor(DI): move Game services to `SolGameServiceRegistry`
DarkWeird 818c5c6
fix(DI): fix game savings. Make `SerialisationManager` as normal serv…
DarkWeird 50cf9c9
fix(DI): Minor fix resolving deps for `SerialisationManager`
DarkWeird 65c694d
fix(DI): Remove unused store
DarkWeird e36b67b
remove intrpsection since beandefintioins are now driven by the prese…
pollend 53f47bf
Merge remote-tracking branch 'origin/develop' into feat/experimental-…
pollend 217003a
fix(DI): Integrate `gestalt-di` with `gestalt-module` and removes `Re…
DarkWeird fd12eac
fix(DI): update tests for working with `gestalt-di`
DarkWeird d68ddf7
fix(DI): fix tests with events
DarkWeird b44b963
Merge remote-tracking branch 'origin/develop' into feat/experimental-…
pollend 6e7c60c
update gestalt version
pollend fdefafb
Merge branch 'develop' into feat/experimental-DI-gestalt
pollend 6e9f56a
update with 3d1 snapshot
pollend 5672d6c
update packages
pollend 935766e
update for 4.0.0 snapshot
pollend 1164f5e
Added FacadeModuleConfig for Android compatibility.
BenjaminAmos fa44ec2
fix: add missing indexing attributes to types
BenjaminAmos 435b5eb
fix: fix tutorial from not running
BenjaminAmos 157ff97
Merge branch 'develop' of github.com:MovingBlocks/DestinationSol into…
pollend ca9eb18
chore: remove mavenLocal()
pollend 57a5e50
bugfix: resolve tutorialManager
pollend 7b36517
Merge branch 'feat/experimental-DI-gestalt' into di-android-fixes
pollend efc7df6
Merge pull request #599 from BenjaminAmos/di-android-fixes
pollend 2f3325b
chore: fix compiling errors
pollend 76db920
bugfix: remove duplicate registration for TutorialManager
pollend 595f73b
chore: fix Component
pollend dd1921e
chore: merged in changes from master
pollend 5fe068c
Merge branch 'develop' of github.com:MovingBlocks/DestinationSol into…
pollend 44cc049
resolve build problems with service registry
pollend 9e013e8
test: fix RubbleTest race condition
BenjaminAmos a22b061
chore: address changes
pollend 4181b09
fix(android): fix the game running on Android
BenjaminAmos 46a8738
Merge pull request #640 from MovingBlocks/android/gestalt-di-fix-android
pollend eea3ef6
chore: implement workaround for preBegin
pollend 9990d4e
chore: resolve preBegin
pollend e524ce2
Merge remote-tracking branch 'origin/develop' into feat/experimental-…
DarkWeird 5a2416c
fix(di): restore playable state for desktop
DarkWeird cbbf328
chore: remove mavenLocal and empty lines
DarkWeird ecc3f19
fix: fix engine tests compilation
BenjaminAmos 008d74c
fix: add ECS `EventReceiver` injection and fix associated tests
BenjaminAmos 660fa7b
feature: make FocusManager as Injectable service and inject it in Nui.
DarkWeird File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,3 +80,4 @@ engine/src/main/resources/entity_store.dat | |
|
|
||
| # Ignore donwloaded JREs | ||
| jre/** | ||
| engine/src/main/generated/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
engine/src/main/java/org/destinationsol/BeanClassFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package org.destinationsol; | ||
|
|
||
| import org.terasology.gestalt.di.BeanContext; | ||
| import org.terasology.gestalt.util.reflection.ClassFactory; | ||
|
|
||
| import javax.inject.Provider; | ||
| import java.util.Optional; | ||
|
|
||
| public class BeanClassFactory implements ClassFactory { | ||
BenjaminAmos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private final Provider<BeanContext> beanContext; | ||
|
|
||
| public BeanClassFactory(Provider<BeanContext> beanContext) { | ||
| this.beanContext = beanContext; | ||
| } | ||
|
|
||
| @Override | ||
| public <T> Optional<T> instantiateClass(Class<? extends T> type) { | ||
| return (Optional<T>) beanContext.get().findBean(type); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
engine/src/main/java/org/destinationsol/ContextWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright 2021 The Terasology Foundation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.destinationsol; | ||
|
|
||
| import org.destinationsol.game.context.Context; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.terasology.gestalt.di.BeanContext; | ||
| import org.terasology.gestalt.di.exceptions.BeanResolutionException; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @Deprecated | ||
| public class ContextWrapper implements Context { | ||
BenjaminAmos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(ContextWrapper.class); | ||
| protected BeanContext context; | ||
|
|
||
| @Inject | ||
| public ContextWrapper(BeanContext beanContext) { | ||
| this.context = beanContext; | ||
| } | ||
|
|
||
| @Override | ||
| public <T> T get(Class<? extends T> type) { | ||
| try { | ||
| return (T) context.getBean(type); | ||
| } catch (BeanResolutionException e){ | ||
| logger.warn("Bean [{}] not found",type); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public <T, U extends T> void put(Class<T> type, U object) { | ||
| throw new RuntimeException("Cannot insert values into wrapped context: please use the BeanContext directly"); | ||
| } | ||
|
|
||
| @Override | ||
| public <T, U extends T> void remove(Class<T> type, U object) { | ||
| throw new RuntimeException("Cannot insert values into wrapped context: please use the BeanContext directly"); | ||
| } | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
engine/src/main/java/org/destinationsol/ContextWrapperService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright 2020 The Terasology Foundation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.destinationsol; | ||
|
|
||
|
|
||
| import org.destinationsol.game.context.Context; | ||
| import org.terasology.context.Lifetime; | ||
| import org.terasology.gestalt.di.ServiceRegistry; | ||
|
|
||
| public class ContextWrapperService extends ServiceRegistry { | ||
| public ContextWrapperService() { | ||
| this.with(Context.class).use(ContextWrapper.class).lifetime(Lifetime.Singleton); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.