juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject juneau git commit: RestContext refactoring.
Date Fri, 05 Jan 2018 02:23:24 GMT
Repository: juneau
Updated Branches:
  refs/heads/master 2225bc052 -> 3fc40afc2


RestContext refactoring.

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

Branch: refs/heads/master
Commit: 3fc40afc2dc52b6be932fffccb94a01d9875ac91
Parents: 2225bc0
Author: JamesBognar <jamesbognar@apache.org>
Authored: Thu Jan 4 21:23:20 2018 -0500
Committer: JamesBognar <jamesbognar@apache.org>
Committed: Thu Jan 4 21:23:20 2018 -0500

----------------------------------------------------------------------
 .../apache/juneau/encoders/IdentityEncoder.java |   2 +-
 .../org/apache/juneau/internal/ClassUtils.java  |   2 +-
 juneau-doc/src/main/javadoc/overview.html       |   2 +-
 .../apache/juneau/rest/test/GzipResource.java   |   2 +-
 .../juneau/rest/test/InheritanceResource.java   |   2 +-
 .../java/org/apache/juneau/rest/CallMethod.java |  10 +-
 .../org/apache/juneau/rest/RestContext.java     | 151 ++++++++++++++++++-
 .../apache/juneau/rest/RestContextBuilder.java  | 117 +++++++++-----
 .../juneau/rest/annotation/RestMethod.java      |  48 +++---
 .../juneau/rest/annotation/RestResource.java    |  27 +++-
 10 files changed, 286 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/IdentityEncoder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/IdentityEncoder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/IdentityEncoder.java
index ae9eb2d..763764b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/IdentityEncoder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/encoders/IdentityEncoder.java
@@ -23,7 +23,7 @@ public class IdentityEncoder extends Encoder {
 	public static final IdentityEncoder INSTANCE = new IdentityEncoder();
 
 	/** Constructor. */
-	protected IdentityEncoder() {}
+	public IdentityEncoder() {}
 
 	@Override /* Encoder */
 	public InputStream getInputStream(InputStream is) throws IOException {

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
index aa78c06..8e002f0 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ClassUtils.java
@@ -854,7 +854,7 @@ public final class ClassUtils {
 						return (T)con.newInstance(getMatchingArgs(con, args));
 				}
 
-				throw new FormattedRuntimeException("Could not instantiate class {0}.  Constructor not
found.", c.getName());
+				throw new FormattedRuntimeException("Could not instantiate class {0}/{1}.  Constructor
not found.", c.getName(), c2);
 			} catch (Exception e) {
 				throw new FormattedRuntimeException(e, "Could not instantiate class {0}", c.getName());
 			}

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-doc/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index 05de119..98c60a9 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -10675,7 +10675,7 @@
 						<code>getUnbufferedWriter()</code> has been removed.
 				</ul>
 			<li>New {@link org.apache.juneau.rest.annotation.RestMethod#encoders() @RestMethod.encoders()}
and 
-				{@link org.apache.juneau.rest.annotation.RestMethod#inheritEncoders() @RestMethod.inheritEncoders}
annotations.  
+				<code><del>RestMethod.inheritEncoders()</del></code> annotations.
 
 				Allows encoders to be fine-tuned at the method level.
 			<li>New {@link org.apache.juneau.rest.annotation.RestResource#config() @RestResource.config()}
annotation for associating external {@link org.apache.juneau.ini.ConfigFile} config files
with servlets.
 			<li><code><del>ResourceLink</del></code>.

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
index 3baee73..ece84ba 100644
--- a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
@@ -103,7 +103,7 @@ public class GzipResource {
 		}
 
 		// This method overrides the set of encoders at the method level and so shouldn't use GZip
encoding.
-		@RestMethod(name=GET, path="/direct4", inheritEncoders=false)
+		@RestMethod(name=GET, path="/direct4", encoders={IdentityEncoder.class})
 		public void direct4(RestResponse res) throws Exception {
 			Writer w = res.getNegotiatedWriter();
 			w.append("test");

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
index a722d1e..36c6c75 100644
--- a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
+++ b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
@@ -136,7 +136,7 @@ public class InheritanceResource extends RestServlet {
 		private static final long serialVersionUID = 1L;
 
 		// Should show ['e3','e4','e1','e2','identity']
-		@RestMethod(name=GET, path="/test")
+		@RestMethod(name=GET, path="/test", inherit="ENCODERS")
 		public Reader test(RestResponse res) throws RestServletException {
 			return new StringReader(new ObjectList(res.getSupportedEncodings()).toString());
 		}

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/CallMethod.java
----------------------------------------------------------------------
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/CallMethod.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/CallMethod.java
index 0330c20..335b994 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/CallMethod.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/CallMethod.java
@@ -181,7 +181,7 @@ class CallMethod implements Comparable<CallMethod>  {
 
 				ASet<String> inherit = new ASet<String>().appendAll(StringUtils.split(m.inherit()));
 				if (inherit.contains("*")) 
-					inherit.appendAll("SERIALIZERS","PARSERS","TRANSFORMS","PROPERTIES");
+					inherit.appendAll("SERIALIZERS","PARSERS","TRANSFORMS","PROPERTIES","ENCODERS");
 
 				SerializerGroupBuilder sgb = null;
 				ParserGroupBuilder pgb = null;
@@ -324,12 +324,10 @@ class CallMethod implements Comparable<CallMethod>  {
 						properties.put(p1, true);
 				}
 
-				if (m.encoders().length > 0 || ! m.inheritEncoders()) {
-					EncoderGroupBuilder g = EncoderGroup.create();
-					if (m.inheritEncoders())
+				if (m.encoders().length > 0) {
+					EncoderGroupBuilder g = EncoderGroup.create().append(IdentityEncoder.INSTANCE);
+					if (inherit.contains("ENCODERS"))
 						g.append(encoders);
-					else
-						g.append(IdentityEncoder.INSTANCE);
 
 					for (Class<? extends Encoder> c : m.encoders()) {
 						try {

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/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 91145d9..7507a0c 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
@@ -32,6 +32,7 @@ import javax.servlet.http.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.encoders.*;
+import org.apache.juneau.encoders.Encoder;
 import org.apache.juneau.http.*;
 import org.apache.juneau.httppart.*;
 import org.apache.juneau.ini.*;
@@ -1091,6 +1092,154 @@ public final class RestContext extends BeanContext {
 	 */
 	public static final String REST_mimeTypes = PREFIX + "mimeTypes.ss";
 
+//	/**
+//	 * <b>Configuration property:</b>  Serializers. 
+//	 *
+//	 * <ul>
+//	 * 	<li><b>Name:</b> <js>"RestContext.serializers.lo"</js>
+//	 * 	<li><b>Data type:</b> <code>List&lt;Class &lt;? <jk>extends</jk>
Serializer&gt; | Serializer&gt;</code>
+//	 * 	<li><b>Default:</b> empty list
+//	 * 	<li><b>Session-overridable:</b> <jk>false</jk>
+//	 * </ul>
+//	 * 
+//	 * <h6 class='topic'>Notes:</h6>
+//	 * <ul class='spaced-list'>
+//	 * 	<li>Property:  {@link RestContext#REST_serializers}
+//	 * 	<li>Annotations: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestResource#serializers()} 
+//	 * 			<li>{@link RestMethod#serializers()} 
+//	 * 		</ul>
+//	 * 	<li>Methods: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestContextBuilder#serializers(Class...)}
+//	 * 			<li>{@link RestContextBuilder#serializers(Serializer...)}
+//	 * 		</ul>
+//	 * </ul>
+//	 */
+//	public static final String REST_serializers = PREFIX + "serializers.lo";
+//
+//	/**
+//	 * <b>Configuration property:</b>  Parsers. 
+//	 *
+//	 * <ul>
+//	 * 	<li><b>Name:</b> <js>"RestContext.parsers.lo"</js>
+//	 * 	<li><b>Data type:</b> <code>List&lt;Class &lt;? <jk>extends</jk>
Parser&gt; | Parser&gt;</code>
+//	 * 	<li><b>Default:</b> empty list
+//	 * 	<li><b>Session-overridable:</b> <jk>false</jk>
+//	 * </ul>
+//	 * 
+//	 * <h6 class='topic'>Notes:</h6>
+//	 * <ul class='spaced-list'>
+//	 * 	<li>Property:  {@link RestContext#REST_parsers}
+//	 * 	<li>Annotations: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestResource#parsers()} 
+//	 * 			<li>{@link RestMethod#parsers()} 
+//	 * 		</ul>
+//	 * 	<li>Methods: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestContextBuilder#parsers(Class...)}
+//	 * 			<li>{@link RestContextBuilder#parsers(Parser...)}
+//	 * 		</ul>
+//	 * </ul>
+//	 */
+//	public static final String REST_parsers = PREFIX + "parsers.lo";
+//
+//	/**
+//	 * <b>Configuration property:</b>  HTTP part serializer. 
+//	 *
+//	 * <ul>
+//	 * 	<li><b>Name:</b> <js>"RestContext.partSerializer.o"</js>
+//	 * 	<li><b>Data type:</b> <code>Class &lt;? <jk>extends</jk>
HttpPartSerializer&gt; | HttpPartSerializer</code>
+//	 * 	<li><b>Default:</b> {@link SimpleUonPartSerializer}
+//	 * 	<li><b>Session-overridable:</b> <jk>false</jk>
+//	 * </ul>
+//	 * 
+//	 * <h6 class='topic'>Notes:</h6>
+//	 * <ul class='spaced-list'>
+//	 * 	<li>Property:  {@link RestContext#REST_partSerializer}
+//	 * 	<li>Annotations: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestResource#partSerializer()} 
+//	 * 		</ul>
+//	 * 	<li>Methods: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestContextBuilder#partSerializer(Class)}
+//	 * 			<li>{@link RestContextBuilder#partSerializer(HttpPartSerializer)}
+//	 * 		</ul>
+//	 * </ul>
+//	 */
+//	public static final String REST_partSerializer = PREFIX + "partSerializer.o";
+//
+//	/**
+//	 * <b>Configuration property:</b>  HTTP part parser. 
+//	 *
+//	 * <ul>
+//	 * 	<li><b>Name:</b> <js>"RestContext.partParser.o"</js>
+//	 * 	<li><b>Data type:</b> <code>Class &lt;? <jk>extends</jk>
HttpPartParser&gt; | HttpPartParser</code>
+//	 * 	<li><b>Default:</b> {@link UonPartParser}
+//	 * 	<li><b>Session-overridable:</b> <jk>false</jk>
+//	 * </ul>
+//	 * 
+//	 * <h6 class='topic'>Notes:</h6>
+//	 * <ul class='spaced-list'>
+//	 * 	<li>Property:  {@link RestContext#REST_partParser}
+//	 * 	<li>Annotations: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestResource#partParser()} 
+//	 * 		</ul>
+//	 * 	<li>Methods: 
+//	 * 		<ul>
+//	 * 			<li>{@link RestContextBuilder#partParser(Class)}
+//	 * 			<li>{@link RestContextBuilder#partParser(HttpPartParser)}
+//	 * 		</ul>
+//	 * </ul>
+//	 */
+//	public static final String REST_partParser = PREFIX + "partParser.o";
+
+	/**
+	 * <b>Configuration property:</b>  Compression encoders. 
+	 *
+	 * <ul>
+	 * 	<li><b>Name:</b> <js>"RestContext.encoders.o"</js>
+	 * 	<li><b>Data type:</b> <code>List&lt;Class &lt;? <jk>extends</jk>
Encoder&gt; | Encoder&gt;</code>
+	 * 	<li><b>Default:</b> empty list
+	 * 	<li><b>Session-overridable:</b> <jk>false</jk>
+	 * </ul>
+	 * 
+	 * <p>
+	 * These can be used to enable various kinds of compression (e.g. <js>"gzip"</js>)
on requests and responses.
+	 *
+	 * <h5 class='section'>Example:</h5>
+	 * <p class='bcode'>
+	 * 	<jc>// Servlet with automated support for GZIP compression</jc>
+	 * 	<ja>@RestResource</ja>(encoders={GzipEncoder.<jk>class</jk>})
+	 * 	<jk>public</jk> MyRestServlet <jk>extends</jk> RestServlet {
+	 * 		...
+	 * 	}
+	 * </p>
+	 * 
+	 * <h6 class='topic'>Notes:</h6>
+	 * <ul class='spaced-list'>
+	 * 	<li>Property:  {@link RestContext#REST_encoders}
+	 * 	<li>Annotations: 
+	 * 		<ul>
+	 * 			<li>{@link RestResource#encoders()} 
+	 * 			<li>{@link RestMethod#encoders()} 
+	 * 		</ul>
+	 * 	<li>Methods: 
+	 * 		<ul>
+	 * 			<li>{@link RestContextBuilder#encoders(Class...)}
+	 * 			<li>{@link RestContextBuilder#encoders(Encoder...)}
+	 * 		</ul>
+	 * 	<li>Instance classes must provide a public no-arg constructor, or a public constructor
that takes in a
+	 * 		{@link PropertyStore} object.
+	 * 	<li>Instance class can be defined as an inner class of the REST resource class.
+	 * </ul>
+	 */
+	public static final String REST_encoders = PREFIX + "encoders.lo";
+
 	
 	//-------------------------------------------------------------------------------------------------------------------
 	// Instance
@@ -1252,7 +1401,7 @@ public final class RestContext extends BeanContext {
 			parsers = builder.parsers.apply(ps).add(properties).build();
 			partSerializer = resolve(resource, HttpPartSerializer.class, builder.partSerializer, serializers.getPropertyStore());
 			partParser = resolve(resource, HttpPartParser.class, builder.partParser, parsers.getPropertyStore());
-			encoders = builder.encoders.build();
+			encoders = new EncoderGroupBuilder().append(getInstanceArrayProperty(REST_encoders, Encoder.class,
new Encoder[0], true, resource, ps)).build();
 			beanContext = BeanContext.create().apply(ps).add(properties).build();
 
 			mimetypesFileTypeMap = new ExtendedMimetypesFileTypeMap();

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/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 f36e51e..03e9713 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
@@ -105,7 +105,6 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	Object 
 		partSerializer = SimpleUonPartSerializer.class, 
 		partParser = UonPartParser.class;
-	EncoderGroupBuilder encoders = EncoderGroup.create().append(IdentityEncoder.INSTANCE);
 
 	List<Object> childResources = new ArrayList<>();
 	String path;
@@ -141,6 +140,7 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 		
 		logger(RestLogger.Normal.class);
 		staticFileResponseHeader("Cache-Control", "max-age=86400, public");
+		encoders(IdentityEncoder.INSTANCE);
 
 		try {
 
@@ -573,41 +573,6 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	}
 
 	/**
-	 * Adds class-level encoders to this resource.
-	 *
-	 * <p>
-	 * This is the programmatic equivalent to the {@link RestResource#encoders() @RestResource.encoders()}
annotation.
-	 *
-	 * <p>
-	 * Values are added AFTER those found in the annotation and therefore take precedence over
those defined via the
-	 * annotation.
-	 *
-	 * <p>
-	 * By default, only the {@link IdentityEncoder} is included in this list.
-	 *
-	 * @param encoders The parser classes to add to this config.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder encoders(Class<?>...encoders) {
-		this.encoders.append(encoders);
-		return this;
-	}
-
-	/**
-	 * Adds class-level encoders to this resource.
-	 *
-	 * <p>
-	 * Same as {@link #encoders(Class...)} except allows you to pass in encoder instances.
-	 *
-	 * @param encoders The encoders to add to this config.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder encoders(Encoder...encoders) {
-		this.encoders.append(encoders);
-		return this;
-	}
-
-	/**
 	 * Adds a child resource to this resource.
 	 *
 	 * <p>
@@ -2405,6 +2370,86 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	}
 
 	/**
+	 * <b>Configuration property:</b>  Compression encoders. 
+	 *
+	 * <p>
+	 * These can be used to enable various kinds of compression (e.g. <js>"gzip"</js>)
on requests and responses.
+	 *
+	 * <h5 class='section'>Example:</h5>
+	 * <p class='bcode'>
+	 * 	<jc>// Servlet with automated support for GZIP compression</jc>
+	 * 	<ja>@RestResource</ja>(encoders={GzipEncoder.<jk>class</jk>})
+	 * 	<jk>public</jk> MyRestServlet <jk>extends</jk> RestServlet {
+	 * 		...
+	 * 	}
+	 * </p>
+	 * 
+	 * <h6 class='topic'>Notes:</h6>
+	 * <ul class='spaced-list'>
+	 * 	<li>Property:  {@link RestContext#REST_encoders}
+	 * 	<li>Annotations: 
+	 * 		<ul>
+	 * 			<li>{@link RestResource#encoders()} 
+	 * 			<li>{@link RestMethod#encoders()} 
+	 * 		</ul>
+	 * 	<li>Methods: 
+	 * 		<ul>
+	 * 			<li>{@link RestContextBuilder#encoders(Class...)}
+	 * 			<li>{@link RestContextBuilder#encoders(Encoder...)}
+	 * 		</ul>
+	 * 	<li>Instance classes must provide a public no-arg constructor, or a public constructor
that takes in a
+	 * 		{@link PropertyStore} object.
+	 * 	<li>Instance class can be defined as an inner class of the REST resource class.
+	 * </ul>
+	 *
+	 * @param encoders Encoder classes to add to this config.
+	 * @return This object (for method chaining).
+	 */
+	public RestContextBuilder encoders(Class<?>...encoders) {
+		return addTo(REST_encoders, encoders);
+	}
+
+	/**
+	 * <b>Configuration property:</b>  Compression encoders. 
+	 *
+	 * <p>
+	 * These can be used to enable various kinds of compression (e.g. <js>"gzip"</js>)
on requests and responses.
+	 *
+	 * <h5 class='section'>Example:</h5>
+	 * <p class='bcode'>
+	 * 	<jc>// Servlet with automated support for GZIP compression</jc>
+	 * 	<ja>@RestResource</ja>(encoders={GzipEncoder.<jk>class</jk>})
+	 * 	<jk>public</jk> MyRestServlet <jk>extends</jk> RestServlet {
+	 * 		...
+	 * 	}
+	 * </p>
+	 * 
+	 * <h6 class='topic'>Notes:</h6>
+	 * <ul class='spaced-list'>
+	 * 	<li>Property:  {@link RestContext#REST_encoders}
+	 * 	<li>Annotations: 
+	 * 		<ul>
+	 * 			<li>{@link RestResource#encoders()} 
+	 * 			<li>{@link RestMethod#encoders()} 
+	 * 		</ul>
+	 * 	<li>Methods: 
+	 * 		<ul>
+	 * 			<li>{@link RestContextBuilder#encoders(Class...)}
+	 * 			<li>{@link RestContextBuilder#encoders(Encoder...)}
+	 * 		</ul>
+	 * 	<li>Instance classes must provide a public no-arg constructor, or a public constructor
that takes in a
+	 * 		{@link PropertyStore} object.
+	 * 	<li>Instance class can be defined as an inner class of the REST resource class.
+	 * </ul>
+	 *
+	 * @param encoders Encoder instances to add to this config.
+	 * @return This object (for method chaining).
+	 */
+	public RestContextBuilder encoders(Encoder...encoders) {
+		return addTo(REST_encoders, encoders);
+	}
+
+	/**
 	 * <b>Configuration property:</b>  Serializer listener.
 	 * 
 	 * <p>

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
----------------------------------------------------------------------
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
index a2eae24..f588ffe 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java
@@ -262,6 +262,7 @@ public @interface RestMethod {
 	 * 	<li>"PARSERS" - Inherit class-level parsers.
 	 * 	<li>"TRANSFORMS" - Inherit class-level bean properties and pojo-swaps.
 	 * 	<li>"PROPERTIES" - Inherit class-level properties (other than transforms).
+	 * 	<li>"ENCODERS" - Inherit class-level encoders.
 	 * 	<li>"*" - Inherit everything.
 	 * </ul>
 	 *
@@ -334,41 +335,46 @@ public @interface RestMethod {
 	String[] supportedContentTypes() default {};
 
 	/**
-	 * Appends to the list of {@link Encoder encoders} specified on the servlet.
+	 * Compression encoders. 
 	 *
 	 * <p>
 	 * Use this annotation when the list of encoders assigned to a method differs from the list
of encoders assigned at
 	 * the servlet level.
-	 *
+	 * 
 	 * <p>
 	 * These can be used to enable various kinds of compression (e.g. <js>"gzip"</js>)
on requests and responses.
 	 *
+	 * <h5 class='section'>Example:</h5>
 	 * <p class='bcode'>
-	 * 	<jk>public class</jk> MyResource <jk>extends</jk> RestServlet
{
-	 *
-	 * 		<ja>@RestMethod</ja>(
-	 * 			name=<jsf>PUT</jsf>,
-	 * 			path=<js>"/foo"</js>,
-	 * 			encoders={GzipEncoder.<jk>class</jk>}
-	 * 		)
-	 * 		<jk>public</jk> Object doGetWithSpecialEncoding() {
-	 * 			<jc>// Handle request with special encoding</jc>
-	 * 		}
+	 * 	<jc>// Servlet with automated support for GZIP compression</jc>
+	 * 	<ja>@RestResource</ja>(encoders={GzipEncoder.<jk>class</jk>})
+	 * 	<jk>public</jk> MyRestServlet <jk>extends</jk> RestServlet {
+	 * 		...
 	 * 	}
 	 * </p>
-	 *
-	 * <p>
-	 * If you want to OVERRIDE the set of encoders specified by the servlet, combine this annotation
with
-	 * <code><ja>@RestMethod</ja>(inheritEncoders=<jk>false</jk>)</code>.
+	 * 
+	 * <h6 class='topic'>Notes:</h6>
+	 * <ul class='spaced-list'>
+	 * 	<li>Property:  {@link RestContext#REST_encoders}
+	 * 	<li>Annotations: 
+	 * 		<ul>
+	 * 			<li>{@link RestResource#encoders()} 
+	 * 			<li>{@link RestMethod#encoders()} 
+	 * 		</ul>
+	 * 	<li>Methods: 
+	 * 		<ul>
+	 * 			<li>{@link RestContextBuilder#encoders(Class...)}
+	 * 			<li>{@link RestContextBuilder#encoders(Encoder...)}
+	 * 		</ul>
+	 * 	<li>Instance classes must provide a public no-arg constructor, or a public constructor
that takes in a
+	 * 		{@link PropertyStore} object.
+	 * 	<li>Instance class can be defined as an inner class of the REST resource class.
+	 * 	<li>Use <code>inherit={<js>"ENCODERS"</js>}</code> to
inherit encoders from the resource class.
+	 * </ul>
 	 */
 	Class<? extends Encoder>[] encoders() default {};
 
 	/**
-	 * Specifies whether the method should inherit encoders from the servlet.
-	 */
-	boolean inheritEncoders() default true;
-
-	/**
 	 * Same as {@link RestResource#properties()}, except defines property values by default
when this method is called.
 	 *
 	 * <p>

http://git-wip-us.apache.org/repos/asf/juneau/blob/3fc40afc/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
----------------------------------------------------------------------
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
index 6a55849..656c8bf 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestResource.java
@@ -411,14 +411,11 @@ public @interface RestResource {
 	Class<? extends ResponseHandler>[] responseHandlers() default {};
 
 	/**
-	 * Specifies a list of {@link Encoder} to associate with this servlet.
+	 * Compression encoders. 
 	 *
 	 * <p>
 	 * These can be used to enable various kinds of compression (e.g. <js>"gzip"</js>)
on requests and responses.
 	 *
-	 * <p>
-	 * This annotation can only be used on {@link Encoder} classes that have no-arg constructors.
-	 *
 	 * <h5 class='section'>Example:</h5>
 	 * <p class='bcode'>
 	 * 	<jc>// Servlet with automated support for GZIP compression</jc>
@@ -427,10 +424,24 @@ public @interface RestResource {
 	 * 		...
 	 * 	}
 	 * </p>
-	 *
-	 * <p>
-	 * The programmatic equivalent to this annotation are the {@link RestContextBuilder#encoders(Class...)}/
-	 * {@link RestContextBuilder#encoders(Encoder...)} methods.
+	 * 
+	 * <h6 class='topic'>Notes:</h6>
+	 * <ul class='spaced-list'>
+	 * 	<li>Property:  {@link RestContext#REST_encoders}
+	 * 	<li>Annotations: 
+	 * 		<ul>
+	 * 			<li>{@link RestResource#encoders()} 
+	 * 			<li>{@link RestMethod#encoders()} 
+	 * 		</ul>
+	 * 	<li>Methods: 
+	 * 		<ul>
+	 * 			<li>{@link RestContextBuilder#encoders(Class...)}
+	 * 			<li>{@link RestContextBuilder#encoders(Encoder...)}
+	 * 		</ul>
+	 * 	<li>Instance classes must provide a public no-arg constructor, or a public constructor
that takes in a
+	 * 		{@link PropertyStore} object.
+	 * 	<li>Instance class can be defined as an inner class of the REST resource class.
+	 * </ul>
 	 */
 	Class<? extends Encoder>[] encoders() default {};
 


Mime
View raw message