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:33:55 GMT
Repository: juneau
Updated Branches:
  refs/heads/master 3fc40afc2 -> 40923605e


RestContext refactoring.

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

Branch: refs/heads/master
Commit: 40923605e1b53dd5c1f41758ee393e8ab8d2f3cd
Parents: 3fc40af
Author: JamesBognar <jamesbognar@apache.org>
Authored: Thu Jan 4 21:33:52 2018 -0500
Committer: JamesBognar <jamesbognar@apache.org>
Committed: Thu Jan 4 21:33:52 2018 -0500

----------------------------------------------------------------------
 .../org/apache/juneau/rest/RestContext.java     | 116 ++++++------
 .../apache/juneau/rest/RestContextBuilder.java  | 175 ++++++++++++-------
 .../juneau/rest/annotation/RestResource.java    |  42 ++++-
 3 files changed, 215 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juneau/blob/40923605/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 7507a0c..24bafb6 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
@@ -1146,57 +1146,67 @@ public final class RestContext extends BeanContext {
 //	 */
 //	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>  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>
+	 * 
+	 * <p>
+	 * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters,
and URI parts.
+	 *
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </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>
+	 * 
+	 * <p>
+	 * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters,
and URI parts.
+	 * 
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </ul>
+	 */
+	public static final String REST_partParser = PREFIX + "partParser.o";
 
 	/**
 	 * <b>Configuration property:</b>  Compression encoders. 
@@ -1399,8 +1409,8 @@ public final class RestContext extends BeanContext {
 			properties = builder.properties;
 			serializers = builder.serializers.apply(ps).add(properties).build();
 			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());
+			partSerializer = getInstanceProperty(REST_partSerializer, HttpPartSerializer.class, SimpleUonPartSerializer.class,
true, resource, ps);
+			partParser = getInstanceProperty(REST_partSerializer, HttpPartParser.class, UonPartParser.class,
true, resource, ps);
 			encoders = new EncoderGroupBuilder().append(getInstanceArrayProperty(REST_encoders, Encoder.class,
new Encoder[0], true, resource, ps)).build();
 			beanContext = BeanContext.create().apply(ps).add(properties).build();
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/40923605/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 03e9713..8b03a16 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
@@ -102,9 +102,6 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 
 	SerializerGroupBuilder serializers = SerializerGroup.create();
 	ParserGroupBuilder parsers = ParserGroup.create();
-	Object 
-		partSerializer = SimpleUonPartSerializer.class, 
-		partParser = UonPartParser.class;
 
 	List<Object> childResources = new ArrayList<>();
 	String path;
@@ -517,62 +514,6 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	}
 
 	/**
-	 * Specifies the class-level {@link HttpPartSerializer} to use for serializing headers,
query/form parameters, and URI parts.
-	 *
-	 * <p>
-	 * This is the programmatic equivalent to the {@link RestResource#partSerializer() @RestResource.partSerializer()}
annotation.
-	 *
-	 * @param partSerializer The serializer class.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder partSerializer(Class<? extends HttpPartSerializer> partSerializer)
{
-		this.partSerializer = partSerializer;
-		return this;
-	}
-
-	/**
-	 * Specifies the class-level {@link HttpPartSerializer} to use for serializing headers,
query/form parameters, and URI parts.
-	 *
-	 * <p>
-	 * This is the programmatic equivalent to the {@link RestResource#partSerializer() @RestResource.partSerializer()}
annotation.
-	 *
-	 * @param partSerializer The serializer instance.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder partSerializer(HttpPartSerializer partSerializer) {
-		this.partSerializer = partSerializer;
-		return this;
-	}
-
-	/**
-	 * Specifies the class-level {@link HttpPartParser} to use for parsing headers, query/form
parameters, and URI parts.
-	 *
-	 * <p>
-	 * This is the programmatic equivalent to the {@link RestResource#partParser() @RestResource.partParser()}
annotation.
-	 *
-	 * @param partParser The parser class.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder partParser(Class<? extends HttpPartParser> partParser) {
-		this.partParser = partParser;
-		return this;
-	}
-
-	/**
-	 * Specifies the class-level {@link HttpPartParser} to use for parsing headers, query/form
parameters, and URI parts.
-	 *
-	 * <p>
-	 * This is the programmatic equivalent to the {@link RestResource#partParser() @RestResource.partParser()}
annotation.
-	 *
-	 * @param partParser The parser instance.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder partParser(HttpPartParser partParser) {
-		this.partParser = partParser;
-		return this;
-	}
-
-	/**
 	 * Adds a child resource to this resource.
 	 *
 	 * <p>
@@ -2370,6 +2311,122 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	}
 
 	/**
+	 * <b>Configuration property:</b>  HTTP part serializer. 
+	 *
+	 * <p>
+	 * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters,
and URI parts.
+	 *
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </ul>
+	 *
+	 * @param partSerializer The serializer class.
+	 * @return This object (for method chaining).
+	 */
+	public RestContextBuilder partSerializer(Class<? extends HttpPartSerializer> partSerializer)
{
+		return set(REST_partSerializer, partSerializer);
+	}
+
+	/**
+	 * <b>Configuration property:</b>  HTTP part serializer. 
+	 *
+	 * <p>
+	 * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters,
and URI parts.
+	 *
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </ul>
+	 *
+	 * @param partSerializer The serializer instance.
+	 * @return This object (for method chaining).
+	 */
+	public RestContextBuilder partSerializer(HttpPartSerializer partSerializer) {
+		return set(REST_partSerializer, partSerializer);
+	}
+
+	/**
+	 * <b>Configuration property:</b>  HTTP part parser. 
+	 *
+	 * <p>
+	 * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters,
and URI parts.
+	 * 
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </ul>
+	 *
+	 * @param partParser The parser class.
+	 * @return This object (for method chaining).
+	 */
+	public RestContextBuilder partParser(Class<? extends HttpPartParser> partParser) {
+		return set(REST_partParser, partParser);
+	}
+
+	/**
+	 * <b>Configuration property:</b>  HTTP part parser. 
+	 *
+	 * <p>
+	 * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters,
and URI parts.
+	 * 
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </ul>
+	 *
+	 * @param partParser The parser instance.
+	 * @return This object (for method chaining).
+	 */
+	public RestContextBuilder partParser(HttpPartParser partParser) {
+		return set(REST_partParser, partParser);
+	}
+
+	/**
 	 * <b>Configuration property:</b>  Compression encoders. 
 	 *
 	 * <p>

http://git-wip-us.apache.org/repos/asf/juneau/blob/40923605/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 656c8bf..6355dec 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
@@ -301,20 +301,50 @@ public @interface RestResource {
 	Class<? extends Parser>[] parsers() default {};
 
 	/**
-	 * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters,
and URI parts.
+	 * HTTP part serializer. 
 	 *
 	 * <p>
-	 * The programmatic equivalent to this annotation are the {@link RestContextBuilder#partSerializer(Class)}/
-	 * {@link RestContextBuilder#partSerializer(HttpPartSerializer)} methods.
+	 * Specifies the {@link HttpPartSerializer} to use for serializing headers, query/form parameters,
and URI parts.
+	 *
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </ul>
 	 */
 	Class<? extends HttpPartSerializer> partSerializer() default SimpleUonPartSerializer.class;
 	
 	/**
-	 * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters,
and URI parts.
+	 * HTTP part parser. 
 	 *
 	 * <p>
-	 * The programmatic equivalent to this annotation are the {@link RestContextBuilder#partParser(Class)}/
-	 * {@link RestContextBuilder#partParser(HttpPartParser)} methods.
+	 * Specifies the {@link HttpPartParser} to use for parsing headers, query/form parameters,
and URI parts.
+	 * 
+	 * <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>
+	 * 	<li>When defined as a class, properties/transforms defined on the resource/method
are inherited.
+	 * 	<li>When defined as an instance, properties/transforms defined on the resource/method
are NOT inherited.
+	 * </ul>
 	 */
 	Class<? extends HttpPartParser> partParser() default UonPartParser.class;
 


Mime
View raw message