org.springframework.web.reactive.result.condition.RequestCondition Java Examples

The following examples show how to use org.springframework.web.reactive.result.condition.RequestCondition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RequestMappingHandlerMapping.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Create a {@link RequestMappingInfo} from the supplied
 * {@link RequestMapping @RequestMapping} annotation, which is either
 * a directly declared annotation, a meta-annotation, or the synthesized
 * result of merging annotation attributes within an annotation hierarchy.
 */
protected RequestMappingInfo createRequestMappingInfo(
		RequestMapping requestMapping, @Nullable RequestCondition<?> customCondition) {

	RequestMappingInfo.Builder builder = RequestMappingInfo
			.paths(resolveEmbeddedValuesInPatterns(requestMapping.path()))
			.methods(requestMapping.method())
			.params(requestMapping.params())
			.headers(requestMapping.headers())
			.consumes(requestMapping.consumes())
			.produces(requestMapping.produces())
			.mappingName(requestMapping.name());
	if (customCondition != null) {
		builder.customCondition(customCondition);
	}
	return builder.options(this.config).build();
}
 
Example #2
Source File: RequestMappingHandlerMapping.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Create a {@link RequestMappingInfo} from the supplied
 * {@link RequestMapping @RequestMapping} annotation, which is either
 * a directly declared annotation, a meta-annotation, or the synthesized
 * result of merging annotation attributes within an annotation hierarchy.
 */
protected RequestMappingInfo createRequestMappingInfo(
		RequestMapping requestMapping, @Nullable RequestCondition<?> customCondition) {

	RequestMappingInfo.Builder builder = RequestMappingInfo
			.paths(resolveEmbeddedValuesInPatterns(requestMapping.path()))
			.methods(requestMapping.method())
			.params(requestMapping.params())
			.headers(requestMapping.headers())
			.consumes(requestMapping.consumes())
			.produces(requestMapping.produces())
			.mappingName(requestMapping.name());
	if (customCondition != null) {
		builder.customCondition(customCondition);
	}
	return builder.options(this.config).build();
}
 
Example #3
Source File: RequestMappingInfo.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns,
		@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
		@Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
		@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {

	this.name = (StringUtils.hasText(name) ? name : null);
	this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
	this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition());
	this.paramsCondition = (params != null ? params : new ParamsRequestCondition());
	this.headersCondition = (headers != null ? headers : new HeadersRequestCondition());
	this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition());
	this.producesCondition = (produces != null ? produces : new ProducesRequestCondition());
	this.customConditionHolder = new RequestConditionHolder(custom);
}
 
Example #4
Source File: RequestMappingInfo.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Creates a new instance with the given request conditions.
 */
public RequestMappingInfo(@Nullable PatternsRequestCondition patterns,
		@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
		@Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
		@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {

	this(null, patterns, methods, params, headers, consumes, produces, custom);
}
 
Example #5
Source File: RequestMappingInfo.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Creates a new instance with the given request conditions.
 */
public RequestMappingInfo(@Nullable PatternsRequestCondition patterns,
		@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
		@Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
		@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {

	this(null, patterns, methods, params, headers, consumes, produces, custom);
}
 
Example #6
Source File: RequestMappingInfo.java    From java-technology-stack with MIT License 5 votes vote down vote up
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns,
		@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
		@Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
		@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {

	this.name = (StringUtils.hasText(name) ? name : null);
	this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
	this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition());
	this.paramsCondition = (params != null ? params : new ParamsRequestCondition());
	this.headersCondition = (headers != null ? headers : new HeadersRequestCondition());
	this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition());
	this.producesCondition = (produces != null ? produces : new ProducesRequestCondition());
	this.customConditionHolder = new RequestConditionHolder(custom);
}
 
Example #7
Source File: RequestMappingHandlerMapping.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)},
 * supplying the appropriate custom {@link RequestCondition} depending on whether
 * the supplied {@code annotatedElement} is a class or method.
 * @see #getCustomTypeCondition(Class)
 * @see #getCustomMethodCondition(Method)
 */
@Nullable
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) {
	RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class);
	RequestCondition<?> condition = (element instanceof Class ?
			getCustomTypeCondition((Class<?>) element) : getCustomMethodCondition((Method) element));
	return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null);
}
 
Example #8
Source File: RequestMappingHandlerMapping.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)},
 * supplying the appropriate custom {@link RequestCondition} depending on whether
 * the supplied {@code annotatedElement} is a class or method.
 * @see #getCustomTypeCondition(Class)
 * @see #getCustomMethodCondition(Method)
 */
@Nullable
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) {
	RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class);
	RequestCondition<?> condition = (element instanceof Class ?
			getCustomTypeCondition((Class<?>) element) : getCustomMethodCondition((Method) element));
	return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null);
}
 
Example #9
Source File: ApiVersionRequestMappingHandlerMapping.java    From yue-library with Apache License 2.0 4 votes vote down vote up
@Override
protected RequestCondition<?> getCustomMethodCondition(Method method) {
   	// 扫描方法上的 {@link ApiVersion}
	ApiVersion apiVersion = AnnotationUtils.findAnnotation(method, ApiVersion.class);
	return createRequestCondition(apiVersion, method.getDeclaringClass());
}
 
Example #10
Source File: RequestMappingInfo.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public DefaultBuilder customCondition(RequestCondition<?> condition) {
	this.customCondition = condition;
	return this;
}
 
Example #11
Source File: RequestMappingInfo.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Returns the "custom" condition of this {@link RequestMappingInfo}; or {@code null}.
 */
@Nullable
public RequestCondition<?> getCustomCondition() {
	return this.customConditionHolder.getCondition();
}
 
Example #12
Source File: RequestMappingInfo.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Re-create a RequestMappingInfo with the given custom request condition.
 */
public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition<?> customRequestCondition) {
	this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition,
			info.consumesCondition, info.producesCondition, customRequestCondition);
}
 
Example #13
Source File: ApiVersionRequestMappingHandlerMapping.java    From yue-library with Apache License 2.0 4 votes vote down vote up
@Override
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) {
   	// 扫描类或接口上的 {@link ApiVersion}
	ApiVersion apiVersion = AnnotationUtils.findAnnotation(handlerType, ApiVersion.class);
	return createRequestCondition(apiVersion, handlerType);
}
 
Example #14
Source File: RequestMappingInfo.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public DefaultBuilder customCondition(RequestCondition<?> condition) {
	this.customCondition = condition;
	return this;
}
 
Example #15
Source File: RequestMappingInfo.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Returns the "custom" condition of this {@link RequestMappingInfo}; or {@code null}.
 */
@Nullable
public RequestCondition<?> getCustomCondition() {
	return this.customConditionHolder.getCondition();
}
 
Example #16
Source File: RequestMappingInfo.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Re-create a RequestMappingInfo with the given custom request condition.
 */
public RequestMappingInfo(RequestMappingInfo info, @Nullable RequestCondition<?> customRequestCondition) {
	this(info.name, info.patternsCondition, info.methodsCondition, info.paramsCondition, info.headersCondition,
			info.consumesCondition, info.producesCondition, customRequestCondition);
}
 
Example #17
Source File: RequestMappingHandlerMapping.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Provide a custom type-level request condition.
 * The custom {@link RequestCondition} can be of any type so long as the
 * same condition type is returned from all calls to this method in order
 * to ensure custom request conditions can be combined and compared.
 * <p>Consider extending
 * {@link org.springframework.web.reactive.result.condition.AbstractRequestCondition
 * AbstractRequestCondition} for custom condition types and using
 * {@link org.springframework.web.reactive.result.condition.CompositeRequestCondition
 * CompositeRequestCondition} to provide multiple custom conditions.
 * @param handlerType the handler type for which to create the condition
 * @return the condition, or {@code null}
 */
@SuppressWarnings("UnusedParameters")
@Nullable
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) {
	return null;
}
 
Example #18
Source File: RequestMappingHandlerMapping.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Provide a custom method-level request condition.
 * The custom {@link RequestCondition} can be of any type so long as the
 * same condition type is returned from all calls to this method in order
 * to ensure custom request conditions can be combined and compared.
 * <p>Consider extending
 * {@link org.springframework.web.reactive.result.condition.AbstractRequestCondition
 * AbstractRequestCondition} for custom condition types and using
 * {@link org.springframework.web.reactive.result.condition.CompositeRequestCondition
 * CompositeRequestCondition} to provide multiple custom conditions.
 * @param method the handler method for which to create the condition
 * @return the condition, or {@code null}
 */
@SuppressWarnings("UnusedParameters")
@Nullable
protected RequestCondition<?> getCustomMethodCondition(Method method) {
	return null;
}
 
Example #19
Source File: RequestMappingInfo.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Set a custom condition to use.
 */
Builder customCondition(RequestCondition<?> condition);
 
Example #20
Source File: RequestMappingHandlerMapping.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Provide a custom method-level request condition.
 * The custom {@link RequestCondition} can be of any type so long as the
 * same condition type is returned from all calls to this method in order
 * to ensure custom request conditions can be combined and compared.
 * <p>Consider extending
 * {@link org.springframework.web.reactive.result.condition.AbstractRequestCondition
 * AbstractRequestCondition} for custom condition types and using
 * {@link org.springframework.web.reactive.result.condition.CompositeRequestCondition
 * CompositeRequestCondition} to provide multiple custom conditions.
 * @param method the handler method for which to create the condition
 * @return the condition, or {@code null}
 */
@SuppressWarnings("UnusedParameters")
@Nullable
protected RequestCondition<?> getCustomMethodCondition(Method method) {
	return null;
}
 
Example #21
Source File: RequestMappingInfo.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Set a custom condition to use.
 */
Builder customCondition(RequestCondition<?> condition);
 
Example #22
Source File: RequestMappingHandlerMapping.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Provide a custom type-level request condition.
 * The custom {@link RequestCondition} can be of any type so long as the
 * same condition type is returned from all calls to this method in order
 * to ensure custom request conditions can be combined and compared.
 * <p>Consider extending
 * {@link org.springframework.web.reactive.result.condition.AbstractRequestCondition
 * AbstractRequestCondition} for custom condition types and using
 * {@link org.springframework.web.reactive.result.condition.CompositeRequestCondition
 * CompositeRequestCondition} to provide multiple custom conditions.
 * @param handlerType the handler type for which to create the condition
 * @return the condition, or {@code null}
 */
@SuppressWarnings("UnusedParameters")
@Nullable
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) {
	return null;
}