You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2020/03/08 22:57:19 UTC

[logging-log4j2] 02/04: Merge Scoped into Bean

This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch mean-bean-machine
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit b4d7cfc1a51fd8bfccb54445b62880e72c839c9b
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Sun Mar 8 15:19:36 2020 -0500

    Merge Scoped into Bean
    
    As the interfaces were initially separated in CDI due to their support for interceptors and decorators, that distinction is not necessary here.
    
    Signed-off-by: Matt Sicker <bo...@gmail.com>
---
 .../{ScopedInstance.java => BeanInstance.java}     |  6 +--
 ...copedInstance.java => DefaultBeanInstance.java} | 16 +++---
 .../plugins/defaults/bean/DefaultBeanManager.java  | 13 +++--
 .../bean/DefaultInitializationContext.java         | 56 ++++++++++-----------
 .../plugins/defaults/bean/DefaultScopeContext.java | 28 +++++------
 .../defaults/bean/DependentScopeContext.java       | 12 ++---
 ...zyScopedInstance.java => LazyBeanInstance.java} | 18 +++----
 .../logging/log4j/plugins/spi/bean/Bean.java       | 20 +++++++-
 .../log4j/plugins/spi/bean/BeanManager.java        | 10 ++--
 .../plugins/spi/bean/InitializationContext.java    | 17 +++----
 .../log4j/plugins/spi/bean/ScopeContext.java       | 22 ++++-----
 .../logging/log4j/plugins/spi/bean/Scoped.java     | 57 ----------------------
 .../logging/log4j/plugins/spi/model/Variable.java  |  5 ++
 13 files changed, 122 insertions(+), 158 deletions(-)

diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/ScopedInstance.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/BeanInstance.java
similarity index 87%
rename from log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/ScopedInstance.java
rename to log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/BeanInstance.java
index 196d303..f47e889 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/ScopedInstance.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/BeanInstance.java
@@ -17,10 +17,10 @@
 
 package org.apache.logging.log4j.plugins.defaults.bean;
 
-import org.apache.logging.log4j.plugins.spi.bean.Scoped;
+import org.apache.logging.log4j.plugins.spi.bean.Bean;
 
-interface ScopedInstance<T> extends AutoCloseable {
-    Scoped<T> getScoped();
+interface BeanInstance<T> extends AutoCloseable {
+    Bean<T> getBean();
 
     T getInstance();
 
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultScopedInstance.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultBeanInstance.java
similarity index 75%
rename from log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultScopedInstance.java
rename to log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultBeanInstance.java
index 4548d08..2f5a5d3 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultScopedInstance.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultBeanInstance.java
@@ -17,25 +17,25 @@
 
 package org.apache.logging.log4j.plugins.defaults.bean;
 
+import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.bean.InitializationContext;
-import org.apache.logging.log4j.plugins.spi.bean.Scoped;
 
 import java.util.Objects;
 
-class DefaultScopedInstance<T> implements ScopedInstance<T> {
-    private final Scoped<T> scoped;
+class DefaultBeanInstance<T> implements BeanInstance<T> {
+    private final Bean<T> bean;
     private final T instance;
     private final InitializationContext<T> context;
 
-    DefaultScopedInstance(final Scoped<T> scoped, final T instance, final InitializationContext<T> context) {
-        this.scoped = Objects.requireNonNull(scoped);
+    DefaultBeanInstance(final Bean<T> bean, final T instance, final InitializationContext<T> context) {
+        this.bean = Objects.requireNonNull(bean);
         this.instance = Objects.requireNonNull(instance);
         this.context = Objects.requireNonNull(context);
     }
 
     @Override
-    public Scoped<T> getScoped() {
-        return scoped;
+    public Bean<T> getBean() {
+        return bean;
     }
 
     @Override
@@ -45,6 +45,6 @@ class DefaultScopedInstance<T> implements ScopedInstance<T> {
 
     @Override
     public void close() {
-        scoped.destroy(instance, context);
+        bean.destroy(instance, context);
     }
 }
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultBeanManager.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultBeanManager.java
index 87bffc2..b1a5334 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultBeanManager.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultBeanManager.java
@@ -17,9 +17,9 @@
 
 package org.apache.logging.log4j.plugins.defaults.bean;
 
+import org.apache.logging.log4j.plugins.api.Dependent;
 import org.apache.logging.log4j.plugins.api.Disposes;
 import org.apache.logging.log4j.plugins.api.Produces;
-import org.apache.logging.log4j.plugins.api.Dependent;
 import org.apache.logging.log4j.plugins.api.Provider;
 import org.apache.logging.log4j.plugins.api.Singleton;
 import org.apache.logging.log4j.plugins.defaults.model.DefaultElementManager;
@@ -31,9 +31,11 @@ import org.apache.logging.log4j.plugins.spi.UnsatisfiedBeanException;
 import org.apache.logging.log4j.plugins.spi.ValidationException;
 import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.bean.BeanManager;
+import org.apache.logging.log4j.plugins.spi.bean.InitializationContext;
 import org.apache.logging.log4j.plugins.spi.bean.InjectionFactory;
 import org.apache.logging.log4j.plugins.spi.bean.InjectionTargetFactory;
 import org.apache.logging.log4j.plugins.spi.bean.ProducerFactory;
+import org.apache.logging.log4j.plugins.spi.bean.ScopeContext;
 import org.apache.logging.log4j.plugins.spi.model.ElementManager;
 import org.apache.logging.log4j.plugins.spi.model.InjectionPoint;
 import org.apache.logging.log4j.plugins.spi.model.MetaClass;
@@ -44,9 +46,6 @@ import org.apache.logging.log4j.plugins.spi.model.MetaMethod;
 import org.apache.logging.log4j.plugins.spi.model.MetaParameter;
 import org.apache.logging.log4j.plugins.spi.model.Qualifiers;
 import org.apache.logging.log4j.plugins.spi.model.Variable;
-import org.apache.logging.log4j.plugins.spi.bean.InitializationContext;
-import org.apache.logging.log4j.plugins.spi.bean.ScopeContext;
-import org.apache.logging.log4j.plugins.spi.bean.Scoped;
 import org.apache.logging.log4j.plugins.util.ParameterizedTypeImpl;
 import org.apache.logging.log4j.plugins.util.TypeUtil;
 
@@ -356,8 +355,8 @@ public class DefaultBeanManager implements BeanManager {
     }
 
     @Override
-    public <T> InitializationContext<T> createInitializationContext(final Scoped<T> scoped) {
-        return new DefaultInitializationContext<>(scoped);
+    public <T> InitializationContext<T> createInitializationContext(final Bean<T> bean) {
+        return new DefaultInitializationContext<>(bean);
     }
 
     @Override
@@ -398,7 +397,7 @@ public class DefaultBeanManager implements BeanManager {
         }
         final Optional<Bean<?>> bean;
         if (pointBean.isDependentScoped() && !resolvedBean.isDependentScoped()) {
-            bean = parentContext.getNonDependentScopedDependent().filter(Bean.class::isInstance).map(TypeUtil::cast);
+            bean = parentContext.getNonDependentScopedDependent();
         } else {
             bean = Optional.of(pointBean);
         }
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInitializationContext.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInitializationContext.java
index d3c6350..9e00a66 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInitializationContext.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultInitializationContext.java
@@ -17,8 +17,8 @@
 
 package org.apache.logging.log4j.plugins.defaults.bean;
 
+import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.bean.InitializationContext;
-import org.apache.logging.log4j.plugins.spi.bean.Scoped;
 import org.apache.logging.log4j.plugins.util.TypeUtil;
 
 import java.util.List;
@@ -29,25 +29,25 @@ import java.util.concurrent.CopyOnWriteArrayList;
 
 public class DefaultInitializationContext<T> implements InitializationContext<T> {
 
-    private final Scoped<T> scoped;
-    private Map<Scoped<?>, Object> incompleteInstances;
-    private final List<ScopedInstance<?>> dependentInstances = new CopyOnWriteArrayList<>();
-    private final List<ScopedInstance<?>> parentDependentInstances;
+    private final Bean<T> bean;
+    private Map<Bean<?>, Object> incompleteInstances;
+    private final List<BeanInstance<?>> dependentInstances = new CopyOnWriteArrayList<>();
+    private final List<BeanInstance<?>> parentDependentInstances;
     private final InitializationContext<?> parentContext;
 
-    public DefaultInitializationContext(final Scoped<T> scoped) {
-        this(scoped, null, new CopyOnWriteArrayList<>(), null);
+    public DefaultInitializationContext(final Bean<T> bean) {
+        this(bean, null, new CopyOnWriteArrayList<>(), null);
     }
 
-    private DefaultInitializationContext(final Scoped<T> scoped, final Map<Scoped<?>, Object> incompleteInstances) {
-        this(scoped, incompleteInstances, new CopyOnWriteArrayList<>(), null);
+    private DefaultInitializationContext(final Bean<T> bean, final Map<Bean<?>, Object> incompleteInstances) {
+        this(bean, incompleteInstances, new CopyOnWriteArrayList<>(), null);
     }
 
-    private DefaultInitializationContext(final Scoped<T> scoped, final Map<Scoped<?>, Object> incompleteInstances,
-                                         final List<ScopedInstance<?>> parentDependentInstances,
+    private DefaultInitializationContext(final Bean<T> bean, final Map<Bean<?>, Object> incompleteInstances,
+                                         final List<BeanInstance<?>> parentDependentInstances,
                                          final InitializationContext<?> parentContext) {
 
-        this.scoped = scoped;
+        this.bean = bean;
         this.incompleteInstances = incompleteInstances;
         this.parentDependentInstances = parentDependentInstances;
         this.parentContext = parentContext;
@@ -58,51 +58,51 @@ public class DefaultInitializationContext<T> implements InitializationContext<T>
         if (incompleteInstances == null) {
             incompleteInstances = new ConcurrentHashMap<>();
         }
-        if (scoped != null) {
-            incompleteInstances.put(scoped, incompleteInstance);
+        if (bean != null) {
+            incompleteInstances.put(bean, incompleteInstance);
         }
     }
 
     @Override
-    public boolean isTrackingDependencies(final Scoped<T> scoped) {
+    public boolean isTrackingDependencies(final Bean<T> bean) {
         return !dependentInstances.isEmpty() ||
-                (scoped instanceof AbstractBean<?, ?> && ((AbstractBean<?, ?>) scoped).isTrackingDependencies());
+                (bean instanceof AbstractBean<?, ?> && ((AbstractBean<?, ?>) bean).isTrackingDependencies());
     }
 
     @Override
     public void addDependentInstance(final T dependentInstance) {
-        parentDependentInstances.add(new DefaultScopedInstance<>(scoped, dependentInstance, this));
+        parentDependentInstances.add(new DefaultBeanInstance<>(bean, dependentInstance, this));
     }
 
     @Override
-    public Optional<Scoped<?>> getNonDependentScopedDependent() {
-        if (parentContext == null || scoped == null) {
+    public Optional<Bean<?>> getNonDependentScopedDependent() {
+        if (parentContext == null || bean == null) {
             return Optional.empty();
         }
-        return scoped.isDependentScoped() ? parentContext.getNonDependentScopedDependent() : Optional.of(scoped);
+        return bean.isDependentScoped() ? parentContext.getNonDependentScopedDependent() : Optional.of(bean);
     }
 
     @Override
-    public <S> InitializationContext<S> createDependentContext(final Scoped<S> scoped) {
-        return new DefaultInitializationContext<>(scoped, incompleteInstances, dependentInstances, this);
+    public <S> InitializationContext<S> createDependentContext(final Bean<S> bean) {
+        return new DefaultInitializationContext<>(bean, incompleteInstances, dependentInstances, this);
     }
 
     @Override
-    public <S> InitializationContext<S> createIndependentContext(final Scoped<S> scoped) {
-        return new DefaultInitializationContext<>(scoped, incompleteInstances == null ? null : new ConcurrentHashMap<>(incompleteInstances));
+    public <S> InitializationContext<S> createIndependentContext(final Bean<S> bean) {
+        return new DefaultInitializationContext<>(bean, incompleteInstances == null ? null : new ConcurrentHashMap<>(incompleteInstances));
     }
 
     @Override
-    public <S> Optional<S> getIncompleteInstance(final Scoped<S> scoped) {
+    public <S> Optional<S> getIncompleteInstance(final Bean<S> bean) {
         return Optional.ofNullable(incompleteInstances)
-                .map(map -> map.get(scoped))
+                .map(map -> map.get(bean))
                 .map(TypeUtil::cast);
     }
 
     @Override
     public void close() {
-        for (final ScopedInstance<?> dependentInstance : dependentInstances) {
-            if (!(scoped != null && scoped.equals(dependentInstance.getScoped()))) {
+        for (final BeanInstance<?> dependentInstance : dependentInstances) {
+            if (dependentInstance.getBean().equals(bean)) {
                 dependentInstance.close();
             }
         }
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultScopeContext.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultScopeContext.java
index 0fc5f6d..e0a5965 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultScopeContext.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DefaultScopeContext.java
@@ -17,9 +17,9 @@
 
 package org.apache.logging.log4j.plugins.defaults.bean;
 
+import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.bean.InitializationContext;
 import org.apache.logging.log4j.plugins.spi.bean.ScopeContext;
-import org.apache.logging.log4j.plugins.spi.bean.Scoped;
 import org.apache.logging.log4j.plugins.util.TypeUtil;
 
 import java.lang.annotation.Annotation;
@@ -29,7 +29,7 @@ import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class DefaultScopeContext implements ScopeContext {
-    private final Map<Scoped<?>, ScopedInstance<?>> cache = new ConcurrentHashMap<>();
+    private final Map<Bean<?>, BeanInstance<?>> cache = new ConcurrentHashMap<>();
     private final Class<? extends Annotation> scopeType;
 
     public DefaultScopeContext(final Class<? extends Annotation> scopeType) {
@@ -42,24 +42,24 @@ public class DefaultScopeContext implements ScopeContext {
     }
 
     @Override
-    public <T> T getOrCreate(final Scoped<T> scoped, final InitializationContext<T> context) {
-        final ScopedInstance<T> scopedInstance =
-                TypeUtil.cast(cache.computeIfAbsent(scoped, ignored -> new LazyScopedInstance<>(scoped, context)));
-        return scopedInstance.getInstance();
+    public <T> T getOrCreate(final Bean<T> bean, final InitializationContext<T> context) {
+        final BeanInstance<T> beanInstance =
+                TypeUtil.cast(cache.computeIfAbsent(bean, ignored -> new LazyBeanInstance<>(bean, context)));
+        return beanInstance.getInstance();
     }
 
     @Override
-    public <T> Optional<T> getIfExists(final Scoped<T> scoped) {
-        final ScopedInstance<T> scopedInstance = TypeUtil.cast(cache.get(scoped));
-        return scopedInstance == null ? Optional.empty() : Optional.of(scopedInstance.getInstance());
+    public <T> Optional<T> getIfExists(final Bean<T> bean) {
+        final BeanInstance<T> beanInstance = TypeUtil.cast(cache.get(bean));
+        return beanInstance == null ? Optional.empty() : Optional.of(beanInstance.getInstance());
     }
 
     @Override
-    public void destroy(final Scoped<?> scoped) {
-        final ScopedInstance<?> scopedInstance = cache.get(scoped);
-        if (scopedInstance != null) {
-            scopedInstance.close();
-            cache.remove(scoped, scopedInstance);
+    public void destroy(final Bean<?> bean) {
+        final BeanInstance<?> beanInstance = cache.get(bean);
+        if (beanInstance != null) {
+            beanInstance.close();
+            cache.remove(bean, beanInstance);
         }
     }
 
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DependentScopeContext.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DependentScopeContext.java
index 57554eb..2a7a4be 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DependentScopeContext.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/DependentScopeContext.java
@@ -18,9 +18,9 @@
 package org.apache.logging.log4j.plugins.defaults.bean;
 
 import org.apache.logging.log4j.plugins.api.Dependent;
+import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.bean.InitializationContext;
 import org.apache.logging.log4j.plugins.spi.bean.ScopeContext;
-import org.apache.logging.log4j.plugins.spi.bean.Scoped;
 
 import java.lang.annotation.Annotation;
 import java.util.Optional;
@@ -32,24 +32,24 @@ public class DependentScopeContext implements ScopeContext {
     }
 
     @Override
-    public <T> T getOrCreate(final Scoped<T> scoped, final InitializationContext<T> context) {
+    public <T> T getOrCreate(final Bean<T> bean, final InitializationContext<T> context) {
         if (context == null) {
             return null;
         }
-        final T instance = scoped.create(context);
-        if (context.isTrackingDependencies(scoped)) {
+        final T instance = bean.create(context);
+        if (context.isTrackingDependencies(bean)) {
             context.addDependentInstance(instance);
         }
         return instance;
     }
 
     @Override
-    public <T> Optional<T> getIfExists(final Scoped<T> scoped) {
+    public <T> Optional<T> getIfExists(final Bean<T> bean) {
         return Optional.empty();
     }
 
     @Override
-    public void destroy(final Scoped<?> scoped) {
+    public void destroy(final Bean<?> bean) {
     }
 
     @Override
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/LazyScopedInstance.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/LazyBeanInstance.java
similarity index 75%
rename from log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/LazyScopedInstance.java
rename to log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/LazyBeanInstance.java
index 64c1cb8..970fef9 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/LazyScopedInstance.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/bean/LazyBeanInstance.java
@@ -17,24 +17,24 @@
 
 package org.apache.logging.log4j.plugins.defaults.bean;
 
+import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.bean.InitializationContext;
-import org.apache.logging.log4j.plugins.spi.bean.Scoped;
 
 import java.util.Objects;
 
-class LazyScopedInstance<T> implements ScopedInstance<T> {
-    private final Scoped<T> scoped;
+class LazyBeanInstance<T> implements BeanInstance<T> {
+    private final Bean<T> bean;
     private final InitializationContext<T> context;
     private volatile T instance;
 
-    LazyScopedInstance(final Scoped<T> scoped, final InitializationContext<T> context) {
-        this.scoped = Objects.requireNonNull(scoped);
+    LazyBeanInstance(final Bean<T> bean, final InitializationContext<T> context) {
+        this.bean = Objects.requireNonNull(bean);
         this.context = Objects.requireNonNull(context);
     }
 
     @Override
-    public Scoped<T> getScoped() {
-        return scoped;
+    public Bean<T> getBean() {
+        return bean;
     }
 
     @Override
@@ -42,7 +42,7 @@ class LazyScopedInstance<T> implements ScopedInstance<T> {
         if (instance == null) {
             synchronized (this) {
                 if (instance == null) {
-                    instance = scoped.create(context);
+                    instance = bean.create(context);
                 }
             }
         }
@@ -51,7 +51,7 @@ class LazyScopedInstance<T> implements ScopedInstance<T> {
 
     @Override
     public void close() {
-        scoped.destroy(instance, context);
+        bean.destroy(instance, context);
         instance = null;
     }
 }
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/Bean.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/Bean.java
index 2fecd0c..3e93e2f 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/Bean.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/Bean.java
@@ -23,7 +23,25 @@ import org.apache.logging.log4j.plugins.spi.model.Variable;
 
 import java.util.Collection;
 
-public interface Bean<T> extends Scoped<T>, Variable<T> {
+public interface Bean<T> extends Variable<T> {
+    /**
+     * Creates a new instance of this bean. The given {@link InitializationContext} should be used by implementations
+     * to track dependent objects.
+     *
+     * @param context the context in which the instance is being managed
+     * @return a managed, initialized instance
+     */
+    T create(final InitializationContext<T> context);
+
+    /**
+     * Destroys a managed instance in the given context. Implementations should call {@link InitializationContext#close()} to
+     * allow dependent objects to be destroyed.
+     *
+     * @param instance the managed instance to destroy
+     * @param context  the context in which the instance is being managed
+     */
+    void destroy(final T instance, final InitializationContext<T> context);
+
     Collection<InjectionPoint<?>> getInjectionPoints();
 
     // for a managed bean: that class
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/BeanManager.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/BeanManager.java
index e8cd275..a66d1b1 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/BeanManager.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/BeanManager.java
@@ -60,13 +60,13 @@ public interface BeanManager extends AutoCloseable {
 //    Collection<Bean<?>> getBeans();
 
     /**
-     * Creates an InitializationContext for a given Scoped instance for use in dependency injection SPIs.
+     * Creates an InitializationContext for a given Bean instance for use in dependency injection SPIs.
      *
-     * @param scoped scoped object to create an initialization context for
-     * @param <T>    type of object created by scope
-     * @return new InitializationContext for the given Scoped
+     * @param bean bean to create an initialization context for
+     * @param <T>  type of object created by bean
+     * @return new InitializationContext for the given Bean
      */
-    <T> InitializationContext<T> createInitializationContext(final Scoped<T> scoped);
+    <T> InitializationContext<T> createInitializationContext(final Bean<T> bean);
 
     /**
      * Gets or creates the value for a given bean inside a given InitializationContext.
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/InitializationContext.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/InitializationContext.java
index 117342e..b13b849 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/InitializationContext.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/InitializationContext.java
@@ -20,35 +20,34 @@ package org.apache.logging.log4j.plugins.spi.bean;
 import java.util.Optional;
 
 /**
- * Provides operations used by {@link Scoped} implementations for tracking lifecycle state.
+ * Provides operations used by {@link Bean} implementations for tracking lifecycle state.
  */
 public interface InitializationContext<T> extends AutoCloseable {
     /**
      * Pushes an incomplete instance state. An instance is not completely initialized until it is returned from
-     * {@link Scoped#create(InitializationContext)}.
+     * {@link Bean#create(InitializationContext)}.
      *
      * @param incompleteInstance incompletely initialized instance
      */
     void addIncompleteInstance(final T incompleteInstance);
 
     // TODO: this API is needlessly complicated currently
-    boolean isTrackingDependencies(final Scoped<T> scoped);
+    boolean isTrackingDependencies(final Bean<T> bean);
 
     void addDependentInstance(T dependentInstance);
 
-    // TODO: consider returning Optional<Bean<?>> or flattening Scoped into Bean
-    Optional<Scoped<?>> getNonDependentScopedDependent();
+    Optional<Bean<?>> getNonDependentScopedDependent();
 
-    <S> Optional<S> getIncompleteInstance(Scoped<S> scoped);
+    <S> Optional<S> getIncompleteInstance(Bean<S> bean);
 
     // dependent contexts share the same incomplete instances
-    <S> InitializationContext<S> createDependentContext(Scoped<S> scoped);
+    <S> InitializationContext<S> createDependentContext(Bean<S> bean);
 
     // independent contexts are used by producers to get their declaring bean separately
-    <S> InitializationContext<S> createIndependentContext(Scoped<S> scoped);
+    <S> InitializationContext<S> createIndependentContext(Bean<S> bean);
 
     /**
-     * Destroys all dependent objects by propagating them to {@link Scoped#destroy(Object, InitializationContext)}.
+     * Destroys all dependent objects by propagating them to {@link Bean#destroy(Object, InitializationContext)}.
      */
     @Override
     void close();
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/ScopeContext.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/ScopeContext.java
index ced2798..ac154ae 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/ScopeContext.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/ScopeContext.java
@@ -23,7 +23,7 @@ import java.lang.annotation.Annotation;
 import java.util.Optional;
 
 /**
- * Manages {@link Scoped} instances within a particular {@linkplain ScopeType scope}.
+ * Manages {@link Bean} instances within a particular {@linkplain ScopeType scope}.
  */
 public interface ScopeContext extends AutoCloseable {
 
@@ -33,30 +33,30 @@ public interface ScopeContext extends AutoCloseable {
     Class<? extends Annotation> getScopeType();
 
     /**
-     * Gets or {@linkplain Scoped#create(InitializationContext) creates} a scoped instance of a specific type.
+     * Gets or {@linkplain Bean#create(InitializationContext) creates} a bean instance of a specific type.
      *
-     * @param scoped the managed type
+     * @param bean    the bean to get or create an instance of
      * @param context the context to create a new instance in
      * @param <T>     the instance type being managed
      * @return the new or existing instance
      */
-    <T> T getOrCreate(final Scoped<T> scoped, final InitializationContext<T> context);
+    <T> T getOrCreate(final Bean<T> bean, final InitializationContext<T> context);
 
     /**
-     * Returns an existing scoped instance if it exists.
+     * Returns an existing bean instance if it exists.
      *
-     * @param scoped the managed type
-     * @param <T>     the instance type being managed
+     * @param bean the bean to look up an existing instance of
+     * @param <T>  the instance type being managed
      * @return the existing instance or empty
      */
-    <T> Optional<T> getIfExists(final Scoped<T> scoped);
+    <T> Optional<T> getIfExists(final Bean<T> bean);
 
     /**
-     * Destroys the existing scoped instance of a specified type if it exists or otherwise does nothing.
+     * Destroys the existing bean instance of a specified type if it exists or otherwise does nothing.
      *
-     * @param scoped the managed type
+     * @param bean the managed type
      */
-    void destroy(final Scoped<?> scoped);
+    void destroy(final Bean<?> bean);
 
     @Override
     void close();
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/Scoped.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/Scoped.java
deleted file mode 100644
index 7953435..0000000
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/bean/Scoped.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.logging.log4j.plugins.spi.bean;
-
-import org.apache.logging.log4j.plugins.api.Dependent;
-import org.apache.logging.log4j.plugins.api.Singleton;
-
-import java.lang.annotation.Annotation;
-
-/**
- * Manages the creation and destruction of instances of a specific type within a particular scope context. Scopes
- * provide managed life-cycles for objects such as {@linkplain Singleton singleton} and {@linkplain Dependent dependent}.
- *
- * @param <T> type of managed instance
- * @see org.apache.logging.log4j.plugins.api.ScopeType
- */
-public interface Scoped<T> {
-
-    /**
-     * Creates a new instance of this managed type. The given {@link InitializationContext} should be used by implementations
-     * to track dependent objects.
-     *
-     * @param context the context in which the instance is being managed
-     * @return a managed, initialized instance
-     */
-    T create(final InitializationContext<T> context);
-
-    /**
-     * Destroys a managed instance in the given context. Implementations should call {@link InitializationContext#close()} to
-     * allow dependent objects to be destroyed.
-     *
-     * @param instance the managed instance to destroy
-     * @param context  the context in which the instance is being managed
-     */
-    void destroy(final T instance, final InitializationContext<T> context);
-
-    Class<? extends Annotation> getScopeType();
-
-    default boolean isDependentScoped() {
-        return getScopeType() == Dependent.class;
-    }
-}
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/model/Variable.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/model/Variable.java
index bb8db73..c11748d 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/model/Variable.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/spi/model/Variable.java
@@ -17,6 +17,7 @@
 
 package org.apache.logging.log4j.plugins.spi.model;
 
+import org.apache.logging.log4j.plugins.api.Dependent;
 import org.apache.logging.log4j.plugins.util.TypeUtil;
 
 import java.lang.annotation.Annotation;
@@ -38,4 +39,8 @@ public interface Variable<T> {
     Qualifiers getQualifiers();
 
     Class<? extends Annotation> getScopeType();
+
+    default boolean isDependentScoped() {
+        return getScopeType() == Dependent.class;
+    }
 }