Skip to content

Commit 39497d9

Browse files
committed
Refactor rename from BeanContext to BeanScope
1 parent 095b5d1 commit 39497d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+242
-299
lines changed

inject-generator/src/main/java/io/avaje/inject/generator/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Constants {
2020
static final String META_INF_FACTORY = "META-INF/services/io.avaje.inject.spi.BeanContextFactory";
2121

2222
static final String REQUESTSCOPE = "io.avaje.inject.RequestScope";
23-
static final String BEANCONTEXT = "io.avaje.inject.BeanContext";
23+
static final String BEANCONTEXT = "io.avaje.inject.BeanScope";
2424
static final String CONTEXTMODULE = "io.avaje.inject.ContextModule";
2525

2626
static final String GENERATED = "io.avaje.inject.spi.Generated";

inject-generator/src/main/java/io/avaje/inject/generator/SimpleFactoryWriter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SimpleFactoryWriter {
1414

1515
private static final String CODE_COMMENT_FACTORY =
1616
"/**\n" +
17-
" * Generated source - Creates the BeanContext for the %s module.\n" +
17+
" * Generated source - Creates the BeanScope for the %s module.\n" +
1818
" * \n" +
1919
" * With JPMS Java module system this generated class should be explicitly\n" +
2020
" * registered in module-info via a <code>provides</code> clause like:\n" +
@@ -33,16 +33,12 @@ class SimpleFactoryWriter {
3333

3434
private static final String CODE_COMMENT_CREATE_CONTEXT =
3535
" /**\n" +
36-
" * Create and return the BeanContext.\n" +
36+
" * Create the beans.\n" +
3737
" * <p>\n" +
3838
" * Creates all the beans in order based on constuctor dependencies.\n" +
3939
" * The beans are registered into the builder along with callbacks for\n" +
4040
" * field injection, method injection and lifecycle support.\n" +
4141
" * <p>\n" +
42-
" * Ultimately the builder returns the BeanContext containing the beans.\n" +
43-
" *\n" +
44-
" * @param parent The parent context for multi-module wiring\n" +
45-
" * @return The BeanContext containing the beans\n" +
4642
" */";
4743

4844
private final MetaDataOrdering ordering;

inject-test/src/test/java/io/avaje/inject/BeanContextBuilderTest.java renamed to inject-test/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
import static org.assertj.core.api.Assertions.assertThat;
1212

13-
public class BeanContextBuilderTest {
13+
public class BeanScopeBuilderTest {
1414

1515
@Test
1616
public void noDepends() {
1717

18-
DBeanContextBuilder.FactoryOrder factoryOrder = new DBeanContextBuilder.FactoryOrder(Collections.emptySet(), true, true);
18+
DBeanScopeBuilder.FactoryOrder factoryOrder = new DBeanScopeBuilder.FactoryOrder(Collections.emptySet(), true, true);
1919
factoryOrder.add(bc("1", null, null));
2020
factoryOrder.add(bc("2", null, null));
2121
factoryOrder.add(bc("3", null, null));
@@ -27,7 +27,7 @@ public void noDepends() {
2727
@Test
2828
public void name_depends() {
2929

30-
DBeanContextBuilder.FactoryOrder factoryOrder = new DBeanContextBuilder.FactoryOrder(Collections.emptySet(), true, true);
30+
DBeanScopeBuilder.FactoryOrder factoryOrder = new DBeanScopeBuilder.FactoryOrder(Collections.emptySet(), true, true);
3131
factoryOrder.add(bc("two", null, "one"));
3232
factoryOrder.add(bc("one", null, null));
3333
factoryOrder.orderFactories();
@@ -38,7 +38,7 @@ public void name_depends() {
3838
@Test
3939
public void name_depends4() {
4040

41-
DBeanContextBuilder.FactoryOrder factoryOrder = new DBeanContextBuilder.FactoryOrder(Collections.emptySet(), true, true);
41+
DBeanScopeBuilder.FactoryOrder factoryOrder = new DBeanScopeBuilder.FactoryOrder(Collections.emptySet(), true, true);
4242
factoryOrder.add(bc("1", null, "3"));
4343
factoryOrder.add(bc("2", null, "4"));
4444
factoryOrder.add(bc("3", null, "4"));
@@ -52,7 +52,7 @@ public void name_depends4() {
5252
@Test
5353
public void nameFeature_depends() {
5454

55-
DBeanContextBuilder.FactoryOrder factoryOrder = new DBeanContextBuilder.FactoryOrder(Collections.emptySet(), true, true);
55+
DBeanScopeBuilder.FactoryOrder factoryOrder = new DBeanScopeBuilder.FactoryOrder(Collections.emptySet(), true, true);
5656
factoryOrder.add(bc("1", "a", "3"));
5757
factoryOrder.add(bc("2", null, "4,a"));
5858
factoryOrder.add(bc("3", null, "4"));
@@ -66,7 +66,7 @@ public void nameFeature_depends() {
6666
@Test
6767
public void feature_depends() {
6868

69-
DBeanContextBuilder.FactoryOrder factoryOrder = new DBeanContextBuilder.FactoryOrder(Collections.emptySet(), true, true);
69+
DBeanScopeBuilder.FactoryOrder factoryOrder = new DBeanScopeBuilder.FactoryOrder(Collections.emptySet(), true, true);
7070
factoryOrder.add(bc("two", null, "myfeature"));
7171
factoryOrder.add(bc("one", "myfeature", null));
7272
factoryOrder.orderFactories();
@@ -77,7 +77,7 @@ public void feature_depends() {
7777
@Test
7878
public void feature_depends2() {
7979

80-
DBeanContextBuilder.FactoryOrder factoryOrder = new DBeanContextBuilder.FactoryOrder(Collections.emptySet(), true, true);
80+
DBeanScopeBuilder.FactoryOrder factoryOrder = new DBeanScopeBuilder.FactoryOrder(Collections.emptySet(), true, true);
8181
factoryOrder.add(bc("two", null, "myfeature"));
8282
factoryOrder.add(bc("one", "myfeature", null));
8383
factoryOrder.add(bc("three", "myfeature", null));

inject-test/src/test/java/org/example/coffee/BeanContextBuilderAddTest.java renamed to inject-test/src/test/java/org/example/coffee/BeanScopeBuilderAddTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package org.example.coffee;
22

3-
import io.avaje.inject.BeanContext;
3+
import io.avaje.inject.BeanScope;
44
import org.junit.jupiter.api.Test;
55
import org.mockito.Mockito;
66

77
import static org.assertj.core.api.Assertions.assertThat;
88
import static org.junit.jupiter.api.Assertions.assertThrows;
99
import static org.mockito.Mockito.verify;
1010

11-
public class BeanContextBuilderAddTest {
11+
public class BeanScopeBuilderAddTest {
1212

1313
@Test
1414
public void withModules_exludingThisOne() {
1515
assertThrows(IllegalStateException.class, () -> {
1616
TDPump testDoublePump = new TDPump();
1717

18-
try (BeanContext context = BeanContext.newBuilder()
18+
try (BeanScope context = BeanScope.newBuilder()
1919
.withBeans(testDoublePump)
2020
// our module is "org.example.coffee"
2121
// so this effectively includes no modules
@@ -35,7 +35,7 @@ public void withModules_includeThisOne() {
3535

3636
TDPump testDoublePump = new TDPump();
3737

38-
try (BeanContext context = BeanContext.newBuilder()
38+
try (BeanScope context = BeanScope.newBuilder()
3939
.withBeans(testDoublePump)
4040
.withModules("org.example")
4141
.build()) {
@@ -53,7 +53,7 @@ public void withBean_expect_testDoublePumpUsed() {
5353

5454
TDPump testDoublePump = new TDPump();
5555

56-
try (BeanContext context = BeanContext.newBuilder()
56+
try (BeanScope context = BeanScope.newBuilder()
5757
.withBeans(testDoublePump)
5858
.build()) {
5959

@@ -70,7 +70,7 @@ public void withMockitoMock_expect_mockUsed() {
7070

7171
Pump mock = Mockito.mock(Pump.class);
7272

73-
try (BeanContext context = BeanContext.newBuilder()
73+
try (BeanScope context = BeanScope.newBuilder()
7474
.withBean(Pump.class, mock)
7575
.build()) {
7676

inject-test/src/test/java/org/example/coffee/BeanContext_Builder_mockitoSpyTest.java renamed to inject-test/src/test/java/org/example/coffee/BeanScope_Builder_mockitoSpyTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.example.coffee;
22

3-
import io.avaje.inject.BeanContext;
3+
import io.avaje.inject.BeanScope;
44
import org.example.coffee.factory.SomeImpl;
55
import org.example.coffee.factory.SomeImplBean;
66
import org.example.coffee.factory.Unused;
@@ -18,15 +18,15 @@
1818
import static org.assertj.core.api.Assertions.assertThat;
1919
import static org.mockito.Mockito.*;
2020

21-
public class BeanContext_Builder_mockitoSpyTest {
21+
public class BeanScope_Builder_mockitoSpyTest {
2222

2323
@Test
2424
public void withBeans_asMocks() {
2525

2626
Pump pump = mock(Pump.class);
2727
Grinder grinder = mock(Grinder.class);
2828

29-
try (BeanContext context = BeanContext.newBuilder()
29+
try (BeanScope context = BeanScope.newBuilder()
3030
.withBeans(pump, grinder)
3131
.build()) {
3232

@@ -47,7 +47,7 @@ public void withBeans_asMocks() {
4747
@Test
4848
public void withMockitoSpy_noSetup_expect_spyUsed() {
4949

50-
try (BeanContext context = BeanContext.newBuilder()
50+
try (BeanScope context = BeanScope.newBuilder()
5151
.withSpy(Pump.class)
5252
.build()) {
5353

@@ -63,7 +63,7 @@ public void withMockitoSpy_noSetup_expect_spyUsed() {
6363
@Test
6464
public void withMockitoSpy_postLoadSetup_expect_spyUsed() {
6565

66-
try (BeanContext context = BeanContext.newBuilder()
66+
try (BeanScope context = BeanScope.newBuilder()
6767
.withSpy(Pump.class)
6868
.withSpy(Grinder.class)
6969
.build()) {
@@ -86,7 +86,7 @@ public void withMockitoSpy_postLoadSetup_expect_spyUsed() {
8686
@Test
8787
public void withMockitoSpy_expect_spyUsed() {
8888

89-
try (BeanContext context = BeanContext.newBuilder()
89+
try (BeanScope context = BeanScope.newBuilder()
9090
.withSpy(Pump.class, pump -> {
9191
// setup the spy
9292
doNothing().when(pump).pumpWater();
@@ -109,7 +109,7 @@ public void withMockitoSpy_expect_spyUsed() {
109109
@Test
110110
public void withMockitoSpy_whenPrimary_expect_spyUsed() {
111111

112-
try (BeanContext context = BeanContext.newBuilder()
112+
try (BeanScope context = BeanScope.newBuilder()
113113
.withSpy(PEmailer.class) // has a primary
114114
.build()) {
115115

@@ -124,7 +124,7 @@ public void withMockitoSpy_whenPrimary_expect_spyUsed() {
124124
@Test
125125
public void withMockitoSpy_whenOnlySecondary_expect_spyUsed() {
126126

127-
try (BeanContext context = BeanContext.newBuilder()
127+
try (BeanScope context = BeanScope.newBuilder()
128128
.withSpy(Widget.class) // only secondary
129129
.build()) {
130130

@@ -144,7 +144,7 @@ public void withMockitoSpy_whenOnlySecondary_expect_spyUsed() {
144144
@Test
145145
public void withMockitoSpy_whenSecondary_expect_spyUsed() {
146146

147-
try (BeanContext context = BeanContext.newBuilder()
147+
try (BeanScope context = BeanScope.newBuilder()
148148
.withSpy(Something.class) // has a secondary and a normal
149149
.build()) {
150150

@@ -168,7 +168,7 @@ public void withMockitoMock_expect_mockUsed() {
168168

169169
AtomicReference<Grinder> mock = new AtomicReference<>();
170170

171-
try (BeanContext context = BeanContext.newBuilder()
171+
try (BeanScope context = BeanScope.newBuilder()
172172
.withMock(Pump.class)
173173
.withMock(Grinder.class, grinder -> {
174174
// setup the mock

inject-test/src/test/java/org/example/coffee/CoffeeMakerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.example.coffee;
22

33
import io.avaje.inject.ApplicationScope;
4-
import io.avaje.inject.BeanContext;
4+
import io.avaje.inject.BeanScope;
55
import io.avaje.inject.SystemContext;
66
import org.example.coffee.core.DuperPump;
77
import org.junit.jupiter.api.Test;
@@ -26,7 +26,7 @@ public void makeIt_via_SystemContext() {
2626
@Test
2727
public void makeIt_via_BootContext_withNoShutdownHook() {
2828

29-
try (BeanContext context = BeanContext.newBuilder()
29+
try (BeanScope context = BeanScope.newBuilder()
3030
.withNoShutdownHook()
3131
.build()) {
3232

@@ -38,7 +38,7 @@ public void makeIt_via_BootContext_withNoShutdownHook() {
3838
@Test
3939
public void makeIt_via_BootContext() {
4040

41-
try (BeanContext context = BeanContext.newBuilder().build()) {
41+
try (BeanScope context = BeanScope.newBuilder().build()) {
4242
String makeIt = context.getBean(CoffeeMaker.class).makeIt();
4343
assertThat(makeIt).isEqualTo("done");
4444
}

inject-test/src/test/java/org/example/coffee/ExtensionExample.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.example.coffee;
22

3-
import io.avaje.inject.BeanContext;
4-
import io.avaje.inject.BeanContextBuilder;
3+
import io.avaje.inject.BeanScope;
4+
import io.avaje.inject.BeanScopeBuilder;
55

66
import java.util.List;
77

@@ -15,8 +15,8 @@ class ExtensionExample {
1515
this.withSpies = withSpies;
1616
}
1717

18-
BeanContext build() {
19-
BeanContextBuilder bootContext = BeanContext.newBuilder();
18+
BeanScope build() {
19+
BeanScopeBuilder bootContext = BeanScope.newBuilder();
2020
withMocks.forEach(bootContext::withMock);
2121
withSpies.forEach(bootContext::withSpy);
2222
return bootContext.build();

inject-test/src/test/java/org/example/coffee/ExtensionExampleTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.example.coffee;
22

3-
import io.avaje.inject.BeanContext;
4-
import io.avaje.inject.BeanContextBuilder;
3+
import io.avaje.inject.BeanScope;
4+
import io.avaje.inject.BeanScopeBuilder;
55
import org.example.coffee.qualifier.SomeStore;
66
import org.example.coffee.secondary.SEmailer;
77
import org.example.coffee.secondary.Widget;
@@ -16,12 +16,12 @@ public class ExtensionExampleTest {
1616
public void checkForCompilerWarningsOnly_notATestThatRuns() {
1717

1818
ExtensionExample extensionExample = new ExtensionExample(asList(Widget.class, SEmailer.class), asList(SomeStore.class));
19-
BeanContext context = extensionExample.build();
19+
BeanScope context = extensionExample.build();
2020

2121
Class cls0 = Widget.class;
2222
Class<?> cls1 = SEmailer.class;
2323

24-
BeanContextBuilder bootContext = BeanContext.newBuilder()
24+
BeanScopeBuilder bootContext = BeanScope.newBuilder()
2525
.withSpy(cls0)
2626
.withSpy(cls1)
2727
.withMock(cls0)

inject-test/src/test/java/org/example/coffee/FactoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.example.coffee;
22

3-
import io.avaje.inject.BeanContext;
3+
import io.avaje.inject.BeanScope;
44
import org.example.coffee.factory.BFact;
55
import org.junit.jupiter.api.Test;
66

@@ -11,7 +11,7 @@ public class FactoryTest {
1111
@Test
1212
public void test() {
1313

14-
try (BeanContext context = BeanContext.newBuilder().build()) {
14+
try (BeanScope context = BeanScope.newBuilder().build()) {
1515
BFact bean = context.getBean(BFact.class);
1616
String b = bean.b();
1717
assertThat(b).isNotNull();

inject-test/src/test/java/org/example/coffee/InjectListTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.example.coffee;
22

3-
import io.avaje.inject.BeanContext;
3+
import io.avaje.inject.BeanScope;
44
import org.example.coffee.list.CombinedSetSomei;
55
import org.example.coffee.list.CombinedSomei;
66
import org.junit.jupiter.api.Test;
@@ -13,7 +13,7 @@ public class InjectListTest {
1313

1414
@Test
1515
public void test() {
16-
try (BeanContext context = BeanContext.newBuilder().build()) {
16+
try (BeanScope context = BeanScope.newBuilder().build()) {
1717
CombinedSomei bean = context.getBean(CombinedSomei.class);
1818
List<String> somes = bean.lotsOfSomes();
1919
assertThat(somes).containsOnly("a", "b", "a2");
@@ -22,7 +22,7 @@ public void test() {
2222

2323
@Test
2424
public void test_set() {
25-
try (BeanContext context = BeanContext.newBuilder().build()) {
25+
try (BeanScope context = BeanScope.newBuilder().build()) {
2626
CombinedSetSomei bean = context.getBean(CombinedSetSomei.class);
2727
List<String> somes = bean.lotsOfSomes();
2828
assertThat(somes).containsOnly("a", "b", "a2");

inject-test/src/test/java/org/example/coffee/ProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.example.coffee;
22

3-
import io.avaje.inject.BeanContext;
3+
import io.avaje.inject.BeanScope;
44
import org.example.coffee.provider.ProvOther;
55
import org.example.coffee.provider.ProvOther2;
66
import org.junit.jupiter.api.Test;
@@ -12,7 +12,7 @@ public class ProviderTest {
1212
@Test
1313
public void test() {
1414

15-
try (BeanContext context = BeanContext.newBuilder().build()) {
15+
try (BeanScope context = BeanScope.newBuilder().build()) {
1616

1717
ProvOther bean = context.getBean(ProvOther.class);
1818
String other = bean.other();

inject-test/src/test/java/org/example/coffee/circular/CircularDependencyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.example.coffee.circular;
22

3-
import io.avaje.inject.BeanContext;
3+
import io.avaje.inject.BeanScope;
44
import org.junit.jupiter.api.Test;
55

66
import static org.assertj.core.api.Assertions.assertThat;
@@ -9,7 +9,7 @@ class CircularDependencyTest {
99

1010
@Test
1111
void wire() {
12-
try (BeanContext context = BeanContext.newBuilder().build()) {
12+
try (BeanScope context = BeanScope.newBuilder().build()) {
1313
assertThat(context.getBean(CircA.class)).isNotNull();
1414
assertThat(context.getBean(CircB.class)).isNotNull();
1515
assertThat(context.getBean(CircC.class)).isNotNull();

0 commit comments

Comments
 (0)