WebHandlerDecorator.java 1.5 KB
Newer Older
1
/*
2
 * Copyright 2002-2016 the original author or authors.
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
16

17
package org.springframework.web.server.handler;
18

19
import reactor.core.publisher.Mono;
20

21
import org.springframework.util.Assert;
22
import org.springframework.web.server.ServerWebExchange;
23
import org.springframework.web.server.WebHandler;
24

25
/**
26
 * {@link WebHandler} that decorates and delegates to another.
27 28
 *
 * @author Rossen Stoyanchev
29
 * @since 5.0
30
 */
R
Rossen Stoyanchev 已提交
31
public class WebHandlerDecorator implements WebHandler {
32

R
Rossen Stoyanchev 已提交
33
	private final WebHandler delegate;
34 35


R
Rossen Stoyanchev 已提交
36
	public WebHandlerDecorator(WebHandler delegate) {
37 38 39 40 41
		Assert.notNull(delegate, "'delegate' must not be null");
		this.delegate = delegate;
	}


R
Rossen Stoyanchev 已提交
42
	public WebHandler getDelegate() {
43 44 45
		return this.delegate;
	}

46 47

	@Override
48
	public Mono<Void> handle(ServerWebExchange exchange) {
R
Rossen Stoyanchev 已提交
49
		return this.delegate.handle(exchange);
50
	}
51 52 53 54 55 56

	@Override
	public String toString() {
		return getClass().getSimpleName() + " [delegate=" + this.delegate + "]";
	}

57
}