You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2021/02/23 16:54:18 UTC

[juneau] branch master updated: Look for createConfig() method on REST classes.

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 a5f0224  Look for createConfig() method on REST classes.
a5f0224 is described below

commit a5f0224381de30c98bef940f0dd532c897a777f9
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Tue Feb 23 11:53:58 2021 -0500

    Look for createConfig() method on REST classes.
---
 TODO.txt                                                      |  5 -----
 .../main/java/org/apache/juneau/rest/RestContextBuilder.java  | 11 ++++++++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/TODO.txt b/TODO.txt
index a07a6b4..bc99b12 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,12 +1,7 @@
-Replace @Rest(paths) with just @Rest(path)
 ClassInfo improvements to getMethod (e.g. getMethodExact vs getMethod).Re-add @PathRemainder annotation.
-Add a createConfig() method on RestContext.
 Thrown NotFound causes - javax.servlet.ServletException: Invalid method response: 200
 
-Instead of PropertyStores, builders should produce settings which are passed to contexts.
-
 Replace @Bean(findFluentSetters) with @FluentSetters.
-Remove @BeanIgnore annotations from classes.
 HttpResponse should use list of Headers and have a headers(Header...) method.
 HttpResponse should allow you to set code.
 HttpException subclasses can set status, but does it use code?
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 da5f92d..58baa52 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
@@ -238,6 +238,15 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
 		Object o = resource == null ? null : resource.get();
 		if (o instanceof Config)
 			x = (Config)o;
+
+		if (x == null) {
+			x = BeanStore
+				.of(beanStore)
+				.beanCreateMethodFinder(Config.class, resourceClass)
+				.find("createConfig")
+				.run();
+		}
+
 		if (x == null)
 			x = beanStore.getBean(Config.class).orElse(null);
 
@@ -249,7 +258,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
 		VarResolver vr = beanStore.getBean(VarResolver.class).orElseThrow(()->new RuntimeException("VarResolver not found."));
 		String cf = vr.resolve(configPath);
 
-		if ("SYSTEM_DEFAULT".equals(cf))
+		if (x == null && "SYSTEM_DEFAULT".equals(cf))
 			x = Config.getSystemDefault();
 
 		if (x == null) {