juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject juneau git commit: Remove redundant setProperties() methods from RestContextBuilder.
Date Fri, 19 Jan 2018 17:46:27 GMT
Repository: juneau
Updated Branches:
  refs/heads/master 3fc92582a -> 3c498b4b9


Remove redundant setProperties() methods from RestContextBuilder.

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

Branch: refs/heads/master
Commit: 3c498b4b951fd9e6e8141b5107712a8c61bd1365
Parents: 3fc9258
Author: JamesBognar <jamesbognar@apache.org>
Authored: Fri Jan 19 12:46:23 2018 -0500
Committer: JamesBognar <jamesbognar@apache.org>
Committed: Fri Jan 19 12:46:23 2018 -0500

----------------------------------------------------------------------
 .../org/apache/juneau/rest/RestContext.java     | 31 +++++++-------
 .../apache/juneau/rest/RestContextBuilder.java  | 43 ++++----------------
 .../juneau/rest/RestContextProperties.java      |  4 +-
 .../juneau/rest/annotation/RestResource.java    |  4 +-
 .../java/org/apache/juneau/rest/package.html    |  2 -
 5 files changed, 25 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/juneau/blob/3c498b4b/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 fd7fc6c..7230156 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
@@ -2973,9 +2973,9 @@ public final class RestContext extends BeanContext {
 	 * Returns the resource bundle used by this resource.
 	 * 
 	 * <p>
-	 * The resource bundle is defined via one of the following:
+	 * The resource bundle is defined via the following:
 	 * <ul>
-	 * 	<li>{@link RestResource#messages() @RestResource.messages()} annotation.
+	 * 	<li class='jf'>{@link RestContext#REST_messages}
 	 * </ul>
 	 * 
 	 * @return The resource bundle for this resource.  Never <jk>null</jk>.
@@ -2988,10 +2988,9 @@ public final class RestContext extends BeanContext {
 	 * Returns the REST information provider used by this resource.
 	 * 
 	 * <p>
-	 * The information provider is defined via one of the following:
+	 * The information provider is defined via the following:
 	 * <ul>
-	 * 	<li>{@link RestResource#infoProvider() @RestResource.infoProvider()} annotation.
-	 * 	<li>{@link RestContextBuilder#infoProvider(Class)}/{@link RestContextBuilder#infoProvider(RestInfoProvider)}
methods.
+	 * 	<li class='jf'>{@link RestContext#REST_infoProvider}
 	 * </ul>
 	 * 
 	 * @return The information provider for this resource.  Never <jk>null</jk>.
@@ -3004,10 +3003,9 @@ public final class RestContext extends BeanContext {
 	 * Returns the REST call handler used by this resource.
 	 * 
 	 * <p>
-	 * The call handler is defined via one of the following:
+	 * The call handler is defined via the following:
 	 * <ul>
-	 * 	<li>{@link RestResource#callHandler() @RestResource.callHandler()} annotation.
-	 * 	<li>{@link RestContextBuilder#callHandler(Class)}/{@link RestContextBuilder#callHandler(RestCallHandler)}
methods.
+	 * 	<li class='jf'>{@link RestContext#REST_callHandler}
 	 * </ul>
 	 * 
 	 * @return The call handler for this resource.  Never <jk>null</jk>.
@@ -3085,10 +3083,11 @@ public final class RestContext extends BeanContext {
 	 * Returns the class-level properties associated with this servlet.
 	 * 
 	 * <p>
-	 * Properties at the class level are defined via one of the following:
+	 * Properties at the class level are defined via the following:
 	 * <ul>
-	 * 	<li>{@link RestResource#properties() @RestResource.properties()} annotation.
-	 * 	<li>{@link RestContextBuilder#setProperty(String, Object)}/{@link RestContextBuilder#setProperties(Map)}
methods.
+	 * 	<li class='ja'>{@link RestResource#properties()}
+	 * 	<li class='jm'>{@link RestContextBuilder#set(String, Object)}
+	 * 	<li class='jm'>{@link RestContextBuilder#set(Map)}
 	 * </ul>
 	 * 
 	 * <h5 class='section'>Notes:</h5>
@@ -3107,10 +3106,9 @@ public final class RestContext extends BeanContext {
 	 * Returns the serializers registered with this resource.
 	 * 
 	 * <p>
-	 * Serializers at the class level are defined via one of the following:
+	 * Serializers at the class level are defined via the following:
 	 * <ul>
-	 * 	<li>{@link RestResource#serializers() @RestResource.serializers()} annotation.
-	 * 	<li>{@link RestContextBuilder#serializers(Class...)}/{@link RestContextBuilder#serializers(Object...)}
methods.
+	 * 	<li class='jf'>{@link RestContext#REST_serializers}
 	 * </ul>
 	 * 
 	 * @return The serializers registered with this resource.
@@ -3123,10 +3121,9 @@ public final class RestContext extends BeanContext {
 	 * Returns the parsers registered with this resource.
 	 * 
 	 * <p>
-	 * Parsers at the class level are defined via one of the following:
+	 * Parsers at the class level are defined via the following:
 	 * <ul>
-	 * 	<li>{@link RestResource#parsers() @RestResource.parsers()} annotation.
-	 * 	<li>{@link RestContextBuilder#parsers(Class...)}/{@link RestContextBuilder#parsers(Object...)}
methods.
+	 * 	<li class='jf'>{@link RestContext#REST_parsers}
 	 * </ul>
 	 * 
 	 * @return The parsers registered with this resource.

http://git-wip-us.apache.org/repos/asf/juneau/blob/3c498b4b/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 866b195..85bbf26 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
@@ -130,6 +130,7 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 		this.resourceClass = resourceClass;
 		this.parentContext = parentContext;
 		
+		properties = new RestContextProperties();
 		logger(RestLoggerDefault.class);
 		staticFileResponseHeader("Cache-Control", "max-age=86400, public");
 		encoders(IdentityEncoder.INSTANCE);
@@ -138,7 +139,6 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 
 			ConfigFileBuilder cfb = new ConfigFileBuilder();
 
-			properties = new RestContextProperties();
 			htmlDocBuilder = new HtmlDocBuilder(properties);
 			configFile = cfb.build();
 			varResolverBuilder = new VarResolverBuilder()
@@ -174,7 +174,7 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 			for (Enumeration<String> ep = config.getInitParameterNames(); ep.hasMoreElements();)
{
 				String p = ep.nextElement();
 				String initParam = config.getInitParameter(p);
-				properties.put(vr.resolve(p), vr.resolve(initParam));
+				set(vr.resolve(p), vr.resolve(initParam));
 			}
 
 			// Load stuff from parent-to-child order.
@@ -183,9 +183,9 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 				Class<?> c = e.getKey();
 				RestResource r = e.getValue();
 				for (Property p : r.properties())
-					properties.append(vr.resolve(p.name()), vr.resolve(p.value()));
+					set(vr.resolve(p.name()), vr.resolve(p.value()));
 				for (String p : r.flags())
-					properties.append(p, true);
+					set(p, true);
 				serializers(r.serializers());
 				parsers(r.parsers());
 				encoders(r.encoders());
@@ -379,38 +379,6 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	}
 
 	/**
-	 * Sets a property on this resource.
-	 * 
-	 * <p>
-	 * This is the programmatic equivalent to the {@link RestResource#properties() @RestResource.properties()}
annotation.
-	 * 
-	 * @param key The property name.
-	 * @param value The property value.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder setProperty(String key, Object value) {
-		this.properties.put(key, value);
-		return this;
-	}
-
-	/**
-	 * Sets multiple properties on this resource.
-	 * 
-	 * <p>
-	 * This is the programmatic equivalent to the {@link RestResource#properties() @RestResource.properties()}
annotation.
-	 * 
-	 * <p>
-	 * Values in the map are added to the existing properties and are overwritten if duplicates
are found.
-	 * 
-	 * @param properties The new properties to add to this config.
-	 * @return This object (for method chaining).
-	 */
-	public RestContextBuilder setProperties(Map<String,Object> properties) {
-		this.properties.putAll(properties);
-		return this;
-	}
-
-	/**
 	 * Returns an instance of an HTMLDOC builder for setting HTMLDOC-related properties.
 	 * 
 	 * @return An instance of an HTMLDOC builder for setting HTMLDOC-related properties.
@@ -2292,6 +2260,7 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	@Override /* ContextBuilder */
 	public RestContextBuilder set(String name, Object value) {
 		super.set(name, value);
+		this.properties.put(name, value);
 		return this;
 	}
 
@@ -2304,6 +2273,8 @@ public class RestContextBuilder extends BeanContextBuilder implements
ServletCon
 	@Override /* ContextBuilder */
 	public RestContextBuilder set(Map<String,Object> properties) {
 		super.set(properties);
+		this.properties.clear();
+		this.properties.putAll(properties);
 		return this;
 	}
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/3c498b4b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextProperties.java
----------------------------------------------------------------------
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextProperties.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextProperties.java
index 5331198..e7a64e4 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextProperties.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextProperties.java
@@ -24,8 +24,8 @@ import org.apache.juneau.rest.annotation.*;
  * These are properties specified on a REST resource class through the following:
  * <ul>
  * 	<li class='ja'>{@link RestResource#properties()}
- * 	<li class='jm'>{@link RestContextBuilder#setProperty(String, Object)}
- * 	<li class='jm'>{@link RestContextBuilder#setProperties(Map)}
+ * 	<li class='jm'>{@link RestContextBuilder#set(String, Object)}
+ * 	<li class='jm'>{@link RestContextBuilder#set(Map)}
  * </ul>
  */
 @SuppressWarnings("serial")

http://git-wip-us.apache.org/repos/asf/juneau/blob/3c498b4b/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 30fadcd..4f74b47 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
@@ -692,8 +692,8 @@ public @interface RestResource {
 	 * {@link SwitchVar $SW}
 	 * 
 	 * <p>
-	 * The programmatic equivalent to this annotation are the {@link RestContextBuilder#setProperty(String,
Object)}/
-	 * {@link RestContextBuilder#setProperties(java.util.Map)} methods.
+	 * The programmatic equivalent to this annotation are the {@link RestContextBuilder#set(String,
Object)}/
+	 * {@link RestContextBuilder#set(java.util.Map)} methods.
 	 */
 	Property[] properties() default {};
 

http://git-wip-us.apache.org/repos/asf/juneau/blob/3c498b4b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
----------------------------------------------------------------------
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
index fea8377..deff1fd 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/package.html
@@ -1706,8 +1706,6 @@
 		</p>
 		<ul class='spaced-list'>
 			<li>
-				By overriding the {@link org.apache.juneau.rest.RestContextBuilder#setProperties(Map)}
method.
-			<li>
 				By overriding the {@link org.apache.juneau.rest.RestContextBuilder#serializers(Class[])}
and 
 				{@link org.apache.juneau.rest.RestContextBuilder#parsers(Class[])} methods and setting
properties on the 
 				serializers and parsers directly.


Mime
View raw message