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 b3191f7  Context API refactoring.
b3191f7 is described below

commit b3191f7e8f6484b8aa80013b95b96d0152901613
Author: JamesBognar <[email protected]>
AuthorDate: Sun Sep 12 13:29:21 2021 -0400

    Context API refactoring.
---
 .../java/org/apache/juneau/rest/RestContext.java   | 119 +-------
 .../org/apache/juneau/rest/RestContextBuilder.java | 335 +++++++++++----------
 .../java/org/apache/juneau/rest/StaticFiles.java   |  35 ++-
 .../juneau/rest/annotation/RestAnnotation.java     |   2 +-
 4 files changed, 212 insertions(+), 279 deletions(-)

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 e1953a9..7ac0577 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
@@ -216,8 +216,6 @@ public class RestContext extends Context {
        // Gets set when postInitChildFirst() gets called.
        private final AtomicBoolean initialized = new AtomicBoolean(false);
 
-       final StaticFiles staticFilesDefault;
-
        /**
         * Constructor.
         *
@@ -263,13 +261,10 @@ public class RestContext extends Context {
                        partParser = bs.add(HttpPartParser.class, 
builder.partParser().create());
                        jsonSchemaGenerator = bs.add(JsonSchemaGenerator.class, 
builder.jsonSchemaGenerator().build());
                        fileFinder = bs.add(FileFinder.class, 
builder.fileFinder().build());
+                       staticFiles = bs.add(StaticFiles.class, 
builder.staticFiles().build());
 
                        Object r = resource.get();
 
-                       staticFiles = createStaticFiles(r, builder, bs);
-                       bs.addBean(StaticFiles.class, staticFiles);
-                       staticFilesDefault = 
builder.staticFilesDefault.value().orElse(staticFiles);
-
                        defaultRequestHeaders = createDefaultRequestHeaders(r, 
builder, bs).build();
                        defaultResponseHeaders = 
createDefaultResponseHeaders(r, builder, bs).build();
                        defaultRequestAttributes = 
createDefaultRequestAttributes(r, builder, bs);
@@ -367,118 +362,6 @@ public class RestContext extends Context {
        }
 
        /**
-        * Instantiates the static files finder for this REST resource.
-        *
-        * <p>
-        * Instantiates based on the following logic:
-        * <ul>
-        *      <li>Returns the resource class itself is an instance of 
FileFinder.
-        *      <li>Looks for static files set via any of the following:
-        *              <ul>
-        *                      <li>{@link 
RestContextBuilder#staticFiles(Class)}/{@link 
RestContextBuilder#staticFiles(StaticFiles)}
-        *                      <li>{@link Rest#staticFiles()}.
-        *              </ul>
-        *      <li>Looks for a static or non-static <c>createStaticFiles()</> 
method that returns {@link StaticFiles} on the
-        *              resource class with any of the following arguments:
-        *              <ul>
-        *                      <li>{@link RestContext}
-        *                      <li>{@link BeanStore}
-        *                      <li>{@link BasicFileFinder}
-        *                      <li>Any {@doc RestInjection injected beans}.
-        *              </ul>
-        *      <li>Resolves it via the bean store registered in this context.
-        *      <li>Looks for value in default static files setting.
-        *      <li>Instantiates a {@link BasicStaticFiles}.
-        * </ul>
-        *
-        * @param resource
-        *      The REST servlet or bean that this context defines.
-        * @param builder
-        *      The builder for this object.
-        * @param beanStore
-        *      The factory used for creating beans and retrieving injected 
beans.
-        *      <br>Created by {@link RestContextBuilder#beanStore()}.
-        * @return The file finder for this REST resource.
-        * @throws Exception If file finder could not be instantiated.
-        */
-       protected StaticFiles createStaticFiles(Object resource, 
RestContextBuilder builder, BeanStore beanStore) throws Exception {
-
-               StaticFiles x = null;
-
-               if (resource instanceof StaticFiles)
-                       x = (StaticFiles)resource;
-
-               if (x == null)
-                       x = builder.staticFiles.value().orElse(null);
-
-               if (x == null)
-                       x = beanStore.getBean(StaticFiles.class).orElse(null);
-
-               if (x == null)
-                       x = builder.staticFilesDefault.value().orElse(null);
-
-               if (x == null)
-                       x = (StaticFiles)createStaticFilesBuilder(resource, 
builder, beanStore).build();
-
-               x = BeanStore
-                       .of(beanStore, resource)
-                       .addBean(StaticFiles.class, x)
-                       .beanCreateMethodFinder(StaticFiles.class, resource)
-                       .find("createStaticFiles")
-                       .withDefault(x)
-                       .run();
-
-               return x;
-       }
-
-       /**
-        * Instantiates the static files builder for this REST resource.
-        *
-        * <p>
-        * Allows subclasses to intercept and modify the builder used by the 
{@link #createStaticFiles(Object,RestContextBuilder,BeanStore)} method.
-        *
-        * @param resource
-        *      The REST servlet or bean that this context defines.
-        * @param builder
-        *      The builder for this object.
-        * @param beanStore
-        *      The factory used for creating beans and retrieving injected 
beans.
-        *      <br>Created by {@link RestContextBuilder#beanStore()}.
-        * @return The static files builder for this REST resource.
-        * @throws Exception If static files builder could not be instantiated.
-        */
-       @SuppressWarnings("unchecked")
-       protected StaticFiles.Builder createStaticFilesBuilder(Object resource, 
RestContextBuilder builder, BeanStore beanStore) throws Exception {
-
-               Class<? extends StaticFiles> c = 
builder.staticFiles.type().orElse(null);
-
-               if (c == null)
-                       c = builder.staticFilesDefault.type().orElse(null);
-
-               StaticFiles.Builder x = StaticFiles
-                       .create()
-                       .beanStore(beanStore)
-                       .type((Class<? extends FileFinder>)c)
-                       .dir("static")
-                       .dir("htdocs")
-                       .cp(getResourceClass(), "htdocs", true)
-                       .cp(getResourceClass(), "/htdocs", true)
-                       .caching(1_000_000)
-                       .exclude("(?i).*\\.(class|properties)")
-                       .headers(cacheControl("max-age=86400, public"));
-
-               x = BeanStore
-                       .of(beanStore, resource)
-                       .addBean(StaticFiles.Builder.class, x)
-                       .beanCreateMethodFinder(StaticFiles.Builder.class, 
resource)
-                       .find("createStaticFilesBuilder")
-                       .withDefault(x)
-                       .run();
-
-               return x;
-       }
-
-       /**
         * Instantiates the REST method parameter resolvers for this REST 
resource.
         *
         * <p>
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 cddeef7..a98d407 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
@@ -136,6 +136,7 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
        private HttpPartParser.Creator partParser;
        private JsonSchemaGeneratorBuilder jsonSchemaGenerator;
        private FileFinder.Builder fileFinder;
+       private StaticFiles.Builder staticFiles;
 
        String
                allowedHeaderParams = env("RestContext.allowedHeaderParams", 
"Accept,Content-Type"),
@@ -160,8 +161,6 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
 
        BeanRef<SwaggerProvider> swaggerProvider = 
BeanRef.of(SwaggerProvider.class);
        BeanRef<DebugEnablement> debugEnablement = 
BeanRef.of(DebugEnablement.class);
-       BeanRef<StaticFiles> staticFiles = BeanRef.of(StaticFiles.class);
-       BeanRef<StaticFiles> staticFilesDefault = BeanRef.of(StaticFiles.class);
        NamedAttributeList defaultRequestAttributes = 
NamedAttributeList.create();
        HeaderListBuilder defaultRequestHeaders = HeaderList.create();
        HeaderListBuilder defaultResponseHeaders = HeaderList.create();
@@ -237,7 +236,6 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
                        // Pass-through default values.
                        if (parentContext != null) {
                                debugDefault = parentContext.debugDefault;
-                               
staticFilesDefault.value(parentContext.staticFilesDefault);
                                defaultClasses = 
parentContext.defaultClasses.copy();
                        } else {
                                defaultClasses = DefaultClassList.create();
@@ -1816,6 +1814,183 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
                return v.get();
        }
 
+       /**
+        * Returns the static files builder for this context.
+        *
+        * @return The static files builder for this context.
+        */
+       public StaticFiles.Builder staticFiles() {
+               if (staticFiles == null)
+                       staticFiles = createStaticFiles(beanStore(), 
resource());
+               return staticFiles;
+       }
+
+
+       /**
+        * Instantiates the static files finder for this REST resource.
+        *
+        * <p>
+        * Used to retrieve localized files to be served up as static files 
through the REST API via the following
+        * predefined methods:
+        * <ul class='javatree'>
+        *      <li class='jm'>{@link BasicRestObject#getHtdoc(String, Locale)}.
+        *      <li class='jm'>{@link BasicRestServlet#getHtdoc(String, 
Locale)}.
+        * </ul>
+        *
+        * <p>
+        * The static file finder can be accessed through the following methods:
+        * <ul class='javatree'>
+        *      <li class='jm'>{@link RestContext#getStaticFiles()}
+        *      <li class='jm'>{@link RestRequest#getStaticFiles()}
+        * </ul>
+        *
+        * <p>
+        * The static file finder is instantiated via the {@link 
RestContextBuilder#createStaticFiles(BeanStore,Supplier)} method which in turn 
instantiates
+        * based on the following logic:
+        * <ul>
+        *      <li>Returns the resource class itself is an instance of {@link 
StaticFiles}.
+        *      <li>Looks for a public <c>createStaticFiles()</> method on the 
resource class with an optional {@link RestContext} argument.
+        *      <li>Instantiates a {@link BasicStaticFiles} which provides 
basic support for finding localized
+        *              resources on the classpath and JVM working directory..
+        * </ul>
+        *
+        * <h5 class='section'>Example:</h5>
+        * <p class='bcode w800'>
+        *      <jc>// Create a static file finder that looks for files in the 
/files working subdirectory, but overrides the find()
+        *      // and resolve methods for special handling of special cases 
and adds a Foo header to all requests.</jc>
+        *      <jk>public class</jk> MyStaticFiles <jk>extends</jk> 
StaticFiles {
+        *
+        *              <jk>public</jk> MyStaticFiles() <jk>extends</jk> 
BasicStaticFiles {
+        *                      <jk>super</jk>(
+        *                              <jk>new</jk> StaticFilesBuilder()
+        *                                      .dir(<js>"/files"</js>)
+        *                                      
.headers(BasicStringHeader.<jsm>of</jsm>(<js>"Foo"</js>, <js>"bar"</js>))
+        *                      );
+        *              }
+        *
+        *              <ja>@Override</ja> <jc>// FileFinder</jc>
+        *              <jk>protected</jk> Optional&lt;InputStream&gt; 
find(String <jv>name</jv>, Locale <jv>locale</jv>) <jk>throws</jk> IOException {
+        *                      <jc>// Do special handling or just call 
super.find().</jc>
+        *                      <jk>return super</jk>.find(<jv>name</jv>, 
<jv>locale</jv>);
+        *              }
+        *
+        *              <ja>@Override</ja> <jc>// staticFiles</jc>
+        *              <jk>public</jk> Optional&lt;BasicHttpResource&gt; 
resolve(String <jv>path</jv>, Locale <jv>locale</jv>) {
+        *                      <jc>// Do special handling or just call 
super.resolve().</jc>
+        *                      <jk>return super</jk>.resolve(<jv>path</jv>, 
<jv>locale</jv>);
+        *              }
+        *      }
+        * </p>
+        *
+        *      <jc>// Option #1 - Registered via annotation.</jc>
+        *      <ja>@Rest</ja>(staticFiles=MyStaticFiles.<jk>class</jk>)
+        *      <jk>public class</jk> MyResource {
+        *
+        *              <jc>// Option #2 - Created via createStaticFiles() 
method.</jc>
+        *              <jk>public</jk> StaticFiles 
createStaticFiles(RestContext <jv>context</jv>) <jk>throws</jk> Exception {
+        *                      <jk>return new</jk> MyStaticFiles();
+        *              }
+        *
+        *              <jc>// Option #3 - Registered via builder passed in 
through resource constructor.</jc>
+        *              <jk>public</jk> MyResource(RestContextBuilder 
<jv>builder</jv>) <jk>throws</jk> Exception {
+        *
+        *                      <jc>// Using method on builder.</jc>
+        *                      
<jv>builder</jv>.staticFiles(MyStaticFiles.<jk>class</jk>);
+        *
+        *                      <jc>// Use a pre-instantiated object 
instead.</jc>
+        *                      <jv>builder</jv>.staticFiles(<jk>new</jk> 
MyStaticFiles());
+        *              }
+        *
+        *              <jc>// Option #4 - Registered via builder passed in 
through init method.</jc>
+        *              <ja>@RestHook</ja>(<jsf>INIT</jsf>)
+        *              <jk>public void</jk> init(RestContextBuilder 
<jv>builder</jv>) <jk>throws</jk> Exception {
+        *                      
<jv>builder</jv>.staticFiles(MyStaticFiles.<jk>class</jk>);
+        *              }
+        *
+        *              <jc>// Create a REST method that uses the static files 
finder.</jc>
+        *              <ja>@RestGet<ja>(<js>"/htdocs/*"</js>)
+        *              <jk>public</jk> HttpResource htdocs(RestRequest 
<jv>req</jv>, <ja>@Path</ja>("/*") String <jv>path</jv>, Locale 
<jv>locale</jv>) <jk>throws</jk> NotFound {
+        *                      <jk>return</jk> 
<jv>req</jv>.getStaticFiles().resolve(<jv>path</jv>, 
<jv>locale</jv>).orElseThrow(NotFound::<jk>new</jk>);
+        *              }
+        *      }
+        * </p>
+        *
+        * <p>
+        * Instantiates based on the following logic:
+        * <ul>
+        *      <li>Returns the resource class itself is an instance of 
FileFinder.
+        *      <li>Looks for static files set via any of the following:
+        *              <ul>
+        *                      <li>{@link RestContextBuilder#staticFiles()}
+        *                      <li>{@link Rest#staticFiles()}.
+        *              </ul>
+        *      <li>Looks for a static or non-static <c>createStaticFiles()</> 
method that returns {@link StaticFiles} on the
+        *              resource class with any of the following arguments:
+        *              <ul>
+        *                      <li>{@link RestContext}
+        *                      <li>{@link BeanStore}
+        *                      <li>{@link BasicFileFinder}
+        *                      <li>Any {@doc RestInjection injected beans}.
+        *              </ul>
+        *      <li>Resolves it via the bean store registered in this context.
+        *      <li>Looks for value in default static files setting.
+        *      <li>Instantiates a {@link BasicStaticFiles}.
+        * </ul>
+        *
+        * @param beanStore
+        *      The factory used for creating beans and retrieving injected 
beans.
+        * @param resource
+        *      The REST servlet or bean that this context defines.
+        * @return The file finder for this REST resource.
+        */
+       protected StaticFiles.Builder createStaticFiles(BeanStore beanStore, 
Supplier<?> resource) {
+
+               Value<StaticFiles.Builder> v = Value.empty();
+               Object r = resource.get();
+
+               beanStore.getBean(StaticFiles.Builder.class).map(x -> 
x.copy()).ifPresent(x -> v.set(x));
+
+               if (v.isEmpty()) {
+                       v.set(
+                               StaticFiles
+                                       .create()
+                                       .beanStore(beanStore)
+                                       .dir("static")
+                                       .dir("htdocs")
+                                       .cp(r.getClass(), "htdocs", true)
+                                       .cp(r.getClass(), "/htdocs", true)
+                                       .caching(1_000_000)
+                                       .exclude("(?i).*\\.(class|properties)")
+                                       .headers(cacheControl("max-age=86400, 
public"))
+                       );
+               }
+
+               beanStore.getBean(StaticFiles.class).ifPresent(x -> 
v.get().impl(x));
+
+               if (r instanceof StaticFiles)
+                       v.get().impl((StaticFiles)r);
+
+               defaultClasses.get(StaticFiles.class).ifPresent(x -> 
v.get().type(x));
+
+               BeanStore
+                       .of(beanStore, r)
+                       .addBean(StaticFiles.Builder.class, v.get())
+                       .beanCreateMethodFinder(StaticFiles.Builder.class, r)
+                       .find("createStaticFiles")
+                       .execute()
+                       .ifPresent(x -> v.set(x));
+
+               BeanStore
+                       .of(beanStore, r)
+                       .addBean(StaticFiles.Builder.class, v.get())
+                       .beanCreateMethodFinder(StaticFiles.class, r)
+                       .find("createStaticFiles")
+                       .execute()
+                       .ifPresent(x -> v.get().impl(x));
+
+               return v.get();
+       }
+
        
//----------------------------------------------------------------------------------------------------
        // Methods that give access to the config file, var resolver, and 
properties.
        
//----------------------------------------------------------------------------------------------------
@@ -3253,160 +3428,6 @@ public class RestContextBuilder extends ContextBuilder 
implements ServletConfig
        }
 
        /**
-        * Static files finder.
-        *
-        * <p>
-        * Used to retrieve localized files to be served up as static files 
through the REST API via the following
-        * predefined methods:
-        * <ul class='javatree'>
-        *      <li class='jm'>{@link BasicRestObject#getHtdoc(String, Locale)}.
-        *      <li class='jm'>{@link BasicRestServlet#getHtdoc(String, 
Locale)}.
-        * </ul>
-        *
-        * <p>
-        * The static file finder can be accessed through the following methods:
-        * <ul class='javatree'>
-        *      <li class='jm'>{@link RestContext#getStaticFiles()}
-        *      <li class='jm'>{@link RestRequest#getStaticFiles()}
-        * </ul>
-        *
-        * <p>
-        * The static file finder is instantiated via the {@link 
RestContext#createStaticFiles(Object,RestContextBuilder,BeanStore)} method 
which in turn instantiates
-        * based on the following logic:
-        * <ul>
-        *      <li>Returns the resource class itself is an instance of {@link 
StaticFiles}.
-        *      <li>Looks for a public <c>createStaticFiles()</> method on the 
resource class with an optional {@link RestContext} argument.
-        *      <li>Instantiates a {@link BasicStaticFiles} which provides 
basic support for finding localized
-        *              resources on the classpath and JVM working directory..
-        * </ul>
-        *
-        * <h5 class='section'>Example:</h5>
-        * <p class='bcode w800'>
-        *      <jc>// Create a static file finder that looks for files in the 
/files working subdirectory, but overrides the find()
-        *      // and resolve methods for special handling of special cases 
and adds a Foo header to all requests.</jc>
-        *      <jk>public class</jk> MyStaticFiles <jk>extends</jk> 
StaticFiles {
-        *
-        *              <jk>public</jk> MyStaticFiles() <jk>extends</jk> 
BasicStaticFiles {
-        *                      <jk>super</jk>(
-        *                              <jk>new</jk> StaticFilesBuilder()
-        *                                      .dir(<js>"/files"</js>)
-        *                                      
.headers(BasicStringHeader.<jsm>of</jsm>(<js>"Foo"</js>, <js>"bar"</js>))
-        *                      );
-        *              }
-        *
-        *              <ja>@Override</ja> <jc>// FileFinder</jc>
-        *              <jk>protected</jk> Optional&lt;InputStream&gt; 
find(String <jv>name</jv>, Locale <jv>locale</jv>) <jk>throws</jk> IOException {
-        *                      <jc>// Do special handling or just call 
super.find().</jc>
-        *                      <jk>return super</jk>.find(<jv>name</jv>, 
<jv>locale</jv>);
-        *              }
-        *
-        *              <ja>@Override</ja> <jc>// staticFiles</jc>
-        *              <jk>public</jk> Optional&lt;BasicHttpResource&gt; 
resolve(String <jv>path</jv>, Locale <jv>locale</jv>) {
-        *                      <jc>// Do special handling or just call 
super.resolve().</jc>
-        *                      <jk>return super</jk>.resolve(<jv>path</jv>, 
<jv>locale</jv>);
-        *              }
-        *      }
-        * </p>
-        *
-        *      <jc>// Option #1 - Registered via annotation.</jc>
-        *      <ja>@Rest</ja>(staticFiles=MyStaticFiles.<jk>class</jk>)
-        *      <jk>public class</jk> MyResource {
-        *
-        *              <jc>// Option #2 - Created via createStaticFiles() 
method.</jc>
-        *              <jk>public</jk> StaticFiles 
createStaticFiles(RestContext <jv>context</jv>) <jk>throws</jk> Exception {
-        *                      <jk>return new</jk> MyStaticFiles();
-        *              }
-        *
-        *              <jc>// Option #3 - Registered via builder passed in 
through resource constructor.</jc>
-        *              <jk>public</jk> MyResource(RestContextBuilder 
<jv>builder</jv>) <jk>throws</jk> Exception {
-        *
-        *                      <jc>// Using method on builder.</jc>
-        *                      
<jv>builder</jv>.staticFiles(MyStaticFiles.<jk>class</jk>);
-        *
-        *                      <jc>// Use a pre-instantiated object 
instead.</jc>
-        *                      <jv>builder</jv>.staticFiles(<jk>new</jk> 
MyStaticFiles());
-        *              }
-        *
-        *              <jc>// Option #4 - Registered via builder passed in 
through init method.</jc>
-        *              <ja>@RestHook</ja>(<jsf>INIT</jsf>)
-        *              <jk>public void</jk> init(RestContextBuilder 
<jv>builder</jv>) <jk>throws</jk> Exception {
-        *                      
<jv>builder</jv>.staticFiles(MyStaticFiles.<jk>class</jk>);
-        *              }
-        *
-        *              <jc>// Create a REST method that uses the static files 
finder.</jc>
-        *              <ja>@RestGet<ja>(<js>"/htdocs/*"</js>)
-        *              <jk>public</jk> HttpResource htdocs(RestRequest 
<jv>req</jv>, <ja>@Path</ja>("/*") String <jv>path</jv>, Locale 
<jv>locale</jv>) <jk>throws</jk> NotFound {
-        *                      <jk>return</jk> 
<jv>req</jv>.getStaticFiles().resolve(<jv>path</jv>, 
<jv>locale</jv>).orElseThrow(NotFound::<jk>new</jk>);
-        *              }
-        *      }
-        * </p>
-        *
-        * @param value The new value for this setting.
-        * @return This object (for method chaining).
-        */
-       @FluentSetter
-       public RestContextBuilder staticFiles(Class<? extends StaticFiles> 
value) {
-               staticFiles.type(value);
-               return this;
-       }
-
-       /**
-        * Static files finder.
-        *
-        * <p>
-        * Used to retrieve localized files to be served up as static files 
through the REST API via the following
-        * predefined methods:
-        * <ul class='javatree'>
-        *      <li class='jm'>{@link BasicRestObject#getHtdoc(String, Locale)}.
-        *      <li class='jm'>{@link BasicRestServlet#getHtdoc(String, 
Locale)}.
-        * </ul>
-        *
-        * <p>
-        * Same as {@link #staticFiles(Class)} but takes in an instantated 
object.
-        *
-        * @param value The new value for this setting.
-        * @return This object (for method chaining).
-        */
-       @FluentSetter
-       public RestContextBuilder staticFiles(StaticFiles value) {
-               staticFiles.value(value);
-               return this;
-       }
-
-       /**
-        * Static files finder default.
-        *
-        * <p>
-        * The default static file finder.
-        *
-        * <p>
-        * This setting is inherited from the parent context if not overrided 
by this context.
-        *
-        * @param value The new value for this setting.
-        * @return This object (for method chaining).
-        */
-       @FluentSetter
-       public RestContextBuilder staticFilesDefault(Class<? extends 
StaticFiles> value) {
-               staticFilesDefault.type(value);
-               return this;
-       }
-
-       /**
-        * Configuration property:  Static files finder default.
-        *
-        * <p>
-        * Same as {@link #staticFilesDefault(Class)} but takes in an 
instantated object.
-        *
-        * @param value The new value for this setting.
-        * @return This object (for method chaining).
-        */
-       @FluentSetter
-       public RestContextBuilder staticFilesDefault(StaticFiles value) {
-               staticFilesDefault.value(value);
-               return this;
-       }
-
-       /**
         * Swagger provider.
         *
         * <p>
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/StaticFiles.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/StaticFiles.java
index 77a07e1..8dbea72 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/StaticFiles.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/StaticFiles.java
@@ -27,7 +27,7 @@ import org.apache.juneau.utils.*;
 /**
  * API for retrieving localized static files from either the classpath or file 
system.
  */
-public interface StaticFiles {
+public interface StaticFiles extends FileFinder {
 
        /** Represents no static files */
        public abstract class Null implements StaticFiles {}
@@ -47,8 +47,32 @@ public interface StaticFiles {
        @FluentSetters
        public static class Builder extends FileFinder.Builder {
 
-               List<Header> headers = AList.create();
-               MimetypesFileTypeMap mimeTypes = new 
ExtendedMimetypesFileTypeMap();
+               List<Header> headers;
+               MimetypesFileTypeMap mimeTypes;
+
+               /**
+                * Constructor.
+                */
+               protected Builder() {
+                       headers = AList.create();
+                       mimeTypes = new ExtendedMimetypesFileTypeMap();
+               }
+
+               /**
+                * Copy constructor.
+                *
+                * @param copyFrom The builder being copied.
+                */
+               protected Builder(Builder copyFrom) {
+                       super(copyFrom);
+                       headers = AList.of(copyFrom.headers);
+                       mimeTypes = copyFrom.mimeTypes;
+               }
+
+               @Override
+               public StaticFiles build() {
+                       return (StaticFiles)super.build();
+               }
 
                @Override
                protected Class<? extends FileFinder> getDefaultType() {
@@ -94,6 +118,11 @@ public interface StaticFiles {
                        return this;
                }
 
+               @Override
+               public Builder copy() {
+                       return new Builder(this);
+               }
+
                // <FluentSetters>
 
                @Override /* GENERATED - FileFinderBuilder */
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
index 81709cb..a0d7fcd 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
@@ -1069,7 +1069,7 @@ public class RestAnnotation {
                        
string(a.uriResolution()).map(UriResolution::valueOf).ifPresent(x -> 
b.uriResolution(x));
                        b.messages().location(c.inner(), 
string(a.messages()).orElse(null));
                        type(a.fileFinder()).ifPresent(x -> 
b.fileFinder().type(x));
-                       type(a.staticFiles()).ifPresent(x -> b.staticFiles(x));
+                       type(a.staticFiles()).ifPresent(x -> 
b.staticFiles().type(x));
                        string(a.path()).ifPresent(x -> b.path(x));
                        string(a.clientVersionHeader()).ifPresent(x -> 
b.clientVersionHeader(x));
                        type(a.callLogger()).ifPresent(x -> 
b.callLogger().implClass(x));

Reply via email to