-
Notifications
You must be signed in to change notification settings - Fork 25
Attempt multi scope no deps #802
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c5599dc
Add more tests for multi-scope
cbarlin 7e271d8
order custom modules
SentryMan 9c09ec4
auto-provide current module
SentryMan a58ebf1
generate allRequiredModules
SentryMan cef0b51
Revert "generate allRequiredModules"
SentryMan 6959bf6
Reapply "generate allRequiredModules"
SentryMan 4e75ffc
what I got
SentryMan 0501dde
Get multi-scope working without dependencies
cbarlin 3fd05dc
get it working
SentryMan 08dfac8
external scope scenario
SentryMan 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
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
7 changes: 2 additions & 5 deletions
7
blackbox-multi-scope/src/main/java/org/multi/crosscut/BeanCross2.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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
package org.multi.crosscut; | ||
|
||
import org.multi.moda.BeanInModA; | ||
import org.multi.modb.BeanInModB; | ||
import org.multi.modc.modb.BeanInModC; | ||
import org.multi.modc.BeanInModC; | ||
import org.multi.scope.CrossCutScope; | ||
|
||
@CrossCutScope | ||
public class BeanCross2 { | ||
public BeanCross2(final BeanInModA beanInModA, final BeanInModC beanInModC) { | ||
|
||
} | ||
public BeanCross2(final BeanInModA beanInModA, final BeanInModC beanInModC) {} | ||
} |
6 changes: 2 additions & 4 deletions
6
blackbox-multi-scope/src/main/java/org/multi/crosscut/BeanCross3.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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
package org.multi.crosscut; | ||
|
||
import org.multi.modc.modb.COther; | ||
import org.multi.modc.COther; | ||
import org.multi.scope.CrossCutScope; | ||
|
||
@CrossCutScope | ||
public class BeanCross3 { | ||
public BeanCross3(final COther other) { | ||
|
||
} | ||
public BeanCross3(final COther other) {} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
blackbox-multi-scope/src/main/java/org/multi/many/BeanInMany.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,19 @@ | ||
package org.multi.many; | ||
|
||
import org.multi.moda.BeanInModA; | ||
import org.multi.modc.COther; | ||
import org.multi.mode.BeanInModE; | ||
import org.multi.scope.ManyScope; | ||
import org.other.one.custom.OtherCustomComponent; | ||
|
||
import io.avaje.inject.External; | ||
|
||
@ManyScope | ||
public class BeanInMany { | ||
|
||
public BeanInMany( | ||
BeanInModE beanInModE, | ||
COther cOther, | ||
BeanInModA modA, | ||
@External OtherCustomComponent external) {} | ||
} |
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 |
---|---|---|
|
@@ -3,5 +3,4 @@ | |
import org.multi.scope.ModAScope; | ||
|
||
@ModAScope | ||
public class BeanInModA { | ||
} | ||
public class BeanInModA {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ | |
import org.multi.scope.ModBScope; | ||
|
||
@ModBScope | ||
public class BeanInModB { | ||
} | ||
public class BeanInModB {} |
6 changes: 6 additions & 0 deletions
6
blackbox-multi-scope/src/main/java/org/multi/modc/BeanInModC.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,6 @@ | ||
package org.multi.modc; | ||
|
||
import org.multi.scope.ModCScope; | ||
|
||
@ModCScope | ||
public class BeanInModC {} |
6 changes: 6 additions & 0 deletions
6
blackbox-multi-scope/src/main/java/org/multi/modc/COther.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,6 @@ | ||
package org.multi.modc; | ||
|
||
import org.multi.scope.ModCScope; | ||
|
||
@ModCScope | ||
public class COther {} |
7 changes: 0 additions & 7 deletions
7
blackbox-multi-scope/src/main/java/org/multi/modc/modb/BeanInModC.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
blackbox-multi-scope/src/main/java/org/multi/modc/modb/COther.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
blackbox-multi-scope/src/main/java/org/multi/modd/BeanInModD.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,14 @@ | ||
package org.multi.modd; | ||
|
||
import org.multi.moda.BeanInModA; | ||
import org.multi.scope.ModDScope; | ||
|
||
@ModDScope | ||
public class BeanInModD { | ||
|
||
private final BeanInModA beanA; | ||
|
||
public BeanInModD(final BeanInModA beanInModA) { | ||
this.beanA = beanInModA; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
blackbox-multi-scope/src/main/java/org/multi/mode/BeanInModE.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,6 @@ | ||
package org.multi.mode; | ||
|
||
import org.multi.scope.ModEScope; | ||
|
||
@ModEScope | ||
public class BeanInModE {} |
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
11 changes: 11 additions & 0 deletions
11
blackbox-multi-scope/src/main/java/org/multi/scope/ManyScope.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,11 @@ | ||
package org.multi.scope; | ||
|
||
import org.other.one.custom.ExternalScope; | ||
|
||
import io.avaje.inject.InjectModule; | ||
import jakarta.inject.Scope; | ||
|
||
@Scope | ||
@InjectModule( | ||
requires = {ExternalScope.class, ModDScope.class, CrossCutScope.class, ModEScope.class}) | ||
public @interface ManyScope {} |
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
8 changes: 8 additions & 0 deletions
8
blackbox-multi-scope/src/main/java/org/multi/scope/ModDScope.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,8 @@ | ||
package org.multi.scope; | ||
|
||
import io.avaje.inject.InjectModule; | ||
import jakarta.inject.Scope; | ||
|
||
@Scope | ||
@InjectModule(requires = {ModAScope.class}) | ||
public @interface ModDScope {} |
8 changes: 8 additions & 0 deletions
8
blackbox-multi-scope/src/main/java/org/multi/scope/ModEScope.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,8 @@ | ||
package org.multi.scope; | ||
|
||
import io.avaje.inject.InjectModule; | ||
import jakarta.inject.Scope; | ||
|
||
@Scope | ||
@InjectModule | ||
public @interface ModEScope {} |
60 changes: 50 additions & 10 deletions
60
blackbox-multi-scope/src/test/java/org/multi/crosscut/BeanCrossTest.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 |
---|---|---|
@@ -1,24 +1,64 @@ | ||
package org.multi.crosscut; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import io.avaje.inject.BeanScope; | ||
import org.junit.jupiter.api.Test; | ||
import org.multi.many.BeanInMany; | ||
import org.multi.many.ManyModule; | ||
import org.multi.moda.BeanInModA; | ||
import org.multi.moda.ModAModule; | ||
import org.multi.modb.BOther; | ||
import org.multi.modb.BeanInModB; | ||
import org.multi.modb.ModBModule; | ||
import org.multi.modc.BeanInModC; | ||
import org.multi.modc.COther; | ||
import org.multi.modc.ModCModule; | ||
import org.multi.modd.BeanInModD; | ||
import org.multi.modd.ModDModule; | ||
import org.multi.mode.BeanInModE; | ||
import org.multi.mode.ModEModule; | ||
import org.other.one.custom.ExternalModule; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import io.avaje.inject.BeanScope; | ||
|
||
class BeanCrossTest { | ||
|
||
@Test | ||
void bootstrap() { | ||
private static final Class<?>[] CHECKABLE = { | ||
BeanCross.class, | ||
BeanCross2.class, | ||
BeanCross3.class, | ||
BeanInMany.class, | ||
BeanInModA.class, | ||
BeanInModB.class, | ||
BOther.class, | ||
BeanInModC.class, | ||
COther.class, | ||
BeanInModD.class, | ||
BeanInModE.class | ||
}; | ||
|
||
try (BeanScope beanScope = BeanScope.builder() | ||
// .modules(new CrossCutModule()) | ||
.build()) { | ||
@Test | ||
void testCustomOrdering() { | ||
|
||
// var beanInModB = beanScope.get(BeanInModB.class); | ||
// assertThat(beanInModB).isNotNull(); | ||
try (BeanScope beanScope = | ||
assertDoesNotThrow( | ||
() -> | ||
BeanScope.builder() | ||
.modules( | ||
new ModEModule(), | ||
new ModBModule(), | ||
new ModDModule(), | ||
new ManyModule(), | ||
new ModCModule(), | ||
new ModAModule(), | ||
new CrossCutModule(), | ||
new ExternalModule()) | ||
.build())) { | ||
for (final Class<?> clazz : CHECKABLE) { | ||
assertTrue( | ||
beanScope.getOptional(clazz).isPresent(), "Bean not found: " + clazz.getSimpleName()); | ||
} | ||
} | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
blackbox-other/src/main/java/org/other/one/custom/ExternalScope.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,8 @@ | ||
package org.other.one.custom; | ||
|
||
import io.avaje.inject.InjectModule; | ||
import jakarta.inject.Scope; | ||
|
||
@Scope | ||
@InjectModule | ||
public @interface ExternalScope {} |
4 changes: 4 additions & 0 deletions
4
blackbox-other/src/main/java/org/other/one/custom/OtherCustomComponent.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,4 @@ | ||
package org.other.one.custom; | ||
|
||
@ExternalScope | ||
public class OtherCustomComponent {} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These being modules or scopes is a hard one by the looks:
But then, either way, it (currently) falls down when you attempt to extract the module dependencies to build the method... So maybe having them as modules is better? Although then you may be trying to read something from the annotation that doesn't yet exist and I've ran into that before as a problem in another project...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so modules in the annotation doesn't fly because the module classes don't exist by the time the processor tries to read them