-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Creating Child containers based on parent container
- Types resolver as build in feature
- Loading branch information
1 parent
ea8f0c1
commit 8150e3d
Showing
16 changed files
with
225 additions
and
31 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
CheckOutExamples/src/main/java/tutorial/_11_ResolveParameters.java
This file contains 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,53 @@ | ||
package tutorial; | ||
|
||
import io.github.jwdeveloper.dependance.Dependance; | ||
import io.github.jwdeveloper.dependance.api.DependanceContainer; | ||
|
||
public class _11_ResolveParameters { | ||
public static void main(String[] args) throws Exception { | ||
DependanceContainer container = Dependance.newContainer() | ||
.registerTransient(_11_ResolveParameters.ExampleWithGenerics.class) | ||
.registerTransient(_11_ResolveParameters.ExampleClass.class) | ||
.configure(config -> | ||
{ | ||
config.onInjection(onInjectionEvent -> | ||
{ | ||
if (!onInjectionEvent.input().equals(ExampleWithGenerics.class)) { | ||
return onInjectionEvent.output(); | ||
} | ||
|
||
var geneicsTyles = onInjectionEvent.inputGenericParameters()[0]; | ||
if (!String.class.equals(geneicsTyles)) { | ||
return onInjectionEvent.output(); | ||
} | ||
return new ExampleWithGenerics<String>(); | ||
}); | ||
}) | ||
.build(); | ||
|
||
var method = _11_ResolveParameters.class.getDeclaredMethod( | ||
"sayHello", | ||
_11_ResolveParameters.ExampleWithGenerics.class, | ||
_11_ResolveParameters.ExampleClass.class); | ||
|
||
var parameters = container.resolveParameters(method); | ||
|
||
method.invoke(null, parameters); | ||
} | ||
|
||
|
||
public static void sayHello(_11_ResolveParameters.ExampleWithGenerics<String> exampleService, | ||
_11_ResolveParameters.ExampleClass exampleClass) { | ||
|
||
System.out.println("Hello world"); | ||
} | ||
|
||
|
||
public static class ExampleWithGenerics<T> { | ||
|
||
} | ||
|
||
public static class ExampleClass { | ||
|
||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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 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 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 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
10 changes: 10 additions & 0 deletions
10
...enchmark/src/main/java/io/github/jwdeveloper/dependance/exampleClasses/ExampleClass3.java
This file contains 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,10 @@ | ||
package io.github.jwdeveloper.dependance.exampleClasses; | ||
|
||
public class ExampleClass3 | ||
{ | ||
ExampleClass4 exampleClass4; | ||
|
||
public ExampleClass3(ExampleClass4 exampleClass4) { | ||
this.exampleClass4 = exampleClass4; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...enchmark/src/main/java/io/github/jwdeveloper/dependance/exampleClasses/ExampleClass4.java
This file contains 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,10 @@ | ||
package io.github.jwdeveloper.dependance.exampleClasses; | ||
|
||
public class ExampleClass4 { | ||
|
||
ExampleClass5 exampleClass5; | ||
|
||
public ExampleClass4(ExampleClass5 exampleClass5) { | ||
this.exampleClass5 = exampleClass5; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...enchmark/src/main/java/io/github/jwdeveloper/dependance/exampleClasses/ExampleClass5.java
This file contains 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,10 @@ | ||
package io.github.jwdeveloper.dependance.exampleClasses; | ||
|
||
public class ExampleClass5 { | ||
|
||
ExampleClass6 exampleClass6; | ||
|
||
public ExampleClass5(ExampleClass6 exampleClass6) { | ||
this.exampleClass6 = exampleClass6; | ||
} | ||
} |
Oops, something went wrong.