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 2017/04/16 23:59:59 UTC
incubator-juneau git commit: Add RestContext.getParentContext() to
get access to parent resource.
Repository: incubator-juneau
Updated Branches:
refs/heads/master 5061873dd -> b2ddf9786
Add RestContext.getParentContext() to get access to parent resource.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/b2ddf978
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/b2ddf978
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/b2ddf978
Branch: refs/heads/master
Commit: b2ddf978695673c66623da3fc314a8ea90192342
Parents: 5061873
Author: JamesBognar <ja...@apache.org>
Authored: Sun Apr 16 19:59:57 2017 -0400
Committer: JamesBognar <ja...@apache.org>
Committed: Sun Apr 16 19:59:57 2017 -0400
----------------------------------------------------------------------
.../java/org/apache/juneau/rest/RestContext.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b2ddf978/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java
index 2875805..65d447e 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -327,6 +327,7 @@ public final class RestContext extends Context {
private final RestCallHandler callHandler;
private final RestInfoProvider infoProvider;
private final RestException initException;
+ private final RestContext parentContext;
// In-memory cache of images and stylesheets in the org.apache.juneau.rest.htdocs package.
private final Map<String,StreamResource> staticFilesCache = new ConcurrentHashMap<String,StreamResource>();
@@ -349,6 +350,7 @@ public final class RestContext extends Context {
try {
this.resource = resource;
this.config = config;
+ this.parentContext = config.parentContext;
Builder b = new Builder(resource, config);
this.allowHeaderParams = b.allowHeaderParams;
@@ -1023,7 +1025,7 @@ public final class RestContext extends Context {
*
* @return The resource object. Never <jk>null</jk>.
*/
- protected Object getResource() {
+ public Object getResource() {
return resource;
}
@@ -1033,7 +1035,7 @@ public final class RestContext extends Context {
* @return The resource object cast to {@link RestServlet}, or
* <jk>null</jk> if the resource doesn't subclass from {@link RestServlet}
*/
- protected RestServlet getRestServlet() {
+ public RestServlet getRestServlet() {
return resource instanceof RestServlet ? (RestServlet)resource : null;
}
@@ -1048,6 +1050,17 @@ public final class RestContext extends Context {
}
/**
+ * Returns the parent resource context (if this resource was initialized from a parent).
+ * <p>
+ * From this object, you can get access to the parent resource class itself using {@link #getResource()} or {@link #getRestServlet()}
+ *
+ * @return The parent resource context, or <jk>null</jk> if there is no parent context.
+ */
+ public RestContext getParentContext() {
+ return parentContext;
+ }
+
+ /**
* Returns the {@link BeanContext} object used for parsing path variables and header values.
*
* @return The bean context used for parsing path variables and header values.