juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [juneau] branch master updated: REST Response rework.
Date Mon, 30 Jul 2018 13:43:07 GMT
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 675c510  REST Response rework.
675c510 is described below

commit 675c510bd0069cf56691b28d28b573fcea43e6fb
Author: JamesBognar <jamesbognar@apache.org>
AuthorDate: Mon Jul 30 09:42:54 2018 -0400

    REST Response rework.
---
 .../apache/juneau/rest/BasicRestCallHandler.java   | 13 ++--
 .../org/apache/juneau/rest/ResponseHandler.java    |  2 +-
 .../org/apache/juneau/rest/ResponseObject.java     | 87 ----------------------
 .../org/apache/juneau/rest/RestCallHandler.java    |  3 +-
 .../java/org/apache/juneau/rest/RestContext.java   |  4 +-
 .../org/apache/juneau/rest/RestJavaMethod.java     | 19 +++--
 .../org/apache/juneau/rest/RestParamDefaults.java  |  5 +-
 .../java/org/apache/juneau/rest/RestResponse.java  | 58 ++++++++++++---
 .../juneau/rest/reshandlers/DefaultHandler.java    |  7 +-
 .../rest/reshandlers/InputStreamHandler.java       |  6 +-
 .../juneau/rest/reshandlers/ReaderHandler.java     |  6 +-
 .../juneau/rest/reshandlers/RedirectHandler.java   |  6 +-
 .../juneau/rest/reshandlers/StreamableHandler.java | 10 +--
 .../juneau/rest/reshandlers/WritableHandler.java   | 10 +--
 .../reshandlers/ZipFileListResponseHandler.java    |  6 +-
 15 files changed, 97 insertions(+), 145 deletions(-)

diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestCallHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestCallHandler.java
index c7d62de..c1630b9 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestCallHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicRestCallHandler.java
@@ -172,15 +172,14 @@ public class BasicRestCallHandler implements RestCallHandler {
 			}
 
 			if (res.hasOutput()) {
-				ResponseObject output = res.getOutput();
 
 				// Do any class-level transforming.
 				for (RestConverter converter : context.getConverters())
-					output.setValue(converter.convert(req, output.getValue()));
+					res.setOutput(converter.convert(req, res.getOutput()));
 
 				// Now serialize the output if there was any.
 				// Some subclasses may write to the OutputStream or Writer directly.
-				handleResponse(req, res, output);
+				handleResponse(req, res);
 			}
 
 			// Make sure our writer in RestResponse gets written.
@@ -210,21 +209,21 @@ public class BasicRestCallHandler implements RestCallHandler {
 	 *
 	 * <p>
 	 * The default implementation simply iterates through the response handlers on this resource
-	 * looking for the first one whose {@link ResponseHandler#handle(RestRequest, RestResponse,
ResponseObject)} method returns
+	 * looking for the first one whose {@link ResponseHandler#handle(RestRequest, RestResponse)}
method returns
 	 * <jk>true</jk>.
 	 *
 	 * @param req The HTTP request.
 	 * @param res The HTTP response.
-	 * @param output The output to serialize in the response.
 	 * @throws IOException
 	 * @throws RestException
 	 */
 	@Override /* RestCallHandler */
-	public void handleResponse(RestRequest req, RestResponse res, ResponseObject output) throws
IOException, RestException, NotImplemented {
+	public void handleResponse(RestRequest req, RestResponse res) throws IOException, RestException,
NotImplemented {
 		// Loop until we find the correct handler for the POJO.
 		for (ResponseHandler h : context.getResponseHandlers())
-			if (h.handle(req, res, output))
+			if (h.handle(req, res))
 				return;
+		Object output = res.getOutput();
 		throw new NotImplemented("No response handlers found to process output of type '"+(output
== null ? null : output.getClass().getName())+"'");
 	}
 
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java
index 2e66ff4..50bf57c 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseHandler.java
@@ -112,5 +112,5 @@ public interface ResponseHandler {
 	 * 	If some other exception occurred.
 	 * 	Can be used to provide an appropriate HTTP response code and message.
 	 */
-	boolean handle(RestRequest req, RestResponse res, ResponseObject output) throws IOException,
RestException;
+	boolean handle(RestRequest req, RestResponse res) throws IOException, RestException;
 }
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseObject.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseObject.java
deleted file mode 100644
index 4b905e2..0000000
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ResponseObject.java
+++ /dev/null
@@ -1,87 +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.rest;
-
-import org.apache.juneau.httppart.*;
-
-/**
- * A simple pairing of a response object and metadata on how to serialize that response object.
- */
-public class ResponseObject {
-
-	private ResponseMeta meta;
-	private Object value;
-
-	/**
-	 * Constructor.
-	 *
-	 * @param meta Metadata about the specified value.
-	 * @param value The POJO that makes up the response.
-	 */
-	public ResponseObject(ResponseMeta meta, Object value) {
-		this.meta = meta;
-		this.value = value;
-	}
-
-	/**
-	 * Returns the metadata about this response.
-	 *
-	 * @return
-	 * 	The metadata about this response.
-	 * 	<jk>Never <jk>null</jk>.
-	 */
-	public ResponseMeta getMeta() {
-		return meta;
-	}
-
-	/**
-	 * Returns the POJO that makes up this response.
-	 *
-	 * @return
-	 * 	The POJO that makes up this response.
-	 * 	<jk>Never <jk>null</jk>.
-	 */
-	public Object getValue() {
-		return value;
-	}
-
-	/**
-	 * Returns <jk>true</jk> if this response object is of the specified type.
-	 *
-	 * @param c The type to check against.
-	 * @return <jk>true</jk> if this response object is of the specified type.
-	 */
-	public boolean isType(Class<?> c) {
-		return c.isInstance(value);
-	}
-
-	/**
-	 * Returns this value cast to the specified class.
-	 *
-	 * @param c The class to cast to.
-	 * @return This value cast to the specified class.
-	 */
-	@SuppressWarnings("unchecked")
-	public <T> T getValue(Class<T> c) {
-		return (T)value;
-	}
-
-	/**
-	 * Sets the POJO value for this response.
-	 *
-	 * @param value The POJO value to set.
-	 */
-	public void setValue(Object value) {
-		this.value = value;
-	}
-}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestCallHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestCallHandler.java
index 2eb3f10..d45be08 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestCallHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestCallHandler.java
@@ -74,11 +74,10 @@ public interface RestCallHandler {
 	 *
 	 * @param req The HTTP request.
 	 * @param res The HTTP response.
-	 * @param output The output to serialize in the response.
 	 * @throws IOException
 	 * @throws RestException
 	 */
-	public void handleResponse(RestRequest req, RestResponse res, ResponseObject output) throws
IOException, RestException ;
+	public void handleResponse(RestRequest req, RestResponse res) throws IOException, RestException
;
 
 	/**
 	 * Handle the case where a matching method was not found.
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 8e3307c..818a98a 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
@@ -3052,7 +3052,7 @@ public final class RestContext extends BeanContext {
 									if (rc != SC_OK)
 										return rc;
 
-									final ResponseObject ro = res.getOutput();
+									final Object o = res.getOutput();
 
 									if ("GET".equals(req.getMethod())) {
 										res.setOutput(getMethodInfo(remoteableMethods.values()));
@@ -3075,7 +3075,7 @@ public final class RestContext extends BeanContext {
 														args = p.parseArgs(in, m.getGenericParameterTypes());
 													}
 												}
-												Object output = m.invoke(ro.getValue(), args);
+												Object output = m.invoke(o, args);
 												res.setOutput(output);
 												return SC_OK;
 											} catch (Exception e) {
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
index 12eec28..9e678af 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestJavaMethod.java
@@ -527,10 +527,12 @@ public class RestJavaMethod implements Comparable<RestJavaMethod>
 {
 				RestMethodReturn rmr = req.getRestMethodReturn();
 				if (! method.getReturnType().equals(Void.TYPE)) {
 					if (output != null || ! res.getOutputStreamCalled()) {
+						res.setOutput(output);
 						ResponseMeta rm = rmr.getResponseMeta();
 						if (rm == null)
 							rm = context.getResponseMetaForObject(output);
-						res.setOutput(new ResponseObject(rm, output));
+						if (rm != null)
+							res.setMeta(rm);
 					}
 				}
 			} catch (InvocationTargetException e) {
@@ -541,19 +543,20 @@ public class RestJavaMethod implements Comparable<RestJavaMethod>
 {
 				ResponseMeta rm = rmt == null ? null : rmt.getResponseMeta();
 				if (rm == null)
 					rm = context.getResponseMetaForObject(e2);
-				if (rm != null)
-					res.setOutput(new ResponseObject(rm, e2));
-				else
+				if (rm != null) {
+					res.setMeta(rm);
+					res.setOutput(e2);
+				} else {
 					throw e;
+				}
 			}
 
 			context.postCall(req, res);
 
-			if (res.hasOutput()) {
-				ResponseObject ro = res.getOutput();
+			if (res.hasOutput())
 				for (RestConverter converter : converters)
-					ro.setValue(converter.convert(req, ro.getValue()));
-			}
+					res.setOutput(converter.convert(req, res.getOutput()));
+
 		} catch (IllegalArgumentException e) {
 			throw new BadRequest(e,
 				"Invalid argument type passed to the following method: ''{0}''.\n\tArgument types: {1}",
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
index 80328f0..c2dc966 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
@@ -681,8 +681,9 @@ class RestParamDefaults {
 			Value<Object> v = (Value<Object>)c.newInstance();
 			v.listener(new ValueListener() {
 				@Override
-				public void onSet(Object newValue) {
-					res.setOutput(new ResponseObject(meta, newValue));
+				public void onSet(Object output) {
+					res.setMeta(meta);
+					res.setOutput(output);
 				}
 			});
 			if (_default != null) {
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
index 8d9d24b..dd03659 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
@@ -58,7 +58,8 @@ public final class RestResponse extends HttpServletResponseWrapper {
 
 	private final RestRequest request;
 	private RestJavaMethod restJavaMethod;
-	private ResponseObject output;                       // The POJO being sent to the output.
+	private ResponseMeta meta;
+	private Object output;                       // The POJO being sent to the output.
 	private boolean isNullOutput;                // The output is null (as opposed to not being
set at all)
 	private RequestProperties properties;                // Response properties
 	private ServletOutputStream sos;
@@ -189,14 +190,8 @@ public final class RestResponse extends HttpServletResponseWrapper {
 	 * @return This object (for method chaining).
 	 */
 	public RestResponse setOutput(Object output) {
-		this.output = new ResponseObject(null, output);
-		this.isNullOutput = output == null;
-		return this;
-	}
-
-	RestResponse setOutput(ResponseObject output) {
 		this.output = output;
-		this.isNullOutput = output.getValue() == null;
+		this.isNullOutput = output == null;
 		return this;
 	}
 
@@ -315,7 +310,7 @@ public final class RestResponse extends HttpServletResponseWrapper {
 	 * @return This object (for method chaining).
 	 */
 	public RestResponse setOutputs(Object...output) {
-		this.output = new ResponseObject(null, output);
+		this.output = output;
 		return this;
 	}
 
@@ -324,7 +319,7 @@ public final class RestResponse extends HttpServletResponseWrapper {
 	 *
 	 * @return The output object.
 	 */
-	public ResponseObject getOutput() {
+	public Object getOutput() {
 		return output;
 	}
 
@@ -516,6 +511,49 @@ public final class RestResponse extends HttpServletResponseWrapper {
 		setHeader(h.getName(), h.getValue());
 	}
 
+	/**
+	 * Returns the metadata about this response.
+	 *
+	 * @return
+	 * 	The metadata about this response.
+	 * 	<jk>Never <jk>null</jk>.
+	 */
+	public ResponseMeta getMeta() {
+		return meta;
+	}
+
+	/**
+	 * Sets metadata about this response.
+	 *
+	 * @param meta The metadata about this response.
+	 * @return This object (for method chaining).
+	 */
+	public RestResponse setMeta(ResponseMeta meta) {
+		this.meta = meta;
+		return this;
+	}
+
+	/**
+	 * Returns <jk>true</jk> if this response object is of the specified type.
+	 *
+	 * @param c The type to check against.
+	 * @return <jk>true</jk> if this response object is of the specified type.
+	 */
+	public boolean isOutputType(Class<?> c) {
+		return c.isInstance(output);
+	}
+
+	/**
+	 * Returns this value cast to the specified class.
+	 *
+	 * @param c The class to cast to.
+	 * @return This value cast to the specified class.
+	 */
+	@SuppressWarnings("unchecked")
+	public <T> T getOutput(Class<T> c) {
+		return (T)output;
+	}
+
 	@Override /* ServletResponse */
 	public void flushBuffer() throws IOException {
 		if (w != null)
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java
index 425b60a..e253f4b 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/DefaultHandler.java
@@ -47,14 +47,13 @@ public class DefaultHandler implements ResponseHandler {
 
 	@SuppressWarnings("resource")
 	@Override /* ResponseHandler */
-	public boolean handle(RestRequest req, RestResponse res, ResponseObject ro) throws IOException,
InternalServerError, NotAcceptable {
+	public boolean handle(RestRequest req, RestResponse res) throws IOException, InternalServerError,
NotAcceptable {
 		SerializerGroup g = res.getSerializers();
 		String accept = req.getHeaders().getString("Accept", "");
 		SerializerMatch sm = g.getSerializerMatch(accept);
 
-		Object o = ro.getValue();
-
-		ResponseMeta rm = ro.getMeta();
+		Object o = res.getOutput();
+		ResponseMeta rm = res.getMeta();
 
 		if (rm != null) {
 			if (rm.getCode() != 0)
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/InputStreamHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/InputStreamHandler.java
index 8f2948e..5fd4fb6 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/InputStreamHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/InputStreamHandler.java
@@ -35,11 +35,11 @@ import org.apache.juneau.utils.*;
 public final class InputStreamHandler implements ResponseHandler {
 
 	@Override /* ResponseHandler */
-	public boolean handle(RestRequest req, RestResponse res, ResponseObject ro) throws IOException,
NotAcceptable, RestException {
-		if (ro.isType(InputStream.class)) {
+	public boolean handle(RestRequest req, RestResponse res) throws IOException, NotAcceptable,
RestException {
+		if (res.isOutputType(InputStream.class)) {
 			res.setHeader("Content-Type", res.getContentType());
 			try (OutputStream os = res.getNegotiatedOutputStream()) {
-				IOPipe.create(ro.getValue(InputStream.class), os).run();
+				IOPipe.create(res.getOutput(InputStream.class), os).run();
 			}
 			return true;
 		}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ReaderHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ReaderHandler.java
index c89c8c1..5a31fbd 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ReaderHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ReaderHandler.java
@@ -32,10 +32,10 @@ import org.apache.juneau.utils.*;
 public final class ReaderHandler implements ResponseHandler {
 
 	@Override /* ResponseHandler */
-	public boolean handle(RestRequest req, RestResponse res, ResponseObject ro) throws IOException,
NotAcceptable, RestException {
-		if (ro.isType(Reader.class)) {
+	public boolean handle(RestRequest req, RestResponse res) throws IOException, NotAcceptable,
RestException {
+		if (res.isOutputType(Reader.class)) {
 			try (Writer w = res.getNegotiatedWriter()) {
-				IOPipe.create(ro.getValue(Reader.class), w).run();
+				IOPipe.create(res.getOutput(Reader.class), w).run();
 			}
 			return true;
 		}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/RedirectHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/RedirectHandler.java
index 798b9be..750193f 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/RedirectHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/RedirectHandler.java
@@ -28,9 +28,9 @@ import org.apache.juneau.rest.helper.*;
 public final class RedirectHandler implements ResponseHandler {
 
 	@Override /* ResponseHandler */
-	public boolean handle(RestRequest req, RestResponse res, ResponseObject ro) throws IOException,
RestException {
-		if (ro.isType(Redirect.class)) {
-			Redirect r = ro.getValue(Redirect.class);
+	public boolean handle(RestRequest req, RestResponse res) throws IOException, RestException
{
+		if (res.isOutputType(Redirect.class)) {
+			Redirect r = res.getOutput(Redirect.class);
 			String uri = req.getUriResolver().resolve(r.getURI());
 			int rc = r.getHttpResponseCode();
 			if (rc != 0)
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/StreamableHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/StreamableHandler.java
index 5752ada..80cf26c 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/StreamableHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/StreamableHandler.java
@@ -37,10 +37,10 @@ import org.apache.juneau.rest.helper.*;
 public final class StreamableHandler implements ResponseHandler {
 
 	@Override /* ResponseHandler */
-	public boolean handle(RestRequest req, RestResponse res, ResponseObject ro) throws IOException,
RestException {
-		if (ro.isType(Streamable.class)) {
-			if (ro.isType(StreamResource.class)) {
-				StreamResource r = ro.getValue(StreamResource.class);
+	public boolean handle(RestRequest req, RestResponse res) throws IOException, RestException
{
+		if (res.isOutputType(Streamable.class)) {
+			if (res.isOutputType(StreamResource.class)) {
+				StreamResource r = res.getOutput(StreamResource.class);
 				MediaType mediaType = r.getMediaType();
 				if (mediaType != null)
 					res.setContentType(mediaType.toString());
@@ -48,7 +48,7 @@ public final class StreamableHandler implements ResponseHandler {
 					res.setHeader(h.getKey(), asString(h.getValue()));
 			}
 			try (OutputStream os = res.getOutputStream()) {
-				ro.getValue(Streamable.class).streamTo(os);
+				res.getOutput(Streamable.class).streamTo(os);
 			}
 			return true;
 		}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/WritableHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/WritableHandler.java
index ddcf849..fc926fd 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/WritableHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/WritableHandler.java
@@ -37,10 +37,10 @@ import org.apache.juneau.rest.helper.*;
 public final class WritableHandler implements ResponseHandler {
 
 	@Override /* ResponseHandler */
-	public boolean handle(RestRequest req, RestResponse res, ResponseObject ro) throws IOException,
NotAcceptable, RestException {
-		if (ro.isType(Writable.class)) {
-			if (ro.isType(ReaderResource.class)) {
-				ReaderResource r = ro.getValue(ReaderResource.class);
+	public boolean handle(RestRequest req, RestResponse res) throws IOException, NotAcceptable,
RestException {
+		if (res.isOutputType(Writable.class)) {
+			if (res.isOutputType(ReaderResource.class)) {
+				ReaderResource r = res.getOutput(ReaderResource.class);
 				MediaType mediaType = r.getMediaType();
 				if (mediaType != null)
 					res.setContentType(mediaType.toString());
@@ -48,7 +48,7 @@ public final class WritableHandler implements ResponseHandler {
 					res.setHeader(h.getKey(), asString(h.getValue()));
 			}
 			try (Writer w = res.getNegotiatedWriter()) {
-				ro.getValue(Writable.class).writeTo(w);
+				res.getOutput(Writable.class).writeTo(w);
 			}
 			return true;
 		}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ZipFileListResponseHandler.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ZipFileListResponseHandler.java
index 5deda07..3fce703 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ZipFileListResponseHandler.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/reshandlers/ZipFileListResponseHandler.java
@@ -44,9 +44,9 @@ import org.apache.juneau.utils.ZipFileList.*;
 public class ZipFileListResponseHandler implements ResponseHandler {
 
 	@Override /* ResponseHandler */
-	public boolean handle(RestRequest req, RestResponse res, ResponseObject ro) throws IOException,
RestException {
-		if (ro.isType(ZipFileList.class)) {
-			ZipFileList m = ro.getValue(ZipFileList.class);
+	public boolean handle(RestRequest req, RestResponse res) throws IOException, RestException
{
+		if (res.isOutputType(ZipFileList.class)) {
+			ZipFileList m = res.getOutput(ZipFileList.class);
 			res.setContentType("application/zip");
 			res.setHeader("Content-Disposition", "attachment;filename=" + m.fileName); //$NON-NLS-2$
 			try (OutputStream os = res.getOutputStream()) {


Mime
View raw message