Repository: avaje/avaje-inject
Pull request #112 (2021-05-17 12:24:30)

Rename ContextModule to InjectModule and BeanContextFactory to BeanScopeFactory


Patch:
diff --git a/README.md b/README.md
index ba6d1235..2dc34e4c 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,8 @@ module org.example {
 
   requires io.avaje.inject;
 
-  // register org.example._DI$BeanContextFactory from generated sources
-  provides io.avaje.inject.spi.BeanContextFactory with org.example._DI$BeanContextFactory;
+  // register org.example._DI$BeanScopeFactory from generated sources
+  provides io.avaje.inject.spi.BeanScopeFactory with org.example._DI$BeanScopeFactory;
 }
 ```
 
diff --git a/inject-generator/pom.xml b/inject-generator/pom.xml
index b872e91a..2fd21e5b 100644
--- a/inject-generator/pom.xml
+++ b/inject-generator/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>io.avaje</groupId>
     <artifactId>avaje-inject-parent</artifactId>
-    <version>4.4</version>
+    <version>6.0.RC1</version>
   </parent>
 
   <artifactId>avaje-inject-generator</artifactId>
@@ -16,7 +16,7 @@
     <dependency>
       <groupId>io.avaje</groupId>
       <artifactId>avaje-inject</artifactId>
-      <version>4.4</version>
+      <version>6.0.RC1</version>
     </dependency>
 
     <!-- test dependencies -->
diff --git a/inject-generator/src/main/java/io/avaje/inject/generator/Constants.java b/inject-generator/src/main/java/io/avaje/inject/generator/Constants.java
index 8e3157d1..77824778 100644
--- a/inject-generator/src/main/java/io/avaje/inject/generator/Constants.java
+++ b/inject-generator/src/main/java/io/avaje/inject/generator/Constants.java
@@ -17,16 +17,16 @@ class Constants {
 
   static final String AT_SINGLETON = "@Singleton";
   static final String AT_GENERATED = "@Generated(\"io.avaje.inject.generator\")";
-  static final String META_INF_FACTORY = "META-INF/services/io.avaje.inject.spi.BeanContextFactory";
+  static final String META_INF_FACTORY = "META-INF/services/io.avaje.inject.spi.BeanScopeFactory";
 
   static final String REQUESTSCOPE = "io.avaje.inject.RequestScope";
   static final String BEANCONTEXT = "io.avaje.inject.BeanScope";
-  static final String CONTEXTMODULE = "io.avaje.inject.ContextModule";
+  static final String INJECTMODULE = "io.avaje.inject.InjectModule";
 
   static final String GENERATED = "io.avaje.inject.spi.Generated";
   static final String BEAN_FACTORY = "io.avaje.inject.spi.BeanFactory";
   static final String BEAN_FACTORY2 = "io.avaje.inject.spi.BeanFactory2";
   static final String BUILDER = "io.avaje.inject.spi.Builder";
   static final String DEPENDENCYMETA = "io.avaje.inject.spi.DependencyMeta";
-  static final String BEANCONTEXTFACTORY = "io.avaje.inject.spi.BeanContextFactory";
+  static final String BEANSCOPEFACTORY = "io.avaje.inject.spi.BeanScopeFactory";
 }
diff --git a/inject-generator/src/main/java/io/avaje/inject/generator/ProcessingContext.java b/inject-generator/src/main/java/io/avaje/inject/generator/ProcessingContext.java
index 7c29d0de..fceb759a 100644
--- a/inject-generator/src/main/java/io/avaje/inject/generator/ProcessingContext.java
+++ b/inject-generator/src/main/java/io/avaje/inject/generator/ProcessingContext.java
@@ -151,9 +151,9 @@ class ProcessingContext {
     writer.append(";").eol();
   }
 
-  void buildAtContextModule(Append writer) {
+  void buildAtInjectModule(Append writer) {
     writer.append(Constants.AT_GENERATED).eol();
-    writer.append("@ContextModule(name=\"%s\"", contextName);
+    writer.append("@InjectModule(name=\"%s\"", contextName);
     if (!isEmpty(contextProvides)) {
       writer.append(", provides=");
       buildStringArray(writer, contextProvides, false);
diff --git a/inject-generator/src/main/java/io/avaje/inject/generator/Processor.java b/inject-generator/src/main/java/io/avaje/inject/generator/Processor.java
index 24efe30b..91741f15 100644
--- a/inject-generator/src/main/java/io/avaje/inject/generator/Processor.java
+++ b/inject-generator/src/main/java/io/avaje/inject/generator/Processor.java
@@ -1,6 +1,6 @@
 package io.avaje.inject.generator;
 
-import io.avaje.inject.ContextModule;
+import io.avaje.inject.InjectModule;
 import io.avaje.inject.Factory;
 import io.avaje.inject.Request;
 import io.avaje.inject.spi.DependencyMeta;
@@ -61,7 +61,7 @@ public class Processor extends AbstractProcessor {
   public Set<String> getSupportedAnnotationTypes() {
 
     Set<String> annotations = new LinkedHashSet<>();
-    annotations.add(ContextModule.class.getCanonicalName());
+    annotations.add(InjectModule.class.getCanonicalName());
     annotations.add(Factory.class.getCanonicalName());
     annotations.add(Singleton.class.getCanonicalName());
     annotations.add(Constants.CONTROLLER);
@@ -197,7 +197,7 @@ public class Processor extends AbstractProcessor {
   }
 
   /**
-   * Read the existing meta data from ContextModule (if found) and the factory bean (if exists).
+   * Read the existing meta data from InjectModule (if found) and the factory bean (if exists).
    */
   private void readModule(RoundEnvironment roundEnv) {
     String factory = context.loadMetaInfServices();
@@ -208,12 +208,12 @@ public class Processor extends AbstractProcessor {
       }
     }
 
-    Set<? extends Element> elementsAnnotatedWith = roundEnv.getElementsAnnotatedWith(ContextModule.class);
+    Set<? extends Element> elementsAnnotatedWith = roundEnv.getElementsAnnotatedWith(InjectModule.class);
     if (!elementsAnnotatedWith.isEmpty()) {
       Iterator<? extends Element> iterator = elementsAnnotatedWith.iterator();
       if (iterator.hasNext()) {
         Element element = iterator.next();
-        ContextModule annotation = element.getAnnotation(ContextModule.class);
+        InjectModule annotation = element.getAnnotation(InjectModule.class);
         if (annotation != null) {
           context.setContextDetails(annotation.name(), annotation.provides(), annotation.dependsOn(), element);
         }
@@ -227,7 +227,7 @@ public class Processor extends AbstractProcessor {
    * which holds the information we need (to regenerate the factory with any changes).
    */
   private void readFactory(TypeElement factoryType) {
-    ContextModule module = factoryType.getAnnotation(ContextModule.class);
+    InjectModule module = factoryType.getAnnotation(InjectModule.class);
     context.setContextDetails(module.name(), module.provides(), module.dependsOn(), factoryType);
 
     List<? extends Element> elements = factoryType.getEnclosedElements();
diff --git a/inject-generator/src/main/java/io/avaje/inject/generator/SimpleFactoryWriter.java b/inject-generator/src/main/java/io/avaje/inject/generator/SimpleFactoryWriter.java
index 33c25f5e..4900bd72 100644
--- a/inject-generator/src/main/java/io/avaje/inject/generator/SimpleFactoryWriter.java
+++ b/inject-generator/src/main/java/io/avaje/inject/generator/SimpleFactoryWriter.java
@@ -24,7 +24,7 @@ class SimpleFactoryWriter {
       " *   module example {\n" +
       " *     requires io.avaje.inject;\n" +
       " *     \n" +
-      " *     provides io.avaje.inject.spi.BeanContextFactory with %s._DI$BeanContextFactory;\n" +
+      " *     provides io.avaje.inject.spi.BeanScopeFactory with %s._DI$BeanScopeFactory;\n" +
       " *     \n" +
       " *   }\n" +
       " * \n" +
@@ -56,7 +56,7 @@ class SimpleFactoryWriter {
     String pkg = context.getContextPackage();
     this.factoryPackage = (pkg != null) ? pkg : ordering.getTopPackage();
     context.deriveContextName(factoryPackage);
-    this.factoryShortName = "_DI$BeanContextFactory";
+    this.factoryShortName = "_DI$BeanScopeFactory";
     this.factoryFullName = factoryPackage + "." + factoryShortName;
   }
 
@@ -126,18 +126,18 @@ class SimpleFactoryWriter {
     Set<String> importTypes = new TreeSet<>();
     importTypes.add(Constants.GENERATED);
     importTypes.add(Constants.BEANCONTEXT);
-    importTypes.add(Constants.CONTEXTMODULE);
+    importTypes.add(Constants.INJECTMODULE);
     importTypes.add(Constants.DEPENDENCYMETA);
-    importTypes.add(Constants.BEANCONTEXTFACTORY);
+    importTypes.add(Constants.BEANSCOPEFACTORY);
     importTypes.add(Constants.BUILDER);
     return importTypes;
   }
 
   private void writeStartClass() {
     writer.append(CODE_COMMENT_FACTORY, context.contextName(), factoryPackage).eol();
-    context.buildAtContextModule(writer);
+    context.buildAtInjectModule(writer);
 
-    writer.append("public class %s implements BeanContextFactory {", factoryShortName).eol().eol();
+    writer.append("public class %s implements BeanScopeFactory {", factoryShortName).eol().eol();
     writer.append("  private final String name;").eol();
     writer.append("  private final String[] provides;").eol();
     writer.append("  private final String[] dependsOn;").eol();
diff --git a/inject/README.md b/inject/README.md
index c2f7446d..7c3f05d9 100644
--- a/inject/README.md
+++ b/inject/README.md
@@ -4,12 +4,14 @@ APT based dependency injection for server side developers - https://avaje.io/inj
 ### Example module use
 
 ```java
+import io.avaje.inject.spi.BeanScopeFactory;
+
 module org.example {
 
-  requires io.avaje.inject;
+    requires io.avaje.inject;
 
-  // register org.example._DI$BeanContextFactory from generated sources
-  provides io.avaje.inject.spi.BeanContextFactory with org.example._DI$BeanContextFactory;
+    // register org.example._DI$BeanScopeFactory from generated sources
+    provides io.avaje.inject.spi.BeanScopeFactory with org.example._DI$BeanScopeFactory;
 }
 ```
 
diff --git a/inject/pom.xml b/inject/pom.xml
index 9f116c70..348b985b 100644
--- a/inject/pom.xml
+++ b/inject/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>io.avaje</groupId>
     <artifactId>avaje-inject-parent</artifactId>
-    <version>4.4</version>
+    <version>6.0.RC1</version>
   </parent>
 
   <artifactId>avaje-inject</artifactId>
diff --git a/inject/src/main/java/io/avaje/inject/ApplicationScope.java b/inject/src/main/java/io/avaje/inject/ApplicationScope.java
index c7fa4184..0a6b0f6f 100644
--- a/inject/src/main/java/io/avaje/inject/ApplicationScope.java
+++ b/inject/src/main/java/io/avaje/inject/ApplicationScope.java
@@ -3,9 +3,9 @@ package io.avaje.inject;
 import java.util.List;
 
 /**
- * Provides a global system wide BeanContext that contains all the bean contexts in the classpath.
+ * Provides a global system wide BeanScope that contains all the beans.
  * <p>
- * This will automatically get all the bean contexts and wire them all as necessary. It will use
+ * This will automatically get all the beans and wire them all as necessary. It will use
  * a shutdown hook to fire any <code>@PreDestroy</code> methods on beans.
  * </p>
  *
@@ -41,7 +41,7 @@ public class ApplicationScope {
   }
 
   /**
-   * Return the underlying BeanContext.
+   * Return the underlying BeanScope.
    */
   public static BeanScope scope() {
     return appScope;
@@ -140,6 +140,35 @@ public class ApplicationScope {
   /**
    * Start building a RequestScope.
    *
+   * <pre>{@code
+   *
+   *   try (RequestScope requestScope = ApplicationScope.newRequestScope()
+   *       // supply some instances
+   *       .withBean(HttpRequest.class, request)
+   *       .withBean(HttpResponse.class, response)
+   *       .build()) {
+   *
+   *       MyController controller = requestScope.get(MyController.class);
+   *       controller.process();
+   *
+   *   }
+   *
+   *   ...
+   *
+   *   // define request scoped beans
+   *   @Request
+   *   MyController {
+   *
+   *     // can depend on supplied instances, singletons and other request scope beans
+   *     @Inject
+   *     MyController(HttpRequest request, HttpResponse response, MyService myService) {
+   *       ...
+   *     }
+   *
+   *   }
+   *
+   * }</pre>
+   *
    * @return The request scope builder
    */
   public static RequestScopeBuilder newRequestScope() {
diff --git a/inject/src/main/java/io/avaje/inject/BeanEntry.java b/inject/src/main/java/io/avaje/inject/BeanEntry.java
index 4caa7f87..5f429de4 100644
--- a/inject/src/main/java/io/avaje/inject/BeanEntry.java
+++ b/inject/src/main/java/io/avaje/inject/BeanEntry.java
@@ -6,7 +6,7 @@ package io.avaje.inject;
 public class BeanEntry<T> {
 
   /**
-   * An explicitly supplied bean. See BeanContextBuilder.
+   * An explicitly supplied bean. See BeanScopeBuilder.
    */
   public static final int SUPPLIED = 2;
 
diff --git a/inject/src/main/java/io/avaje/inject/BeanScope.java b/inject/src/main/java/io/avaje/inject/BeanScope.java
index eaa919ed..e55a42aa 100644
--- a/inject/src/main/java/io/avaje/inject/BeanScope.java
+++ b/inject/src/main/java/io/avaje/inject/BeanScope.java
@@ -45,7 +45,7 @@ import java.util.List;
 public interface BeanScope extends Closeable {
 
   /**
-   * Build a bean context with options for shutdown hook and supplying test doubles.
+   * Build a bean scope with options for shutdown hook and supplying test doubles.
    * <p>
    * We would choose to use BeanScopeBuilder in test code (for component testing)
    * as it gives us the ability to inject test doubles, mocks, spy's etc.
@@ -70,7 +70,6 @@ public interface BeanScope extends Closeable {
    *       assertThat(...
    *     }
    *   }
-   *
    * }</pre>
    */
   static BeanScopeBuilder newBuilder() {
@@ -80,6 +79,34 @@ public interface BeanScope extends Closeable {
   /**
    * Create a RequestScope via builder where we provide extra instances
    * that can be used/included in wiring request scoped beans.
+   *
+   * <pre>{@code
+   *
+   *   try (RequestScope requestScope = beanScope.newRequestScope()
+   *       // supply some instances
+   *       .withBean(HttpRequest.class, request)
+   *       .withBean(HttpResponse.class, response)
+   *       .build()) {
+   *
+   *       MyController controller = requestScope.get(MyController.class);
+   *       controller.process();
+   *   }
+   *
+   *   ...
+   *
+   *   // define request scoped beans
+   *   @Request
+   *   MyController {
+   *
+   *     // can depend on supplied instances, singletons and other request scope beans
+   *     @Inject
+   *     MyController(HttpRequest request, HttpResponse response, MyService myService) {
+   *       ...
+   *     }
+   *
+   *   }
+   *
+   * }</pre>
    */
   RequestScopeBuilder newRequestScope();
 
diff --git a/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java b/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java
index 6316527a..4db202e3 100644
--- a/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java
+++ b/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java
@@ -3,9 +3,9 @@ package io.avaje.inject;
 import java.util.function.Consumer;
 
 /**
- * Build a bean context with options for shutdown hook and supplying test doubles.
+ * Build a bean scope with options for shutdown hook and supplying test doubles.
  * <p>
- * We would choose to use BeanContextBuilder in test code (for component testing) as it gives us
+ * We would choose to use BeanScopeBuilder in test code (for component testing) as it gives us
  * the ability to inject test doubles, mocks, spy's etc.
  * </p>
  *
@@ -34,9 +34,9 @@ import java.util.function.Consumer;
 public interface BeanScopeBuilder {
 
   /**
-   * Create the bean context without registering a shutdown hook.
+   * Create the bean scope without registering a shutdown hook.
    * <p>
-   * The expectation is that the BeanContextBuilder is closed via code or via using
+   * The expectation is that the BeanScopeBuilder is closed via code or via using
    * try with resources.
    * </p>
    * <pre>{@code
@@ -89,12 +89,12 @@ public interface BeanScopeBuilder {
    * }</pre>
    *
    * @param modules The names of modules that we want to include in dependency injection.
-   * @return This BeanContextBuilder
+   * @return This BeanScopeBuilder
    */
   BeanScopeBuilder withModules(String... modules);
 
   /**
-   * Set this when building a BeanContext (typically for testing) and supplied beans replace module dependencies.
+   * Set this when building a BeanScope (typically for testing) and supplied beans replace module dependencies.
    * This means we don't need the usual module dependencies as supplied beans are used instead.
    */
   BeanScopeBuilder withIgnoreMissingModuleDependencies();
@@ -132,7 +132,7 @@ public interface BeanScopeBuilder {
    * }</pre>
    *
    * @param beans The bean used when injecting a dependency for this bean or the interface(s) it implements
-   * @return This BeanContextBuilder
+   * @return This BeanScopeBuilder
    */
   BeanScopeBuilder withBeans(Object... beans);
 
@@ -286,9 +286,9 @@ public interface BeanScopeBuilder {
   <D> BeanScopeBuilder withSpy(Class<D> type, Consumer<D> consumer);
 
   /**
-   * Build and return the bean context.
+   * Build and return the bean scope.
    *
-   * @return The BeanContext
+   * @return The BeanScope
    */
   BeanScope build();
 }
diff --git a/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java b/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java
index 89bbeee1..5177b624 100644
--- a/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java
+++ b/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java
@@ -1,19 +1,17 @@
 package io.avaje.inject;
 
-import io.avaje.inject.spi.BeanContextFactory;
+import io.avaje.inject.spi.BeanScopeFactory;
 import io.avaje.inject.spi.Builder;
 import io.avaje.inject.spi.EnrichBean;
 import io.avaje.inject.spi.SuppliedBean;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.lang.annotation.Annotation;
 import java.util.*;
-import java.util.concurrent.locks.ReentrantLock;
 import java.util.function.Consumer;
 
 /**
- * Build a bean context with options for shutdown hook and supplying test doubles.
+ * Build a bean scope with options for shutdown hook and supplying test doubles.
  */
 class DBeanScopeBuilder implements BeanScopeBuilder {
 
@@ -32,7 +30,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
   private boolean ignoreMissingModuleDependencies;
 
   /**
-   * Create a BeanContextBuilder to ultimately load and return a new BeanContext.
+   * Create a BeanScopeBuilder to ultimately load and return a new BeanScope.
    */
   DBeanScopeBuilder() {
   }
@@ -101,7 +99,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
   public BeanScope build() {
     // sort factories by dependsOn
     FactoryOrder factoryOrder = new FactoryOrder(includeModules, !suppliedBeans.isEmpty(), ignoreMissingModuleDependencies);
-    ServiceLoader.load(BeanContextFactory.class).forEach(factoryOrder::add);
+    ServiceLoader.load(BeanScopeFactory.class).forEach(factoryOrder::add);
 
     Set<String> moduleNames = factoryOrder.orderFactories();
     if (moduleNames.isEmpty()) {
@@ -113,7 +111,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
     }
     log.debug("building context with modules {}", moduleNames);
     Builder builder = Builder.newBuilder(suppliedBeans, enrichBeans);
-    for (BeanContextFactory factory : factoryOrder.factories()) {
+    for (BeanScopeFactory factory : factoryOrder.factories()) {
       factory.build(builder);
     }
     return builder.build(shutdownHook);
@@ -142,7 +140,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
     private final boolean ignoreMissingModuleDependencies;
 
     private final Set<String> moduleNames = new LinkedHashSet<>();
-    private final List<BeanContextFactory> factories = new ArrayList<>();
+    private final List<BeanScopeFactory> factories = new ArrayList<>();
     private final List<FactoryState> queue = new ArrayList<>();
     private final List<FactoryState> queueNoDependencies = new ArrayList<>();
 
@@ -154,7 +152,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
       this.ignoreMissingModuleDependencies = ignoreMissingModuleDependencies;
     }
 
-    void add(BeanContextFactory factory) {
+    void add(BeanScopeFactory factory) {
 
       if (includeModule(factory)) {
         FactoryState wrappedFactory = new FactoryState(factory);
@@ -186,7 +184,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
     /**
      * Return true of the factory (for the module) should be included.
      */
-    private boolean includeModule(BeanContextFactory factory) {
+    private boolean includeModule(BeanScopeFactory factory) {
       return includeModules.isEmpty() || includeModules.contains(factory.getName());
     }
 
@@ -215,7 +213,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
     /**
      * Return the list of factories in the order they should be built.
      */
-    List<BeanContextFactory> factories() {
+    List<BeanScopeFactory> factories() {
       return factories;
     }
 
@@ -248,7 +246,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
         }
 
         sb.append(". Modules that were loaded ok are:").append(moduleNames);
-        sb.append(". Consider using BeanContextBuilder.withIgnoreMissingModuleDependencies() or BeanContextBuilder.withSuppliedBeans(...)");
+        sb.append(". Consider using BeanScopeBuilder.withIgnoreMissingModuleDependencies() or BeanScopeBuilder.withSuppliedBeans(...)");
         throw new IllegalStateException(sb.toString());
       }
     }
@@ -294,10 +292,10 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
    */
   private static class FactoryState {
 
-    private final BeanContextFactory factory;
+    private final BeanScopeFactory factory;
     private boolean pushed;
 
-    private FactoryState(BeanContextFactory factory) {
+    private FactoryState(BeanScopeFactory factory) {
       this.factory = factory;
     }
 
@@ -312,7 +310,7 @@ class DBeanScopeBuilder implements BeanScopeBuilder {
       return pushed;
     }
 
-    BeanContextFactory getFactory() {
+    BeanScopeFactory getFactory() {
       return factory;
     }
 
diff --git a/inject/src/main/java/io/avaje/inject/ContextModule.java b/inject/src/main/java/io/avaje/inject/InjectModule.java
similarity index 91%
rename from inject/src/main/java/io/avaje/inject/ContextModule.java
rename to inject/src/main/java/io/avaje/inject/InjectModule.java
index 153d4ffd..3f0c32d5 100644
--- a/inject/src/main/java/io/avaje/inject/ContextModule.java
+++ b/inject/src/main/java/io/avaje/inject/InjectModule.java
@@ -1,14 +1,14 @@
 package io.avaje.inject;
 
 /**
- * Used to explicitly name a bean context and optionally specify if it depends on other bean contexts.
+ * Used to explicitly name a bean scope and optionally specify if it depends on other bean scopes.
  * <p>
  * If this annotation is not present then the name will be derived as the "top level package name"
  * e.g. "org.example.featuretoggle"
  * </p>
  *
  * <p>
- * Typically there is a single bean context per Jar (module). In that sense the name is the "module name" and
+ * Typically there is a single bean scope per Jar (module). In that sense the name is the "module name" and
  * the dependsOn specifies the names of modules that this depends on (provide beans that are used to wire this module).
  * </p>
  *
@@ -54,7 +54,7 @@ package io.avaje.inject;
  *
  * }</pre>
  */
-public @interface ContextModule {
+public @interface InjectModule {
 
   /**
    * The name of this context/module.
diff --git a/inject/src/main/java/io/avaje/inject/SystemContext.java b/inject/src/main/java/io/avaje/inject/SystemContext.java
index 27049a69..84899e7a 100644
--- a/inject/src/main/java/io/avaje/inject/SystemContext.java
+++ b/inject/src/main/java/io/avaje/inject/SystemContext.java
@@ -5,9 +5,9 @@ import java.util.List;
 /**
  * Deprecated - migrate to ApplicationScope.
  * <p>
- * Provides a global system wide BeanContext that contains all the bean contexts in the classpath.
+ * Provides a global system wide BeanScope that contains all the beans.
  * <p>
- * This will automatically get all the bean contexts and wire them all as necessary. It will use
+ * This will automatically get all the beans and wire them all as necessary. It will use
  * a shutdown hook to fire any <code>@PreDestroy</code> methods on beans.
  * </p>
  *
diff --git a/inject/src/main/java/io/avaje/inject/spi/BeanContextFactory.java b/inject/src/main/java/io/avaje/inject/spi/BeanContextFactory.java
deleted file mode 100644
index 88a5e7dd..00000000
--- a/inject/src/main/java/io/avaje/inject/spi/BeanContextFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.avaje.inject.spi;
-
-/**
- * This is the service loader interface defining the bean contexts that can be created.
- */
-public interface BeanContextFactory {
-
-  /**
-   * Return the name of the bean context (module) this will create.
-   */
-  String getName();
-
-  /**
-   * Return the name of module features this module provides.
-   */
-  String[] getProvides();
-
-  /**
-   * Return the names of bean contexts (modules) that this is dependent on (they need to be built before this one).
-   */
-  String[] getDependsOn();
-
-  /**
-   * Build all the beans.
-   */
-  void build(Builder builder);
-}
diff --git a/inject/src/main/java/io/avaje/inject/spi/BeanLifecycle.java b/inject/src/main/java/io/avaje/inject/spi/BeanLifecycle.java
deleted file mode 100644
index 150d3107..00000000
--- a/inject/src/main/java/io/avaje/inject/spi/BeanLifecycle.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package io.avaje.inject.spi;
-
-/**
- * Lifecycle of beans via <code>@PostConstruct</code> and <code>@PreDestroy</code>.
- */
-public interface BeanLifecycle {
-
-  /**
-   * Fire post construction.
-   */
-  void postConstruct();
-
-  /**
-   * Fire on shutdown or close of the bean context.
-   */
-  void preDestroy();
-}
diff --git a/inject/src/main/java/io/avaje/inject/spi/BeanScopeFactory.java b/inject/src/main/java/io/avaje/inject/spi/BeanScopeFactory.java
new file mode 100644
index 00000000..4d4a2f7a
--- /dev/null
+++ b/inject/src/main/java/io/avaje/inject/spi/BeanScopeFactory.java
@@ -0,0 +1,27 @@
+package io.avaje.inject.spi;
+
+/**
+ * This is the service loader interface defining the bean scope.
+ */
+public interface BeanScopeFactory {
+
+  /**
+   * Return the name of the bean scope (module) this will create.
+   */
+  String getName();
+
+  /**
+   * Return the name of module features this module provides.
+   */
+  String[] getProvides();
+
+  /**
+   * Return the names of bean scopes (modules) that this is dependent on (they need to be built before this one).
+   */
+  String[] getDependsOn();
+
+  /**
+   * Build all the beans.
+   */
+  void build(Builder builder);
+}
diff --git a/inject/src/main/java/io/avaje/inject/spi/Builder.java b/inject/src/main/java/io/avaje/inject/spi/Builder.java
index 131cf2fe..6f16e00e 100644
--- a/inject/src/main/java/io/avaje/inject/spi/Builder.java
+++ b/inject/src/main/java/io/avaje/inject/spi/Builder.java
@@ -11,7 +11,7 @@ import java.util.Set;
 import java.util.function.Consumer;
 
 /**
- * Mutable builder object used when building a bean context.
+ * Mutable builder object used when building a bean scope.
  */
 public interface Builder {
 
@@ -161,7 +161,7 @@ public interface Builder {
   <T> T enrich(T bean, Class<?>[] types);
 
   /**
-   * Build and return the bean context.
+   * Build and return the bean scope.
    */
   BeanScope build(boolean withShutdownHook);
 }
diff --git a/inject/src/main/java/io/avaje/inject/spi/package-info.java b/inject/src/main/java/io/avaje/inject/spi/package-info.java
index 64f0a09f..bb28c487 100644
--- a/inject/src/main/java/io/avaje/inject/spi/package-info.java
+++ b/inject/src/main/java/io/avaje/inject/spi/package-info.java
@@ -1,4 +1,4 @@
 /**
- * Building bean context objects expected to only be used by generated code.
+ * Building bean scope objects expected to only be used by generated code.
  */
 package io.avaje.inject.spi;
diff --git a/pom.xml b/pom.xml
index 22c4402e..e8cf0f7d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
 
   <groupId>io.avaje</groupId>
   <artifactId>avaje-inject-parent</artifactId>
-  <version>4.4</version>
+  <version>6.0.RC1</version>
   <packaging>pom</packaging>
   <name>avaje inject parent</name>
   <description>parent pom for avaje inject library</description>


Test patch:
diff --git a/inject-test/pom.xml b/inject-test/pom.xml
index 4d6630d5..de18073d 100644
--- a/inject-test/pom.xml
+++ b/inject-test/pom.xml
@@ -4,7 +4,7 @@
   <parent>
     <groupId>io.avaje</groupId>
     <artifactId>avaje-inject-parent</artifactId>
-    <version>4.4</version>
+    <version>6.0.RC1</version>
   </parent>
 
   <artifactId>avaje-inject-test</artifactId>
diff --git a/inject-test/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java b/inject-test/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java
index e30c6e60..be0bf952 100644
--- a/inject-test/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java
+++ b/inject-test/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java
@@ -1,6 +1,6 @@
 package io.avaje.inject;
 
-import io.avaje.inject.spi.BeanContextFactory;
+import io.avaje.inject.spi.BeanScopeFactory;
 import io.avaje.inject.spi.Builder;
 import org.junit.jupiter.api.Test;
 
@@ -86,27 +86,27 @@ public class BeanScopeBuilderTest {
     assertThat(names(factoryOrder.factories())).containsExactly("one", "three", "two");
   }
 
-  private List<String> names(List<BeanContextFactory> factories) {
+  private List<String> names(List<BeanScopeFactory> factories) {
     return factories.stream()
-      .map(BeanContextFactory::getName)
+      .map(BeanScopeFactory::getName)
       .collect(Collectors.toList());
   }
 
-  private TDBeanContext bc(String name, String provides, String dependsOn) {
-    return new TDBeanContext(name, split(provides), split(dependsOn));
+  private TDBeanScope bc(String name, String provides, String dependsOn) {
+    return new TDBeanScope(name, split(provides), split(dependsOn));
   }
 
   private String[] split(String val) {
     return val == null ? null : val.split(",");
   }
 
-  private static class TDBeanContext implements BeanContextFactory {
+  private static class TDBeanScope implements BeanScopeFactory {
 
     final String name;
     final String[] provides;
     final String[] dependsOn;
 
-    private TDBeanContext(String name, String[] provides, String[] dependsOn) {
+    private TDBeanScope(String name, String[] provides, String[] dependsOn) {
       this.name = name;
       this.provides = provides;
       this.dependsOn = dependsOn;
diff --git a/inject/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java b/inject/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java
index e30c6e60..be0bf952 100644
--- a/inject/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java
+++ b/inject/src/test/java/io/avaje/inject/BeanScopeBuilderTest.java
@@ -1,6 +1,6 @@
 package io.avaje.inject;
 
-import io.avaje.inject.spi.BeanContextFactory;
+import io.avaje.inject.spi.BeanScopeFactory;
 import io.avaje.inject.spi.Builder;
 import org.junit.jupiter.api.Test;
 
@@ -86,27 +86,27 @@ public class BeanScopeBuilderTest {
     assertThat(names(factoryOrder.factories())).containsExactly("one", "three", "two");
   }
 
-  private List<String> names(List<BeanContextFactory> factories) {
+  private List<String> names(List<BeanScopeFactory> factories) {
     return factories.stream()
-      .map(BeanContextFactory::getName)
+      .map(BeanScopeFactory::getName)
       .collect(Collectors.toList());
   }
 
-  private TDBeanContext bc(String name, String provides, String dependsOn) {
-    return new TDBeanContext(name, split(provides), split(dependsOn));
+  private TDBeanScope bc(String name, String provides, String dependsOn) {
+    return new TDBeanScope(name, split(provides), split(dependsOn));
   }
 
   private String[] split(String val) {
     return val == null ? null : val.split(",");
   }
 
-  private static class TDBeanContext implements BeanContextFactory {
+  private static class TDBeanScope implements BeanScopeFactory {
 
     final String name;
     final String[] provides;
     final String[] dependsOn;
 
-    private TDBeanContext(String name, String[] provides, String[] dependsOn) {
+    private TDBeanScope(String name, String[] provides, String[] dependsOn) {
       this.name = name;
       this.provides = provides;
       this.dependsOn = dependsOn;