juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject juneau git commit: RestContextBuilder cleanup.
Date Sat, 30 Dec 2017 15:34:47 GMT
Repository: juneau
Updated Branches:
  refs/heads/master 0ea8321e3 -> bdab23742


RestContextBuilder cleanup.

Project: http://git-wip-us.apache.org/repos/asf/juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/juneau/commit/bdab2374
Tree: http://git-wip-us.apache.org/repos/asf/juneau/tree/bdab2374
Diff: http://git-wip-us.apache.org/repos/asf/juneau/diff/bdab2374

Branch: refs/heads/master
Commit: bdab2374238f35ff75c8a2e597bfd1a1cf7cce05
Parents: 0ea8321
Author: JamesBognar <jamesbognar@apache.org>
Authored: Sat Dec 30 10:34:48 2017 -0500
Committer: JamesBognar <jamesbognar@apache.org>
Committed: Sat Dec 30 10:34:48 2017 -0500

----------------------------------------------------------------------
 .../org/apache/juneau/rest/RestContext.java     | 21 ++++++++++----------
 .../apache/juneau/rest/RestContextBuilder.java  |  4 ++++
 .../org/apache/juneau/rest/RestServlet.java     |  2 +-
 3 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juneau/blob/bdab2374/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
----------------------------------------------------------------------
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 a684ba9..649dacb 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
@@ -141,7 +141,6 @@ public final class RestContext extends Context {
 	/**
 	 * Constructor.
 	 *
-	 * @param resource The resource class (a class annotated with {@link RestResource @RestResource}).
 	 * @param servletContext
 	 * 	The servlet context object.
 	 * 	Can be <jk>null</jk> if this isn't a
@@ -149,11 +148,11 @@ public final class RestContext extends Context {
 	 * @throws Exception If any initialization problems were encountered.
 	 */
 	@SuppressWarnings("unchecked")
-	public RestContext(Object resource, ServletContext servletContext, RestContextBuilder builder)
throws Exception {
+	public RestContext(ServletContext servletContext, RestContextBuilder builder) throws Exception
{
 		super(PropertyStore.DEFAULT);
 		RestException _initException = null;
 		try {
-			this.resource = resource;
+			this.resource = builder.resource;
 			this.builder = builder;
 			this.resourceFinder = new ResourceFinder(resource.getClass());
 			this.parentContext = builder.parentContext;
@@ -406,24 +405,24 @@ public final class RestContext extends Context {
 					r = o;
 				}
 
-				RestContextBuilder childConfig = null;
+				RestContextBuilder childBuilder = null;
 
 				if (o instanceof Class) {
 					Class<?> oc = (Class<?>)o;
-					childConfig = new RestContextBuilder(builder.inner, oc, this);
-					r = resourceResolver.resolve(oc, childConfig);
+					childBuilder = new RestContextBuilder(builder.inner, oc, this);
+					r = resourceResolver.resolve(oc, childBuilder);
 				} else {
 					r = o;
-					childConfig = new RestContextBuilder(builder.inner, o.getClass(), this);
+					childBuilder = new RestContextBuilder(builder.inner, o.getClass(), this);
 				}
 
-				childConfig.init(r);
+				childBuilder.init(r);
 				if (r instanceof RestServlet)
-					((RestServlet)r).innerInit(childConfig);
-				RestContext rc2 = new RestContext(r, servletContext, childConfig);
+					((RestServlet)r).innerInit(childBuilder);
+				RestContext rc2 = new RestContext(servletContext, childBuilder);
 				if (r instanceof RestServlet)
 					((RestServlet)r).setContext(rc2);
-				path = childConfig.path;
+				path = childBuilder.path;
 				childResources.put(path, rc2);
 			}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/bdab2374/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
----------------------------------------------------------------------
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 b269a47..c5cd4a9 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
@@ -81,6 +81,8 @@ import org.apache.juneau.utils.*;
 public class RestContextBuilder extends ContextBuilder implements ServletConfig {
 
 	final ServletConfig inner;
+	
+	Object resource;
 
 	//---------------------------------------------------------------------------
 	// The following fields are meant to be modifiable.
@@ -276,6 +278,8 @@ public class RestContextBuilder extends ContextBuilder implements ServletConfig
 	 * Calls all @RestHook(INIT) methods on the specified resource object.
 	 */
 	void init(Object resource) throws ServletException {
+		this.resource = resource;
+		
 		Map<String,Method> map = new LinkedHashMap<>();
 		for (Method m : ClassUtils.getAllMethods(this.resourceClass, true)) {
 			if (m.isAnnotationPresent(RestHook.class) && m.getAnnotation(RestHook.class).value()
== HookEvent.INIT) {

http://git-wip-us.apache.org/repos/asf/juneau/blob/bdab2374/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServlet.java
----------------------------------------------------------------------
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServlet.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServlet.java
index 8c05811..66e59f4 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServlet.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServlet.java
@@ -109,7 +109,7 @@ public abstract class RestServlet extends HttpServlet {
 	private synchronized RestContext createContext(RestContextBuilder builder) throws Exception
{
 		if (! isInitialized) {
 			this.builder = builder;
-			this.context = new RestContext(this, this.getServletContext(), builder);
+			this.context = new RestContext(this.getServletContext(), builder);
 			this.isInitialized = true;
 		}
 		return context;


Mime
View raw message