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

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 8a9086f  Context API refactoring.
8a9086f is described below

commit 8a9086f75a26af4fe10084e1e69c1a27acdff408
Author: JamesBognar <[email protected]>
AuthorDate: Sat Sep 11 13:31:31 2021 -0400

    Context API refactoring.
---
 .../java/org/apache/juneau/mstat/ThrownStore.java  | 144 ++++++++++++++++++++-
 .../apache/juneau/mstat/ThrownStoreBuilder.java    | 131 -------------------
 .../java/org/apache/juneau/rest/RestContext.java   |  98 +-------------
 .../org/apache/juneau/rest/RestContextBuilder.java | 101 ++++++++++++++-
 .../org/apache/juneau/mstat/ThrownStore_Test.java  |  17 +--
 5 files changed, 242 insertions(+), 249 deletions(-)

diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/mstat/ThrownStore.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/mstat/ThrownStore.java
index d0c0400..ca0bb34 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/mstat/ThrownStore.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/mstat/ThrownStore.java
@@ -14,6 +14,8 @@ package org.apache.juneau.mstat;
 
 import static java.util.stream.Collectors.*;
 import static java.util.Collections.*;
+import static org.apache.juneau.internal.ClassUtils.*;
+import static org.apache.juneau.internal.ExceptionUtils.*;
 import static org.apache.juneau.internal.ObjectUtils.*;
 import static java.util.Optional.*;
 import static java.util.Comparator.*;
@@ -21,6 +23,8 @@ import static java.util.Comparator.*;
 import java.util.*;
 import java.util.concurrent.*;
 
+import org.apache.juneau.*;
+import org.apache.juneau.collections.*;
 import org.apache.juneau.cp.*;
 
 /**
@@ -45,8 +49,8 @@ public class ThrownStore {
         *
         * @return A new builder for this object.
         */
-       public static ThrownStoreBuilder create() {
-               return new ThrownStoreBuilder();
+       public static Builder create() {
+               return new Builder();
        }
 
        /**
@@ -61,7 +65,7 @@ public class ThrownStore {
         *
         * @param builder The builder for this object.
         */
-       public ThrownStore(ThrownStoreBuilder builder) {
+       public ThrownStore(Builder builder) {
                this.parent = ofNullable(builder.parent);
                this.beanStore = 
ofNullable(builder.beanStore).orElseGet(()->BeanStore.create().build());
 
@@ -78,6 +82,140 @@ public class ThrownStore {
        }
 
        /**
+        * The builder for this object.
+        */
+       public static class Builder {
+
+               ThrownStore parent;
+               Class<? extends ThrownStore> implClass;
+               ThrownStore impl;
+               BeanStore beanStore;
+               Class<? extends ThrownStats> statsImplClass;
+               Set<Class<?>> ignoreClasses;
+
+               /**
+                * Constructor.
+                */
+               protected Builder() {}
+
+               /**
+                * Copy constructor.
+                *
+                * @param copyFrom The builder to copy.
+                */
+               protected Builder(Builder copyFrom) {
+                       parent = copyFrom.parent;
+                       implClass = copyFrom.implClass;
+                       impl = copyFrom.impl;
+                       beanStore = copyFrom.beanStore;
+                       statsImplClass = copyFrom.statsImplClass;
+                       ignoreClasses = copyFrom.ignoreClasses == null ? null : 
ASet.of(copyFrom.ignoreClasses);
+               }
+
+               /**
+                * Create a new {@link ThrownStore} using this builder.
+                *
+                * @return A new {@link ThrownStore}
+                */
+               public ThrownStore build() {
+                       try {
+                               if (impl != null)
+                                       return impl;
+                               Class<? extends ThrownStore> ic = 
isConcrete(implClass) ? implClass : ThrownStore.class;
+                               return 
BeanStore.of(beanStore).addBeans(Builder.class, this).createBean(ic);
+                       } catch (ExecutableException e) {
+                               throw runtimeException(e);
+                       }
+               }
+
+               /**
+                * Specifies the bean store to use for instantiating the {@link 
ThrownStore} object.
+                *
+                * <p>
+                * Can be used to instantiate {@link ThrownStore} 
implementations with injected constructor argument beans.
+                *
+                * @param value The new value for this setting.
+                * @return  This object (for method chaining).
+                */
+               public Builder beanStore(BeanStore value) {
+                       this.beanStore = value;
+                       return this;
+               }
+
+               /**
+                * Specifies a subclass of {@link ThrownStore} to create when 
the {@link #build()} method is called.
+                *
+                * @param value The new value for this setting.
+                * @return  This object (for method chaining).
+                */
+               public Builder implClass(Class<? extends ThrownStore> value) {
+                       this.implClass = value;
+                       return this;
+               }
+
+               /**
+                * Specifies a pre-instantiated bean to return when the {@link 
#build()} method is called.
+                *
+                * @param value The new value for this setting.
+                * @return  This object (for method chaining).
+                */
+               public Builder impl(ThrownStore value) {
+                       this.impl = value;
+                       return this;
+               }
+
+               /**
+                * Specifies a subclass of {@link ThrownStats} to use for 
individual method statistics.
+                *
+                * @param value The new value for this setting.
+                * @return  This object (for method chaining).
+                */
+               public Builder statsImplClass(Class<? extends ThrownStats> 
value) {
+                       this.statsImplClass = value;
+                       return this;
+               }
+
+               /**
+                * Specifies the parent store of this store.
+                *
+                * <p>
+                * Parent stores are used for aggregating statistics across 
multiple child stores.
+                * <br>The {@link ThrownStore#GLOBAL} store can be used for 
aggregating all thrown exceptions in a single JVM.
+                *
+                * @param value The parent store.  Can be <jk>null</jk>.
+                * @return This object (for method chaining).
+                */
+               public Builder parent(ThrownStore value) {
+                       this.parent = value;
+                       return this;
+               }
+
+               /**
+                * Specifies the list of classes to ignore when calculating 
stack traces.
+                *
+                * <p>
+                * Stack trace elements that are the specified class will be 
ignored.
+                *
+                * @param value The list of classes to ignore.
+                * @return This object (for method chaining).
+                */
+               public Builder ignoreClasses(Class<?>...value) {
+                       this.ignoreClasses = ASet.of(value);
+                       return this;
+               }
+
+               /**
+                * Creates a copy of this builder.
+                *
+                * @return A copy of this builder.
+                */
+               public Builder copy() {
+                       return new Builder(this);
+               }
+       }
+
+
+       /**
         * Adds the specified thrown exception to this database.
         *
         * @param e The exception to add.
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/mstat/ThrownStoreBuilder.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/mstat/ThrownStoreBuilder.java
deleted file mode 100644
index 6d0efd1..0000000
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/mstat/ThrownStoreBuilder.java
+++ /dev/null
@@ -1,131 +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.juneau.mstat;
-
-import static org.apache.juneau.internal.ClassUtils.*;
-import static org.apache.juneau.internal.ExceptionUtils.*;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.collections.*;
-import org.apache.juneau.cp.*;
-import org.apache.juneau.internal.*;
-
-/**
- * Builder for {@link ThrownStore} objects.
- */
-@FluentSetters
-public class ThrownStoreBuilder {
-
-       ThrownStore parent;
-       private Class<? extends ThrownStore> implClass;
-       BeanStore beanStore;
-       Class<? extends ThrownStats> statsImplClass;
-       Set<Class<?>> ignoreClasses;
-
-       /**
-        * Create a new {@link ThrownStore} using this builder.
-        *
-        * @return A new {@link ThrownStore}
-        */
-       public ThrownStore build() {
-               try {
-                       Class<? extends ThrownStore> ic = isConcrete(implClass) 
? implClass : getDefaultImplClass();
-                       return 
BeanStore.of(beanStore).addBeans(ThrownStoreBuilder.class, this).createBean(ic);
-               } catch (ExecutableException e) {
-                       throw runtimeException(e);
-               }
-       }
-
-       /**
-        * Specifies the default implementation class if not specified via 
{@link #implClass(Class)}.
-        *
-        * @return The default implementation class if not specified via {@link 
#implClass(Class)}.
-        */
-       protected Class<? extends ThrownStore> getDefaultImplClass() {
-               return ThrownStore.class;
-       }
-
-       /**
-        * Specifies the bean store to use for instantiating the {@link 
ThrownStore} object.
-        *
-        * <p>
-        * Can be used to instantiate {@link ThrownStore} implementations with 
injected constructor argument beans.
-        *
-        * @param value The new value for this setting.
-        * @return  This object (for method chaining).
-        */
-       @FluentSetter
-       public ThrownStoreBuilder beanStore(BeanStore value) {
-               this.beanStore = value;
-               return this;
-       }
-
-       /**
-        * Specifies a subclass of {@link ThrownStore} to create when the 
{@link #build()} method is called.
-        *
-        * @param value The new value for this setting.
-        * @return  This object (for method chaining).
-        */
-       @FluentSetter
-       public ThrownStoreBuilder implClass(Class<? extends ThrownStore> value) 
{
-               this.implClass = value;
-               return this;
-       }
-
-       /**
-        * Specifies a subclass of {@link ThrownStats} to use for individual 
method statistics.
-        *
-        * @param value The new value for this setting.
-        * @return  This object (for method chaining).
-        */
-       @FluentSetter
-       public ThrownStoreBuilder statsImplClass(Class<? extends ThrownStats> 
value) {
-               this.statsImplClass = value;
-               return this;
-       }
-
-       /**
-        * Specifies the parent store of this store.
-        *
-        * <p>
-        * Parent stores are used for aggregating statistics across multiple 
child stores.
-        * <br>The {@link ThrownStore#GLOBAL} store can be used for aggregating 
all thrown exceptions in a single JVM.
-        *
-        * @param value The parent store.  Can be <jk>null</jk>.
-        * @return This object (for method chaining).
-        */
-       public ThrownStoreBuilder parent(ThrownStore value) {
-               this.parent = value;
-               return this;
-       }
-
-       /**
-        * Specifies the list of classes to ignore when calculating stack 
traces.
-        *
-        * <p>
-        * Stack trace elements that are the specified class will be ignored.
-        *
-        * @param value The list of classes to ignore.
-        * @return This object (for method chaining).
-        */
-       public ThrownStoreBuilder ignoreClasses(Class<?>...value) {
-               this.ignoreClasses = ASet.of(value);
-               return this;
-       }
-
-       // <FluentSetters>
-
-       // </FluentSetters>
-}
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 7fd0fbe..2d38c7e 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -248,7 +248,7 @@ public class RestContext extends Context {
                        this.resource = builder.resource;
                        Object r = getResource();
 
-                       RestContext parent = parentContext = 
builder.parentContext;
+                       parentContext = builder.parentContext;
 
                        rootBeanStore = builder.beanStore();
 
@@ -263,11 +263,9 @@ public class RestContext extends Context {
                        BeanStore bs = beanStore;
 
                        logger = bs.add(Logger.class, builder.logger());
+                       thrownStore = bs.add(ThrownStore.class, 
builder.thrownStore().build());
 
-                       ThrownStore ts = thrownStore = createThrownStore(r, 
builder, parent, bs);
-                       bs.addBean(ThrownStore.class, ts);
-
-                       methodExecStore = createMethodExecStore(r, builder, bs, 
ts);
+                       methodExecStore = createMethodExecStore(r, builder, bs, 
thrownStore);
                        bs.addBean(MethodExecStore.class, methodExecStore);
 
                        Messages m = messages = createMessages(r, builder);
@@ -285,7 +283,7 @@ public class RestContext extends Context {
                        callLoggerDefault = builder.callLoggerDefault;
                        debugDefault = builder.debugDefault;
 
-                       callLogger = createCallLogger(r, builder, bs, logger, 
ts);
+                       callLogger = createCallLogger(r, builder, bs, logger, 
thrownStore);
                        bs.addBean(RestLogger.class, callLogger);
 
                        partSerializer = createPartSerializer(r, builder, bs);
@@ -684,7 +682,6 @@ public class RestContext extends Context {
         *      The Java logger to use for logging messages.
         * @param thrownStore
         *      The thrown exception statistics store.
-        *      <br>Created by {@link 
#createThrownStore(Object,RestContextBuilder,RestContext,BeanStore)}.
         * @return The file finder for this REST resource.
         * @throws Exception If file finder could not be instantiated.
         */
@@ -735,7 +732,6 @@ public class RestContext extends Context {
         *      The Java logger to use for logging messages.
         * @param thrownStore
         *      The thrown exception statistics store.
-        *      <br>Created by {@link 
#createThrownStore(Object,RestContextBuilder,RestContext,BeanStore)}.
         * @return The call logger builder for this REST resource.
         * @throws Exception If call logger builder could not be instantiated.
         */
@@ -1211,90 +1207,6 @@ public class RestContext extends Context {
        }
 
        /**
-        * Instantiates the thrown exception store for this REST resource.
-        *
-        * <p>
-        * Instantiates based on the following logic:
-        * <ul>
-        *      <li>Looks for a static or non-static <c>createThrownStore()</> 
method that returns <c>{@link ThrownStore}</c> on the
-        *              resource class with any of the following arguments:
-        *              <ul>
-        *                      <li>{@link RestContext}
-        *                      <li>{@link BeanStore}
-        *                      <li>Any {@doc RestInjection injected beans}.
-        *              </ul>
-        *      <li>Resolves it via the bean store registered in this context.
-        *      <li>Returns {@link ThrownStore#GLOBAL}.
-        * </ul>
-        *
-        * @param resource
-        *      The REST servlet or bean that this context defines.
-        * @param builder
-        *      The builder for this object.
-        * @param parent
-        *      The parent context if the REST bean was registered via {@link 
Rest#children()}.
-        *      <br>Will be <jk>null</jk> if the bean is a top-level resource.
-        * @param beanStore
-        *      The factory used for creating beans and retrieving injected 
beans.
-        *      <br>Created by {@link RestContextBuilder#beanStore()}.
-        * @return The stack trace store for this REST resource.
-        * @throws Exception If stack trace store could not be instantiated.
-        */
-       protected ThrownStore createThrownStore(Object resource, 
RestContextBuilder builder, RestContext parent, BeanStore beanStore) throws 
Exception {
-
-               ThrownStore x = 
beanStore.getBean(ThrownStore.class).orElse(null);
-
-               if (x == null)
-                       x = createThrownStoreBuilder(resource, builder, parent, 
beanStore).build();
-
-               x = BeanStore
-                       .of(beanStore, resource)
-                       .addBean(ThrownStore.class, x)
-                       .beanCreateMethodFinder(ThrownStore.class, resource)
-                       .find("createThrownStore")
-                       .withDefault(x)
-                       .run();
-
-               return x;
-       }
-
-       /**
-        * Instantiates the thrown exception store builder for this REST 
resource.
-        *
-        * @param resource
-        *      The REST servlet or bean that this context defines.
-        * @param builder
-        *      The builder for this object.
-        * @param parent
-        *      The parent context if the REST bean was registered via {@link 
Rest#children()}.
-        *      <br>Will be <jk>null</jk> if the bean is a top-level resource.
-        * @param beanStore
-        *      The factory used for creating beans and retrieving injected 
beans.
-        *      <br>Created by {@link RestContextBuilder#beanStore()}.
-        * @return The stack trace store for this REST resource.
-        * @throws Exception If stack trace store could not be instantiated.
-        */
-       protected ThrownStoreBuilder createThrownStoreBuilder(Object resource, 
RestContextBuilder builder, RestContext parent, BeanStore beanStore) throws 
Exception {
-
-               ThrownStore p = parent == null ? null : parent.thrownStore;
-
-               ThrownStoreBuilder x = ThrownStore
-                       .create()
-                       .parent(p)
-                       .beanStore(beanStore);
-
-               x = BeanStore
-                       .of(beanStore, resource)
-                       .addBean(ThrownStoreBuilder.class, x)
-                       .beanCreateMethodFinder(ThrownStoreBuilder.class, 
resource)
-                       .find("createThrownStoreBuilder")
-                       .withDefault(x)
-                       .run();
-
-               return x;
-       }
-
-       /**
         * Instantiates the method execution statistics store for this REST 
resource.
         *
         * @param resource
@@ -1306,7 +1218,6 @@ public class RestContext extends Context {
         *      <br>Created by {@link RestContextBuilder#beanStore()}.
         * @param thrownStore
         *      The thrown exception statistics store.
-        *      <br>Created by {@link 
#createThrownStore(Object,RestContextBuilder,RestContext,BeanStore)}.
         * @return The stack trace store for this REST resource.
         * @throws Exception If stack trace store could not be instantiated.
         */
@@ -1340,7 +1251,6 @@ public class RestContext extends Context {
         *      <br>Created by {@link RestContextBuilder#beanStore()}.
         * @param thrownStore
         *      The thrown exception statistics store.
-        *      <br>Created by {@link 
#createThrownStore(Object,RestContextBuilder,RestContext,BeanStore)}.
         * @return The stack trace store for this REST resource.
         * @throws Exception If stack trace store could not be instantiated.
         */
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
index 59090a0..f710c8d 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
@@ -44,6 +44,7 @@ import org.apache.juneau.http.header.*;
 import org.apache.juneau.http.response.*;
 import org.apache.juneau.httppart.*;
 import org.apache.juneau.internal.*;
+import org.apache.juneau.mstat.*;
 import org.apache.juneau.oapi.*;
 import org.apache.juneau.parser.*;
 import org.apache.juneau.reflect.*;
@@ -105,11 +106,6 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
                }
        }
 
-       final ServletConfig inner;
-       final Class<?> resourceClass;
-       final RestContext parentContext;
-       BeanStore beanStore;
-
        
//-----------------------------------------------------------------------------------------------------------------
        // The following fields are meant to be modifiable.
        // They should not be declared final.
@@ -119,9 +115,14 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
        Supplier<?> resource;
        ServletContext servletContext;
 
+       final ServletConfig inner;
+       final Class<?> resourceClass;
+       final RestContext parentContext;
+       private BeanStore beanStore;
        private Config config;
        private VarResolver.Builder varResolver;
        private Logger logger;
+       private ThrownStore.Builder thrownStore;
 
        String
                allowedHeaderParams = env("RestContext.allowedHeaderParams", 
"Accept,Content-Type"),
@@ -781,16 +782,17 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
        protected Logger createLogger(BeanStore beanStore, Supplier<?> 
resource) {
 
                Value<Logger> v = Value.empty();
+               Object r = resource.get();
 
                beanStore.getBean(Logger.class).ifPresent(x -> v.set(x));
 
                if (v.isEmpty())
-                       v.set(Logger.getLogger(className(resource.get())));
+                       v.set(Logger.getLogger(className(r)));
 
                BeanStore
                        .of(beanStore, resource.get())
                        .addBean(Logger.class, v.get())
-                       .beanCreateMethodFinder(Logger.class, resource)
+                       .beanCreateMethodFinder(Logger.class, r)
                        .find("createLogger")
                        .execute()
                        .ifPresent(x -> v.set(x));
@@ -798,6 +800,91 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
                return v.get();
        }
 
+       /**
+        * Returns the builder for the {@link ThrownStore} object in the REST 
context.
+        *
+        * @return The builder for the {@link ThrownStore} object in the REST 
context.
+        */
+       public final ThrownStore.Builder thrownStore() {
+               if (thrownStore == null)
+                       thrownStore = createThrownStore(beanStore(), 
resource(), parentContext);
+               return thrownStore;
+       }
+
+       /**
+        * Sets the builder for the {@link ThrownStore} object in the REST 
context.
+        *
+        * @param value The builder for the {@link ThrownStore} object in the 
REST context.
+        * @return This object.
+        * @throws RuntimeException If {@link #init(Object)} has not been 
called.
+        */
+       public final RestContextBuilder thrownStore(ThrownStore value) {
+               thrownStore().impl(value);
+               return this;
+       }
+
+       /**
+        * Instantiates the thrown exception store for this REST resource.
+        *
+        * <p>
+        * Instantiates based on the following logic:
+        * <ul>
+        *      <li>Looks for a static or non-static <c>createThrownStore()</> 
method that returns <c>{@link ThrownStore}</c> on the
+        *              resource class with any of the following arguments:
+        *              <ul>
+        *                      <li>{@link RestContext}
+        *                      <li>{@link BeanStore}
+        *                      <li>Any {@doc RestInjection injected beans}.
+        *              </ul>
+        *      <li>Resolves it via the bean store registered in this context.
+        *      <li>Returns {@link ThrownStore#GLOBAL}.
+        * </ul>
+        *
+        * @param resource
+        *      The REST servlet or bean that this context defines.
+        * @param parent
+        *      The parent context if the REST bean was registered via {@link 
Rest#children()}.
+        *      <br>Will be <jk>null</jk> if the bean is a top-level resource.
+        * @param beanStore
+        *      The factory used for creating beans and retrieving injected 
beans.
+        *      <br>Created by {@link RestContextBuilder#beanStore()}.
+        * @return The stack trace store for this REST resource.
+        */
+       protected ThrownStore.Builder createThrownStore(BeanStore beanStore, 
Supplier<?> resource, RestContext parent) {
+
+               Value<ThrownStore.Builder> v = Value.empty();
+               Object r = resource.get();
+
+               beanStore.getBean(ThrownStore.Builder.class).map(x -> 
x.copy()).ifPresent(x->v.set(x));
+
+               BeanStore
+                       .of(beanStore, r)
+                       .addBean(ThrownStore.Builder.class, v.get())
+                       .beanCreateMethodFinder(ThrownStore.Builder.class, r)
+                       .find("createThrownStore")
+                       .execute()
+                       .ifPresent(x -> v.set(x));
+
+               if (v.isEmpty()) {
+                       v.set(
+                               ThrownStore
+                                       .create()
+                                       .beanStore(beanStore)
+                                       .impl(parent == null ? null : 
parent.getThrownStore())
+                       );
+               }
+
+               BeanStore
+                       .of(beanStore, r)
+                       .addBean(ThrownStore.Builder.class, v.get())
+                       .beanCreateMethodFinder(ThrownStore.class, r)
+                       .find("createThrownStore")
+                       .execute()
+                       .ifPresent(x -> v.get().impl(x));
+
+               return v.get();
+       }
+
        
//----------------------------------------------------------------------------------------------------
        // Methods that give access to the config file, var resolver, and 
properties.
        
//----------------------------------------------------------------------------------------------------
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/mstat/ThrownStore_Test.java 
b/juneau-utest/src/test/java/org/apache/juneau/mstat/ThrownStore_Test.java
index 613665f..55fa449 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/mstat/ThrownStore_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/mstat/ThrownStore_Test.java
@@ -198,19 +198,8 @@ public class ThrownStore_Test {
                
assertObject(ThrownStore.create().implClass(B1.class).build()).isType(B1.class);
        }
 
-       @Test
-       public void b03_builder_defaultImplClass() {
-               ThrownStoreBuilder b = new ThrownStoreBuilder() {
-                       @Override
-                       protected Class<? extends ThrownStore> 
getDefaultImplClass() {
-                               return B1.class;
-                       }
-               };
-               assertObject(b.build()).isType(B1.class);
-       }
-
        public static class B4 extends ThrownStore {
-               public B4(ThrownStoreBuilder b) throws Exception {
+               public B4(ThrownStore.Builder b) throws Exception {
                        throw new RuntimeException("foobar");
                }
        }
@@ -223,14 +212,14 @@ public class ThrownStore_Test {
        public static class B5a {}
 
        public static class B5b extends ThrownStore {
-               public B5b(ThrownStoreBuilder b, B5a x) throws Exception {
+               public B5b(ThrownStore.Builder b, B5a x) throws Exception {
                        if (x == null)
                                throw new RuntimeException("Bad");
                }
        }
 
        public static class B5c extends ThrownStore {
-               public B5c(ThrownStoreBuilder b, Optional<B5a> x) throws 
Exception {
+               public B5c(ThrownStore.Builder b, Optional<B5a> x) throws 
Exception {
                        if (x == null)
                                throw new RuntimeException("Bad");
                }

Reply via email to