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/08/27 22:22:19 UTC

[3/6] incubator-juneau git commit: Support serializing directly from Readers and InputStreams.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
index 66d6bae..42ae307 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
@@ -15,7 +15,6 @@ package org.apache.juneau.json;
 import static org.apache.juneau.serializer.SerializerContext.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 
 /**
@@ -31,7 +30,6 @@ import org.apache.juneau.serializer.*;
  *
  * Produces the JSON-schema for the JSON produced by the {@link JsonSerializer} class with the same properties.
  */
-@Produces(value="application/json+schema,text/json+schema",contentType="application/json")
 public final class JsonSchemaSerializer extends JsonSerializer {
 
 	/**
@@ -42,8 +40,10 @@ public final class JsonSchemaSerializer extends JsonSerializer {
 	public JsonSchemaSerializer(PropertyStore propertyStore) {
 		super(
 			propertyStore.copy()
-			.append(SERIALIZER_detectRecursions, true)
-			.append(SERIALIZER_ignoreRecursions, true)
+				.append(SERIALIZER_detectRecursions, true)
+				.append(SERIALIZER_ignoreRecursions, true),
+			"application/json",
+			"application/json+schema", "text/json+schema"
 		);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
index f9e875d..17e3a31 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerSession.java
@@ -40,7 +40,6 @@ public class JsonSchemaSerializerSession extends JsonSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected JsonSchemaSerializerSession(JsonSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
index db0a78d..0709660 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
@@ -17,7 +17,6 @@ import static org.apache.juneau.json.JsonSerializerContext.*;
 import java.util.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 
 /**
@@ -98,7 +97,6 @@ import org.apache.juneau.serializer.*;
  * 	String json = serializer.serialize(someObject);
  * </p>
  */
-@Produces("application/json,text/json")
 public class JsonSerializer extends WriterSerializer {
 
 	/** Default serializer, all default settings.*/
@@ -137,7 +135,6 @@ public class JsonSerializer extends WriterSerializer {
 	}
 
 	/** Default serializer, single quotes, simple mode. */
-	@Produces(value="application/json+simple,text/json+simple",contentType="application/json")
 	public static class Simple extends JsonSerializer {
 
 		/**
@@ -148,8 +145,10 @@ public class JsonSerializer extends WriterSerializer {
 		public Simple(PropertyStore propertyStore) {
 			super(
 				propertyStore.copy()
-				.append(JSON_simpleMode, true)
-				.append(SERIALIZER_quoteChar, '\'')
+					.append(JSON_simpleMode, true)
+					.append(SERIALIZER_quoteChar, '\''),
+				"application/json",
+				"application/json+simple", "text/json+simple"
 			);
 		}
 	}
@@ -201,10 +200,36 @@ public class JsonSerializer extends WriterSerializer {
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
 	 */
 	public JsonSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+		this(propertyStore, "application/json", "application/json", "text/json");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param produces
+	 * 	The media type that this serializer produces.
+	 * @param accept
+	 * 	The accept media types that the serializer can handle.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 * 	<p>
+	 * 	If empty, then assumes the only media type supported is <code>produces</code>.
+	 * 	<p>
+	 * 	For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+	 * 	<js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code>
+	 * 	<br>...or...
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);</code>
+	 */
+	public JsonSerializer(PropertyStore propertyStore, String produces, String...accept) {
+		super(propertyStore, produces, accept);
 		this.ctx = createContext(JsonSerializerContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
index 12c9433..c9266a2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.json.JsonSerializerContext.*;
 import java.util.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.transform.*;
 
@@ -45,7 +46,6 @@ public class JsonSerializerSession extends WriterSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected JsonSerializerSession(JsonSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);
@@ -135,6 +135,9 @@ public class JsonSerializerSession extends WriterSerializerSession {
 		else if (sType.isArray()) {
 			serializeCollection(out, toList(sType.getInnerClass(), o), eType);
 		}
+		else if (sType.isReader() || sType.isInputStream()) {
+			IOUtils.pipe(o, out);
+		}
 		else
 			out.stringValue(toString(o));
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
index 0d9ab31..e30d678 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.msgpack;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.parser.*;
 
 /**
@@ -30,13 +29,12 @@ import org.apache.juneau.parser.*;
  * 	<li>{@link MsgPackParserContext}
  * </ul>
  */
-@Consumes("octal/msgpack")
 public class MsgPackParser extends InputStreamParser {
 
 	/** Default parser, all default settings.*/
 	public static final MsgPackParser DEFAULT = new MsgPackParser(PropertyStore.create());
 
-	
+
 	private final MsgPackParserContext ctx;
 
 	/**
@@ -45,7 +43,7 @@ public class MsgPackParser extends InputStreamParser {
 	 * @param propertyStore The property store containing all the settings for this object.
 	 */
 	public MsgPackParser(PropertyStore propertyStore) {
-		super(propertyStore);
+		super(propertyStore, "octal/msgpack");
 		this.ctx = createContext(MsgPackParserContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
index ad4dbce..ab5442f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.msgpack;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 
 /**
@@ -34,7 +33,6 @@ import org.apache.juneau.serializer.*;
  * 	<li>{@link BeanContext}
  * </ul>
  */
-@Produces("octal/msgpack")
 public class MsgPackSerializer extends OutputStreamSerializer {
 
 	/** Default serializer, all default settings.*/
@@ -49,7 +47,7 @@ public class MsgPackSerializer extends OutputStreamSerializer {
 	 * @param propertyStore The property store containing all the settings for this object.
 	 */
 	public MsgPackSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+		super(propertyStore, "octal/msgpack");
 		this.ctx = createContext(MsgPackSerializerContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
index 4a8177d..9b81a16 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.msgpack.MsgPackSerializerContext.*;
 import java.util.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.transform.*;
 
@@ -43,7 +44,6 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected MsgPackSerializerSession(MsgPackSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);
@@ -143,7 +143,11 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
 		}
 		else if (sType.isArray()) {
 			serializeCollection(out, toList(sType.getInnerClass(), o), eType);
-		} else
+		}
+		else if (sType.isReader() || sType.isInputStream()) {
+			IOUtils.pipe(o, out);
+		}
+		else
 			out.appendString(toString(o));
 
 		if (! isRecursion)

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java b/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
index 9fb15d6..29b11ce 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/InputStreamParser.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.parser;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 
 /**
  * Subclass of {@link Parser} for byte-based parsers.
@@ -25,23 +24,17 @@ import org.apache.juneau.annotation.*;
  * <ul>
  * 	<li><code>parse(InputStream, ClassMeta, ParserContext)</code>
  * </ul>
- *
- * <h6 class='topic'>@Consumes annotation</h6>
- *
- * The media types that this parser can handle is specified through the {@link Consumes @Consumes} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()} method.
- */
+  */
 public abstract class InputStreamParser extends Parser {
 
 	/**
 	 * Constructor.
 	 *
 	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param consumes The list of media types that this parser consumes (e.g. <js>"application/json"</js>).
 	 */
-	protected InputStreamParser(PropertyStore propertyStore) {
-		super(propertyStore);
+	protected InputStreamParser(PropertyStore propertyStore, String...consumes) {
+		super(propertyStore, consumes);
 	}
 
 	@Override /* Parser */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
index b077654..b365a54 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
@@ -12,15 +12,11 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.parser;
 
-import static org.apache.juneau.internal.StringUtils.*;
-import static org.apache.juneau.internal.ReflectionUtils.*;
-
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.http.*;
 import org.apache.juneau.transform.*;
 import org.apache.juneau.transforms.*;
@@ -29,13 +25,6 @@ import org.apache.juneau.utils.*;
 /**
  * Parent class for all Juneau parsers.
  *
- * <h6 class='topic'>@Consumes annotation</h6>
- *
- * The media types that this parser can handle is specified through the {@link Consumes @Consumes} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()} method.
- *
  * <h6 class='topic'>Valid data conversions</h6>
  *
  * Parsers can parse any parsable POJO types, as specified in the <a class="doclink"
@@ -144,20 +133,15 @@ import org.apache.juneau.utils.*;
 public abstract class Parser extends CoreObject {
 
 	/** General parser properties currently set on this parser. */
-	private final MediaType[] mediaTypes;
+	private final MediaType[] consumes;
 
 	// Hidden constructor to force subclass from InputStreamParser or ReaderParser.
-	Parser(PropertyStore propertyStore) {
+	Parser(PropertyStore propertyStore, String...consumes) {
 		super(propertyStore);
 
-		Consumes c = getAnnotation(Consumes.class, getClass());
-		if (c == null)
-			throw new FormattedRuntimeException("Class ''{0}'' is missing the @Consumes annotation", c);
-
-		String[] mt = split(c.value());
-		this.mediaTypes = new MediaType[mt.length];
-		for (int i = 0; i < mt.length; i++) {
-			mediaTypes[i] = MediaType.forString(mt[i]);
+		this.consumes = new MediaType[consumes.length];
+		for (int i = 0; i < consumes.length; i++) {
+			this.consumes[i] = MediaType.forString(consumes[i]);
 		}
 	}
 
@@ -359,9 +343,19 @@ public abstract class Parser extends CoreObject {
 	 * @return The new context.
 	 */
 	public final ParserSession createSession() {
-		return createSession(null);
+		return createSession(createDefaultSessionArgs());
 	}
 
+	/**
+	 * Creates the session arguments object that gets passed to the {@link #createSession(ParserSessionArgs)} method.
+	 *
+	 * @return
+	 * 	A new default session arguments object.
+	 * 	<p>The arguments can be modified before passing to the {@link #createSession(ParserSessionArgs)}.
+	 */
+	protected final ParserSessionArgs createDefaultSessionArgs() {
+		return new ParserSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, getPrimaryMediaType(), null);
+	}
 
 	//--------------------------------------------------------------------------------
 	// Optional methods
@@ -467,23 +461,20 @@ public abstract class Parser extends CoreObject {
 	//--------------------------------------------------------------------------------
 
 	/**
-	 * Returns the media types handled based on the value of the {@link Consumes} annotation on the parser class.
-	 *
-	 * <p>
-	 * This method can be overridden by subclasses to determine the media types programmatically.
+	 * Returns the media types handled based on the values passed to the <code>consumes</code> constructor parameter.
 	 *
 	 * @return The list of media types.  Never <jk>null</jk>.
 	 */
-	public MediaType[] getMediaTypes() {
-		return mediaTypes;
+	public final MediaType[] getMediaTypes() {
+		return consumes;
 	}
 
 	/**
-	 * Returns the first media type specified on this parser via the {@link Consumes} annotation.
+	 * Returns the first media type handled based on the values passed to the <code>consumes</code> constructor parameter.
 	 *
 	 * @return The media type.
 	 */
-	public MediaType getPrimaryMediaType() {
-		return mediaTypes == null || mediaTypes.length == 0 ? null : mediaTypes[0];
+	public final MediaType getPrimaryMediaType() {
+		return consumes == null || consumes.length == 0 ? null : consumes[0];
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
index 938f643..cbb2a85 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSession.java
@@ -54,11 +54,9 @@ public abstract class ParserSession extends BeanSession {
 	 * 	Runtime session arguments.
 	 */
 	protected ParserSession(ParserContext ctx, ParserSessionArgs args) {
-		super(ctx != null ? ctx : ParserContext.DEFAULT, args != null ? args : ParserSessionArgs.DEFAULT);
+		super(ctx != null ? ctx : ParserContext.DEFAULT, args);
 		if (ctx == null)
 			ctx = ParserContext.DEFAULT;
-		if (args == null)
-			args = ParserSessionArgs.DEFAULT;
 		Class<?> listenerClass;
 		ObjectMap p = getProperties();
 		if (p.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
index 65ce23e..8e43052 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserSessionArgs.java
@@ -23,11 +23,6 @@ import org.apache.juneau.http.*;
  */
 public final class ParserSessionArgs extends BeanSessionArgs {
 
-	/**
-	 * Default session arguments.
-	 */
-	protected static final ParserSessionArgs DEFAULT = new ParserSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, null, null);
-
 	final Method javaMethod;
 	final Object outer;
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java b/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
index a987a5e..0d107a8 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/ReaderParser.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.parser;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 
 /**
  * Subclass of {@link Parser} for characters-based parsers.
@@ -25,13 +24,6 @@ import org.apache.juneau.annotation.*;
  * <ul>
  * 	<li><code>parse(ParserSession, ClassMeta)</code>
  * </ul>
- *
- * <h6 class='topic'>@Consumes annotation</h6>
- *
- * The media types that this parser can handle is specified through the {@link Consumes @Consumes} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()} method.
  */
 public abstract class ReaderParser extends Parser {
 
@@ -39,9 +31,10 @@ public abstract class ReaderParser extends Parser {
 	 * Constructor.
 	 *
 	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param consumes The list of media types that this parser consumes (e.g. <js>"application/json"</js>, <js>"*&#8203;/json"</js>).
 	 */
-	protected ReaderParser(PropertyStore propertyStore) {
-		super(propertyStore);
+	protected ReaderParser(PropertyStore propertyStore, String...consumes) {
+		super(propertyStore, consumes);
 	}
 
 	@Override /* Parser */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/parser/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/package.html b/juneau-core/src/main/java/org/apache/juneau/parser/package.html
index f3203e9..98a4ca0 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/package.html
@@ -112,15 +112,13 @@
 	<p>
 		Defining a new parser is quite simple if you subclass directly from {@link org.apache.juneau.parser.ReaderParser} 
 		or {@link org.apache.juneau.parser.InputStreamParser}.  
-		In each case, you simply need to implement a single method and specify a 
-		{@link org.apache.juneau.annotation.Consumes} annotation.
+		In each case, you simply need to implement a single method .
 	</p>
 	<p>
 		The following example shows a simple parser that converts input streams to images using standard JRE classes.
 	</p>
 	<p class='bcode'>
 	<jd>/** Parser for converting byte streams to images */</jd>
-	<ja>@Consumes</ja>(<js>"image/png,image/jpeg"</js>)
 	<jk>public class</jk> ImageParser <jk>extends</jk> InputStreamParser {
 
 		<jd>/**
@@ -128,7 +126,7 @@
 		 * <ja>@param</ja> propertyStore The property store containing all the settings for this object.
 		 */</jd>
 		<jk>public</jk> ImageParser(PropertyStore propertyStore) {
-			<jk>super</jk>(propertyStore);
+			<jk>super</jk>(propertyStore, <js>"image/png"</js>, <js>"image/jpeg"</js>);
 		}
 
 		<ja>@Override</ja> <jc>/* Parser */</jc>

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
index c5a2695..959560a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextParser.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.plaintext;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.parser.*;
 import org.apache.juneau.transform.*;
 
@@ -44,7 +43,6 @@ import org.apache.juneau.transform.*;
  * 	<li>{@link ParserContext}
  * </ul>
  */
-@Consumes("text/plain")
 public class PlainTextParser extends ReaderParser {
 
 	/** Default parser, all default settings.*/
@@ -57,7 +55,20 @@ public class PlainTextParser extends ReaderParser {
 	 * @param propertyStore The property store containing all the settings for this object.
 	 */
 	public PlainTextParser(PropertyStore propertyStore) {
-		super(propertyStore);
+		this(propertyStore, "text/plain");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param consumes The media types that this parser consumes.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 */
+	public PlainTextParser(PropertyStore propertyStore, String...consumes) {
+		super(propertyStore, consumes);
 	}
 
 	@Override /* CoreObject */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
index 910e2d5..a813865 100644
--- a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializer.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.plaintext;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.transform.*;
 
@@ -43,7 +42,6 @@ import org.apache.juneau.transform.*;
  * 	<li>{@link BeanContext}
  * </ul>
  */
-@Produces("text/plain")
 public class PlainTextSerializer extends WriterSerializer {
 
 	/** Default serializer, all default settings.*/
@@ -54,13 +52,40 @@ public class PlainTextSerializer extends WriterSerializer {
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
 	 */
 	public PlainTextSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+		this(propertyStore, "text/plain");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param produces
+	 * 	The media type that this serializer produces.
+	 * @param accept
+	 * 	The accept media types that the serializer can handle.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 * 	<p>
+	 * 	If empty, then assumes the only media type supported is <code>produces</code>.
+	 * 	<p>
+	 * 	For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+	 * 	<js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code>
+	 * 	<br>...or...
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);</code>
+	 */
+	public PlainTextSerializer(PropertyStore propertyStore, String produces, String...accept) {
+		super(propertyStore, produces, accept);
 		this.ctx = createContext(SerializerContext.class);
 	}
 
+
 	@Override /* CoreObject */
 	public PlainTextSerializerBuilder builder() {
 		return new PlainTextSerializerBuilder(propertyStore);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
index 0e69e09..5915f82 100644
--- a/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/plaintext/PlainTextSerializerSession.java
@@ -34,7 +34,6 @@ public class PlainTextSerializerSession extends WriterSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected PlainTextSerializerSession(SerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java
index b481f2e..2baede9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java
@@ -15,28 +15,35 @@ package org.apache.juneau.serializer;
 import static org.apache.juneau.internal.StringUtils.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 
 /**
  * Subclass of {@link Serializer} for byte-based serializers.
- *
- * <h6 class='topic'>@Produces annotation</h6>
- *
- * The media types that this serializer can produce is specified through the {@link Produces @Produces} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()}
- * and {@link #getResponseContentType()} methods.
  */
 public abstract class OutputStreamSerializer extends Serializer {
 
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param produces
+	 * 	The media type that this serializer produces.
+	 * @param accept
+	 * 	The accept media types that the serializer can handle.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 * 	<p>
+	 * 	If empty, then assumes the only media type supported is <code>produces</code>.
+	 * 	<p>
+	 * 	For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+	 * 	<js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code>
+	 * 	<br>...or...
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);</code>
 	 */
-	protected OutputStreamSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+	protected OutputStreamSerializer(PropertyStore propertyStore, String produces, String...accept) {
+		super(propertyStore, produces, accept);
 	}
 
 
@@ -66,7 +73,7 @@ public abstract class OutputStreamSerializer extends Serializer {
 	 */
 	@Override
 	public final byte[] serialize(Object o) throws SerializeException {
-		return createSession(null).serialize(o);
+		return createSession(createDefaultSessionArgs()).serialize(o);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
index 8098566..f0637f5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializerSession.java
@@ -38,7 +38,6 @@ public abstract class OutputStreamSerializerSession extends SerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected OutputStreamSerializerSession(SerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java
index d2640c3..f04e615 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java
@@ -12,13 +12,9 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.serializer;
 
-import static org.apache.juneau.internal.StringUtils.*;
-import static org.apache.juneau.internal.ReflectionUtils.*;
-
 import java.io.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.http.*;
 
 /**
@@ -39,35 +35,25 @@ import org.apache.juneau.http.*;
  * <p>
  * Subclasses should extend directly from {@link OutputStreamSerializer} or {@link WriterSerializer} depending on
  * whether it's a stream or character based serializer.
- *
- * <h6 class='topic'>@Produces annotation</h6>
- *
- * The media types that this serializer can produce is specified through the {@link Produces @Produces} annotation.
- * <br>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()}
- * and {@link #getResponseContentType()} methods.
  */
 public abstract class Serializer extends CoreObject {
 
-	private final MediaType[] mediaTypes;
-	private final MediaType contentType;
+	private final MediaType[] accept;
+	private final MediaType produces;
 
 	// Hidden constructors to force subclass from OuputStreamSerializer or WriterSerializer.
-	Serializer(PropertyStore propertyStore) {
+	Serializer(PropertyStore propertyStore, String produces, String...accept) {
 		super(propertyStore);
 
-		Produces p = getAnnotation(Produces.class, getClass());
-		if (p == null)
-			throw new FormattedRuntimeException("Class ''{0}'' is missing the @Produces annotation", getClass());
-
-		String[] mt = split(p.value());
-		this.mediaTypes = new MediaType[mt.length];
-		for (int i = 0; i < mt.length; i++) {
-			mediaTypes[i] = MediaType.forString(mt[i]);
+		this.produces = MediaType.forString(produces);
+		if (accept.length == 0) {
+			this.accept = new MediaType[]{this.produces};
+		} else {
+			this.accept = new MediaType[accept.length];
+			for (int i = 0; i < accept.length; i++) {
+				this.accept[i] = MediaType.forString(accept[i]);
+			}
 		}
-
-		String ct = p.contentType().isEmpty() ? this.mediaTypes[0].toString() : p.contentType();
-		contentType = ct.isEmpty() ? null : MediaType.forString(ct);
 	}
 
 	@Override /* CoreObject */
@@ -94,7 +80,6 @@ public abstract class Serializer extends CoreObject {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and serializer
 	 * 	contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 * @return
 	 * 	The new session object.
 	 * 	<br>Note that you must call {@link SerializerSession#close()} on this object to perform any necessary
@@ -116,7 +101,18 @@ public abstract class Serializer extends CoreObject {
 	 * 	cleanup.
 	 */
 	public final SerializerSession createSession() {
-		return createSession(null);
+		return createSession(createDefaultSessionArgs());
+	}
+
+	/**
+	 * Creates the session arguments object that gets passed to the {@link #createSession(SerializerSessionArgs)} method.
+	 *
+	 * @return
+	 * 	A new default session arguments object.
+	 * 	<p>The arguments can be modified before passing to the {@link #createSession(SerializerSessionArgs)}.
+	 */
+	public final SerializerSessionArgs createDefaultSessionArgs() {
+		return new SerializerSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, getResponseContentType(), null);
 	}
 
 	/**
@@ -176,24 +172,12 @@ public abstract class Serializer extends CoreObject {
 	//--------------------------------------------------------------------------------
 
 	/**
-	 * Returns the media types handled based on the value of the {@link Produces} annotation on the serializer class.
-	 *
-	 * <p>
-	 * This method can be overridden by subclasses to determine the media types programmatically.
+	 * Returns the media types handled based on the value of the <code>accept</code> parameter passed into the constructor.
 	 *
 	 * @return The list of media types.  Never <jk>null</jk>.
 	 */
 	public final MediaType[] getMediaTypes() {
-		return mediaTypes;
-	}
-
-	/**
-	 * Returns the first media type specified on this serializer via the {@link Produces} annotation.
-	 *
-	 * @return The media type.
-	 */
-	public final MediaType getPrimaryMediaType() {
-		return mediaTypes == null || mediaTypes.length == 0 ? null : mediaTypes[0];
+		return accept;
 	}
 
 	/**
@@ -212,7 +196,7 @@ public abstract class Serializer extends CoreObject {
 	 *
 	 * @return The response content type.  If <jk>null</jk>, then the matched media type is used.
 	 */
-	public MediaType getResponseContentType() {
-		return contentType;
+	public final MediaType getResponseContentType() {
+		return produces;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index f2428b6..a243fcc 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -90,14 +90,11 @@ public abstract class SerializerSession extends BeanSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected SerializerSession(SerializerContext ctx, SerializerSessionArgs args) {
-		super(ctx != null ? ctx : SerializerContext.DEFAULT, args != null ? args : SerializerSessionArgs.DEFAULT);
+		super(ctx != null ? ctx : SerializerContext.DEFAULT, args);
 		if (ctx == null)
 			ctx = SerializerContext.DEFAULT;
-		if (args == null)
-			args = SerializerSessionArgs.DEFAULT;
 		this.javaMethod = args.javaMethod;
 		UriResolution uriResolution;
 		UriRelativity uriRelativity;

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
index 68077b4..e1c2928 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSessionArgs.java
@@ -26,11 +26,6 @@ import org.apache.juneau.http.*;
  */
 public final class SerializerSessionArgs extends BeanSessionArgs {
 
-	/**
-	 * Default session arguments.
-	 */
-	public static final SerializerSessionArgs DEFAULT = new SerializerSessionArgs(ObjectMap.EMPTY_MAP, null, null, null, null, null);
-
 	final Method javaMethod;
 	final UriContext uriContext;
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
index 11d2138..3449dff 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializer.java
@@ -13,29 +13,36 @@
 package org.apache.juneau.serializer;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.utils.*;
 
 /**
  * Subclass of {@link Serializer} for character-based serializers.
- *
- * <h6 class='topic'>@Produces annotation</h6>
- *
- * The media types that this serializer can produce is specified through the {@link Produces @Produces} annotation.
- *
- * <p>
- * However, the media types can also be specified programmatically by overriding the {@link #getMediaTypes()}
- * and {@link #getResponseContentType()} methods.
  */
 public abstract class WriterSerializer extends Serializer {
 
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param produces
+	 * 	The media type that this serializer produces.
+	 * @param accept
+	 * 	The accept media types that the serializer can handle.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 * 	<p>
+	 * 	If empty, then assumes the only media type supported is <code>produces</code>.
+	 * 	<p>
+	 * 	For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+	 * 	<js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code>
+	 * 	<br>...or...
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);</code>
 	 */
-	protected WriterSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+	protected WriterSerializer(PropertyStore propertyStore, String produces, String...accept) {
+		super(propertyStore, produces, accept);
 	}
 
 
@@ -65,7 +72,7 @@ public abstract class WriterSerializer extends Serializer {
 	 */
 	@Override /* Serializer */
 	public final String serialize(Object o) throws SerializeException {
-		return createSession(null).serialize(o);
+		return createSession(createDefaultSessionArgs()).serialize(o);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
index b91085f..fdea9d3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/WriterSerializerSession.java
@@ -43,7 +43,6 @@ public abstract class WriterSerializerSession extends SerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected WriterSerializerSession(SerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/serializer/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/package.html b/juneau-core/src/main/java/org/apache/juneau/serializer/package.html
index 0057ce8..a7d9f87 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/package.html
@@ -114,8 +114,7 @@
 	<p>
 		Defining a new serializer is quite simple if you subclass directly from 
 		{@link org.apache.juneau.serializer.WriterSerializer}  or {@link org.apache.juneau.serializer.OutputStreamSerializer}.
-		<br>In each case, you simply need to implement a single method and specify a 
-		{@link org.apache.juneau.annotation.Produces} annotation.
+		<br>In each case, you simply need to implement a single method .
 	</p>
 	<p>
 		The following example shows a simple serializer that converts images to output streams using standard JRE 
@@ -123,7 +122,6 @@
 	</p>
 	<p class='bcode'>
 	<jd>/** Serializer for converting images to byte streams */</jd>
-	<ja>@Produces</ja>(<js>"image/png,image/jpeg"</js>)
 	<jk>public class</jk> ImageSerializer <jk>extends</jk> OutputStreamSerializer {
 
 		<jd>/**
@@ -131,7 +129,7 @@
 		 * <ja>@param</ja> propertyStore The property store containing all the settings for this object.
 		 */</jd>
 		<jk>public</jk> ImageSerializer(PropertyStore propertyStore) {
-			<jk>super</jk>(propertyStore);
+			<jk>super</jk>(propertyStore, <jk>null</jk>, <js>"image/png"</js>, <js>"image/jpeg"</js>);
 		}
 
 		<ja>@Override</ja> <jc>/* Serializer */</jc>

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
index 77f722b..1c58cb9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializer.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.soap;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.xml.*;
 
@@ -39,7 +38,6 @@ import org.apache.juneau.xml.*;
  * 	<li>{@link BeanContext}
  * </ul>
  */
-@Produces(value="text/xml+soap",contentType="text/xml")
 public final class SoapXmlSerializer extends XmlSerializer {
 
 	private final SoapXmlSerializerContext ctx;
@@ -50,7 +48,7 @@ public final class SoapXmlSerializer extends XmlSerializer {
 	 * @param propertyStore The property store containing all the settings for this object.
 	 */
 	public SoapXmlSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+		super(propertyStore, "text/xml", "text/xml+soap");
 		this.ctx = createContext(SoapXmlSerializerContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
index c899e44..39857b2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerSession.java
@@ -40,7 +40,6 @@ public class SoapXmlSerializerSession extends XmlSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	public SoapXmlSerializerSession(SoapXmlSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java
index 7410a7d..ffc8a6b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonParser.java
@@ -15,7 +15,6 @@ package org.apache.juneau.uon;
 import static org.apache.juneau.uon.UonParserContext.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.parser.*;
 
 /**
@@ -38,7 +37,6 @@ import org.apache.juneau.parser.*;
  * 	<li>{@link BeanContext}
  * </ul>
  */
-@Consumes("text/uon")
 public class UonParser extends ReaderParser {
 
 	/** Reusable instance of {@link UonParser}, all default settings. */
@@ -67,10 +65,23 @@ public class UonParser extends ReaderParser {
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
 	 */
 	public UonParser(PropertyStore propertyStore) {
-		super(propertyStore);
+		this(propertyStore, "text/uon");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param consumes
+	 * 	The list of media types that this parser consumes (e.g. <js>"application/json"</js>, <js>"*&#8203;/json"</js>).
+	 */
+	public UonParser(PropertyStore propertyStore, String...consumes) {
+		super(propertyStore, consumes);
 		this.ctx = createContext(UonParserContext.class);
 	}
 
@@ -85,7 +96,7 @@ public class UonParser extends ReaderParser {
 	 * @return A new parser session.
 	 */
 	protected final UonParserSession createParameterSession() {
-		return new UonParserSession(ctx);
+		return new UonParserSession(ctx, createDefaultSessionArgs(), false);
 	}
 
 	@Override /* Parser */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
index 7d50309..9f731d4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonParserSession.java
@@ -68,11 +68,17 @@ public class UonParserSession extends ReaderParserSession {
 	 * The main difference is that characters are never decoded, and the {@link UonParserContext#UON_decodeChars}
 	 * property is always ignored.
 	 *
-	 * @param ctx The context to copy setting from.
+	 * @param ctx
+	 * 	The context creating this session object.
+	 * 	The context contains all the configuration settings for this object.
+	 * @param args
+	 * 	Runtime session arguments.
+	 * @param decodeChars
+	 * 	Whether to decode characters.
 	 */
-	protected UonParserSession(UonParserContext ctx) {
-		super(ctx, null);
-		decodeChars = false;
+	protected UonParserSession(UonParserContext ctx, ParserSessionArgs args, boolean decodeChars) {
+		super(ctx, args);
+		this.decodeChars = decodeChars;
 	}
 
 	@Override /* ParserSession */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
index 5f1dc23..bb99e3c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializer.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.serializer.SerializerContext.*;
 import static org.apache.juneau.uon.UonSerializerContext.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 
 /**
@@ -125,7 +124,6 @@ import org.apache.juneau.serializer.*;
  * 	String s = UonSerializer.<jsf>DEFAULT</jsf>.serialize(s);
  * </p>
  */
-@Produces("text/uon")
 public class UonSerializer extends WriterSerializer {
 
 	/** Reusable instance of {@link UonSerializer}, all default settings. */
@@ -173,10 +171,36 @@ public class UonSerializer extends WriterSerializer {
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
 	 */
 	public UonSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+		this(propertyStore, "text/uon");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param produces
+	 * 	The media type that this serializer produces.
+	 * @param accept
+	 * 	The accept media types that the serializer can handle.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 * 	<p>
+	 * 	If empty, then assumes the only media type supported is <code>produces</code>.
+	 * 	<p>
+	 * 	For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+	 * 	<js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code>
+	 * 	<br>...or...
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);</code>
+	 */
+	public UonSerializer(PropertyStore propertyStore, String produces, String...accept) {
+		super(propertyStore, produces, accept);
 		this.ctx = createContext(UonSerializerContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
index 34039bc..b6e8952 100644
--- a/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/uon/UonSerializerSession.java
@@ -18,6 +18,7 @@ import static org.apache.juneau.uon.UonSerializerContext.*;
 import java.util.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.transform.*;
 
@@ -45,7 +46,6 @@ public class UonSerializerSession extends WriterSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	public UonSerializerSession(UonSerializerContext ctx, Boolean encode, SerializerSessionArgs args) {
 		super(ctx, args);
@@ -166,6 +166,9 @@ public class UonSerializerSession extends WriterSerializerSession {
 		else if (sType.isArray()) {
 			serializeCollection(out, toList(sType.getInnerClass(), o), eType);
 		}
+		else if (sType.isReader() || sType.isInputStream()) {
+			IOUtils.pipe(o, out);
+		}
 		else {
 			out.appendObject(o, false);
 		}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
index 399c882..3c2d729 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
@@ -19,7 +19,6 @@ import static org.apache.juneau.internal.StringUtils.*;
 import java.util.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.parser.*;
 import org.apache.juneau.uon.*;
 
@@ -49,7 +48,6 @@ import org.apache.juneau.uon.*;
  * </ul>
  */
 @SuppressWarnings({ "unchecked", "hiding" })
-@Consumes("application/x-www-form-urlencoded")
 public class UrlEncodingParser extends UonParser implements PartParser {
 
 	/** Reusable instance of {@link UrlEncodingParser}. */
@@ -64,7 +62,7 @@ public class UrlEncodingParser extends UonParser implements PartParser {
 	 * @param propertyStore The property store containing all the settings for this object.
 	 */
 	public UrlEncodingParser(PropertyStore propertyStore) {
-		super(propertyStore.copy().append(UON_decodeChars, true));
+		super(propertyStore.copy().append(UON_decodeChars, true), "application/x-www-form-urlencoded");
 		this.ctx = createContext(UrlEncodingParserContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
index 9f872c0..9170cc2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
@@ -21,7 +21,6 @@ import java.io.*;
 import java.net.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.uon.*;
 
@@ -126,7 +125,6 @@ import org.apache.juneau.uon.*;
  * 	String s = UrlEncodingSerializer.<jsf>DEFAULT</jsf>.serialize(s);
  * </p>
  */
-@Produces("application/x-www-form-urlencoded")
 @SuppressWarnings("hiding")
 public class UrlEncodingSerializer extends UonSerializer implements PartSerializer {
 
@@ -145,7 +143,6 @@ public class UrlEncodingSerializer extends UonSerializer implements PartSerializ
 	/**
 	 * Equivalent to <code><jk>new</jk> UrlEncodingSerializerBuilder().expandedParams(<jk>true</jk>).build();</code>.
 	 */
-	@Produces(value="application/x-www-form-urlencoded",contentType="application/x-www-form-urlencoded")
 	public static class Expanded extends UrlEncodingSerializer {
 
 		/**
@@ -193,13 +190,40 @@ public class UrlEncodingSerializer extends UonSerializer implements PartSerializ
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
 	 */
 	public UrlEncodingSerializer(PropertyStore propertyStore) {
-		super(propertyStore.copy().append(UON_encodeChars, true));
+		this(propertyStore, "application/x-www-form-urlencoded");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param produces
+	 * 	The media type that this serializer produces.
+	 * @param accept
+	 * 	The accept media types that the serializer can handle.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 * 	<p>
+	 * 	If empty, then assumes the only media type supported is <code>produces</code>.
+	 * 	<p>
+	 * 	For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+	 * 	<js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code>
+	 * 	<br>...or...
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);</code>
+	 */
+	public UrlEncodingSerializer(PropertyStore propertyStore, String produces, String...accept) {
+		super(propertyStore.copy().append(UON_encodeChars, true), produces, accept);
 		this.ctx = createContext(UrlEncodingSerializerContext.class);
 	}
 
+
 	@Override /* CoreObject */
 	public UrlEncodingSerializerBuilder builder() {
 		return new UrlEncodingSerializerBuilder(propertyStore);
@@ -242,7 +266,7 @@ public class UrlEncodingSerializer extends UonSerializer implements PartSerializ
 			}
 
 			StringWriter w = new StringWriter();
-			UonSerializerSession s = new UonSerializerSession(ctx, urlEncode, SerializerSessionArgs.DEFAULT);
+			UonSerializerSession s = new UonSerializerSession(ctx, urlEncode, createDefaultSessionArgs());
 			s.serialize(w, o);
 			return w.toString();
 		} catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
index 46e36d2..cce9b4d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java
@@ -18,6 +18,7 @@ import java.lang.reflect.*;
 import java.util.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.transform.*;
 import org.apache.juneau.uon.*;
@@ -46,7 +47,6 @@ public class UrlEncodingSerializerSession extends UonSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected UrlEncodingSerializerSession(UrlEncodingSerializerContext ctx, Boolean encode, SerializerSessionArgs args) {
 		super(ctx, encode, args);
@@ -128,6 +128,8 @@ public class UrlEncodingSerializerSession extends UonSerializerSession {
 		} else if (sType.isCollection() || sType.isArray()) {
 			Map m = sType.isCollection() ? getCollectionMap((Collection)o) : getCollectionMap(o);
 			serializeCollectionMap(out, m, getClassMeta(Map.class, Integer.class, Object.class));
+		} else if (sType.isReader() || sType.isInputStream()) {
+			IOUtils.pipe(o, out);
 		} else {
 			// All other types can't be serialized as key/value pairs, so we create a
 			// mock key/value pair with a "_value" key.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
index 6e70c35..f04c2d4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
@@ -15,7 +15,6 @@ package org.apache.juneau.xml;
 import static org.apache.juneau.xml.XmlSerializerContext.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 
 /**
@@ -37,7 +36,6 @@ import org.apache.juneau.serializer.*;
 public class XmlDocSerializer extends XmlSerializer {
 
 	/** Default serializer without namespaces. */
-	@Produces(value="text/xml",contentType="text/xml")
 	public static class Ns extends XmlDocSerializer {
 
 		/**

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
index b889889..a7a8748 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlDocSerializerSession.java
@@ -34,7 +34,6 @@ public class XmlDocSerializerSession extends XmlSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected XmlDocSerializerSession(XmlSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
index cd81507..fbc6ae2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.xml;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.parser.*;
 
 /**
@@ -35,7 +34,6 @@ import org.apache.juneau.parser.*;
  * 	<li>{@link BeanContext}
  * </ul>
  */
-@Consumes("text/xml,application/xml")
 public class XmlParser extends ReaderParser {
 
 	/** Default parser, all default settings.*/
@@ -47,10 +45,23 @@ public class XmlParser extends ReaderParser {
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
 	 */
 	public XmlParser(PropertyStore propertyStore) {
-		super(propertyStore);
+		this(propertyStore, "text/xml", "application/xml");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param consumes
+	 * 	The list of media types that this parser consumes (e.g. <js>"application/json"</js>, <js>"*&#8203;/json"</js>).
+	 */
+	public XmlParser(PropertyStore propertyStore, String...consumes) {
+		super(propertyStore, consumes);
 		this.ctx = createContext(XmlParserContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
index 23429a4..8d4a7aa 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaDocSerializerSession.java
@@ -34,7 +34,6 @@ public class XmlSchemaDocSerializerSession extends XmlSchemaSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected XmlSchemaDocSerializerSession(XmlSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
index 26ba629..aba1879 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
@@ -13,7 +13,6 @@
 package org.apache.juneau.xml;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.serializer.*;
 
 /**
@@ -38,7 +37,6 @@ import org.apache.juneau.serializer.*;
  * 	<li>{@link BeanContext}
  * </ul>
  */
-@Produces(value="text/xml+schema",contentType="text/xml")
 public class XmlSchemaSerializer extends XmlSerializer {
 
 	/**
@@ -47,7 +45,7 @@ public class XmlSchemaSerializer extends XmlSerializer {
 	 * @param propertyStore Initialize with the specified config property store.
 	 */
 	public XmlSchemaSerializer(PropertyStore propertyStore) {
-		super(propertyStore.copy().append(XmlSerializerContext.XML_enableNamespaces, true));
+		super(propertyStore.copy().append(XmlSerializerContext.XML_enableNamespaces, true), "text/xml", "text/xml+schema");
 	}
 
 	@Override /* Serializer */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
index f3b9120..6de01ec 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializerSession.java
@@ -49,7 +49,6 @@ public class XmlSchemaSerializerSession extends XmlSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected XmlSchemaSerializerSession(XmlSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
index e836a67..2a81c03 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
@@ -16,7 +16,6 @@ import static org.apache.juneau.serializer.SerializerContext.*;
 import static org.apache.juneau.xml.XmlSerializerContext.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
 import org.apache.juneau.json.*;
 import org.apache.juneau.serializer.*;
 
@@ -121,7 +120,6 @@ import org.apache.juneau.serializer.*;
  * 	<li>{@link SqReadable} - Default serializer, single quotes, whitespace added.
  * </ul>
  */
-@Produces("text/xml")
 public class XmlSerializer extends WriterSerializer {
 
 	/** Default serializer without namespaces. */
@@ -170,7 +168,6 @@ public class XmlSerializer extends WriterSerializer {
 	}
 
 	/** Default serializer without namespaces. */
-	@Produces(value="text/xml+simple",contentType="text/xml")
 	public static class Ns extends XmlSerializer {
 
 		/**
@@ -179,7 +176,7 @@ public class XmlSerializer extends WriterSerializer {
 		 * @param propertyStore The property store containing all the settings for this object.
 		 */
 		public Ns(PropertyStore propertyStore) {
-			super(propertyStore.copy().append(XML_enableNamespaces, true));
+			super(propertyStore.copy().append(XML_enableNamespaces, true), "text/xml", "text/xml+simple");
 		}
 	}
 
@@ -217,10 +214,36 @@ public class XmlSerializer extends WriterSerializer {
 	/**
 	 * Constructor.
 	 *
-	 * @param propertyStore The property store containing all the settings for this object.
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
 	 */
 	public XmlSerializer(PropertyStore propertyStore) {
-		super(propertyStore);
+		this(propertyStore, "text/xml");
+	}
+
+	/**
+	 * Constructor.
+	 *
+	 * @param propertyStore
+	 * 	The property store containing all the settings for this object.
+	 * @param produces
+	 * 	The media type that this serializer produces.
+	 * @param accept
+	 * 	The accept media types that the serializer can handle.
+	 * 	<p>
+	 * 	Can contain meta-characters per the <code>media-type</code> specification of
+	 * 	<a class="doclink" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">RFC2616/14.1</a>
+	 * 	<p>
+	 * 	If empty, then assumes the only media type supported is <code>produces</code>.
+	 * 	<p>
+	 * 	For example, if this serializer produces <js>"application/json"</js> but should handle media types of
+	 * 	<js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"application/json"</js>, <js>"text/json"</js>);</code>
+	 * 	<br>...or...
+	 * 	<br><code><jk>super</jk>(propertyStore, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);</code>
+	 */
+	public XmlSerializer(PropertyStore propertyStore, String produces, String...accept) {
+		super(propertyStore, produces, accept);
 		this.ctx = createContext(XmlSerializerContext.class);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/b37d99ba/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
index 1603f0d..d1c348d 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
@@ -25,6 +25,7 @@ import java.lang.reflect.*;
 import java.util.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.internal.*;
 import org.apache.juneau.serializer.*;
 import org.apache.juneau.transform.*;
 import org.apache.juneau.xml.annotation.*;
@@ -63,7 +64,6 @@ public class XmlSerializerSession extends WriterSerializerSession {
 	 * 	These specify session-level information such as locale and URI context.
 	 * 	It also include session-level properties that override the properties defined on the bean and
 	 * 	serializer contexts.
-	 * 	<br>If <jk>null</jk>, defaults to {@link SerializerSessionArgs#DEFAULT}.
 	 */
 	protected XmlSerializerSession(XmlSerializerContext ctx, SerializerSessionArgs args) {
 		super(ctx, args);
@@ -344,6 +344,7 @@ public class XmlSerializerSession extends WriterSerializerSession {
 			o = null;
 
 		boolean isCollapsed = false;		// If 'true', this is a collection and we're not rendering the outer element.
+		boolean isRaw = (sType.isReader() || sType.isInputStream()) && o != null;
 
 		// Get the JSON type string.
 		if (o == null) {
@@ -390,7 +391,7 @@ public class XmlSerializerSession extends WriterSerializerSession {
 		boolean cr = o != null && (sType.isMapOrBean() || sType.isCollectionOrArray()) && ! isMixed;
 
 		String en = elementName;
-		if (en == null) {
+		if (en == null && ! isRaw) {
 			en = type.toString();
 			type = null;
 		}
@@ -406,25 +407,29 @@ public class XmlSerializerSession extends WriterSerializerSession {
 
 		// Render the start tag.
 		if (! isCollapsed) {
-			out.oTag(i, elementNs, en, encodeEn);
-			if (addNamespaceUris) {
-				out.attr((String)null, "xmlns", defaultNamespace.getUri());
+			if (en != null) {
+				out.oTag(i, elementNs, en, encodeEn);
+				if (addNamespaceUris) {
+					out.attr((String)null, "xmlns", defaultNamespace.getUri());
 
-				for (Namespace n : namespaces)
-					out.attr("xmlns", n.getName(), n.getUri());
-			}
-			if (! isExpectedType) {
-				if (resolvedDictionaryName != null)
-					out.attr(dns, getBeanTypePropertyName(eType), resolvedDictionaryName);
-				else if (type != null && type != STRING)
-					out.attr(dns, getBeanTypePropertyName(eType), type);
+					for (Namespace n : namespaces)
+						out.attr("xmlns", n.getName(), n.getUri());
+				}
+				if (! isExpectedType) {
+					if (resolvedDictionaryName != null)
+						out.attr(dns, getBeanTypePropertyName(eType), resolvedDictionaryName);
+					else if (type != null && type != STRING)
+						out.attr(dns, getBeanTypePropertyName(eType), type);
+				}
+			} else {
+				out.i(i);
 			}
 			if (o == null) {
 				if ((sType.isBoolean() || sType.isNumber()) && ! sType.isNullable())
 					o = sType.getPrimitiveDefault();
 			}
 
-			if (o != null && ! (sType.isMapOrBean()))
+			if (o != null && ! (sType.isMapOrBean() || en == null))
 				out.append('>');
 
 			if (cr && ! (sType.isMapOrBean()))
@@ -463,6 +468,8 @@ public class XmlSerializerSession extends WriterSerializerSession {
 				serializeCollection(out, o, sType, eType, pMeta, isMixed);
 				if (isCollapsed)
 					this.indent++;
+			} else if (sType.isReader() || sType.isInputStream()) {
+				IOUtils.pipe(o, out);
 			} else {
 				if (format == XMLTEXT)
 					out.append(toString(o));
@@ -475,16 +482,18 @@ public class XmlSerializerSession extends WriterSerializerSession {
 
 		// Render the end tag.
 		if (! isCollapsed) {
-			if (rc == CR_EMPTY) {
-				if (isHtmlMode())
-					out.append('>').eTag(elementNs, en, encodeEn);
-				else
+			if (en != null) {
+				if (rc == CR_EMPTY) {
+					if (isHtmlMode())
+						out.append('>').eTag(elementNs, en, encodeEn);
+					else
+						out.append('/').append('>');
+				} else if (rc == CR_VOID || o == null) {
 					out.append('/').append('>');
-			} else if (rc == CR_VOID || o == null) {
-				out.append('/').append('>');
+				}
+				else
+					out.ie(cr && rc != CR_MIXED ? i : 0).eTag(elementNs, en, encodeEn);
 			}
-			else
-				out.ie(cr && rc != CR_MIXED ? i : 0).eTag(elementNs, en, encodeEn);
 			if (! isMixed)
 				out.nl(i);
 		}