Re-add vararg options in WebHttpHandlerBuilder

WebHttpHandlerBuilder is low level not expected to appear frequently
but they might be repeated more in tests (e.g. of WebFilter's).

Issuse: SPR-15499
This commit is contained in:
Rossen Stoyanchev 2017-05-08 15:50:27 -04:00
parent 459457e1aa
commit add1305252
1 changed files with 23 additions and 0 deletions

View File

@ -16,6 +16,7 @@
package org.springframework.web.server.adapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@ -147,6 +148,17 @@ public class WebHttpHandlerBuilder {
}
/**
* Add the given filter(s).
* @param filters the filter(s) to add
*/
public WebHttpHandlerBuilder filter(WebFilter... filters) {
if (!ObjectUtils.isEmpty(filters)) {
this.filters.addAll(Arrays.asList(filters));
}
return this;
}
/**
* Add the given filters.
* @param filters the filters to add
@ -168,6 +180,17 @@ public class WebHttpHandlerBuilder {
return this;
}
/**
* Add the given exception handler(s).
* @param handlers the exception handler(s)
*/
public WebHttpHandlerBuilder exceptionHandler(WebExceptionHandler... handlers) {
if (!ObjectUtils.isEmpty(handlers)) {
this.exceptionHandlers.addAll(Arrays.asList(handlers));
}
return this;
}
/**
* Add the given exception handlers.
* @param handlers the exception handlers