org.springframework.web.bind.support.WebBindingInitializer Java Examples

The following examples show how to use org.springframework.web.bind.support.WebBindingInitializer. 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: WebFluxConfigurationSupportTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void requestMappingHandlerAdapter() throws Exception {
	ApplicationContext context = loadConfig(WebFluxConfig.class);

	String name = "requestMappingHandlerAdapter";
	RequestMappingHandlerAdapter adapter = context.getBean(name, RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);

	List<HttpMessageReader<?>> readers = adapter.getMessageReaders();
	assertEquals(13, readers.size());

	ResolvableType multiValueMapType = forClassWithGenerics(MultiValueMap.class, String.class, String.class);

	assertHasMessageReader(readers, forClass(byte[].class), APPLICATION_OCTET_STREAM);
	assertHasMessageReader(readers, forClass(ByteBuffer.class), APPLICATION_OCTET_STREAM);
	assertHasMessageReader(readers, forClass(String.class), TEXT_PLAIN);
	assertHasMessageReader(readers, forClass(Resource.class), IMAGE_PNG);
	assertHasMessageReader(readers, forClass(Message.class), new MediaType("application", "x-protobuf"));
	assertHasMessageReader(readers, multiValueMapType, APPLICATION_FORM_URLENCODED);
	assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_XML);
	assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_JSON);
	assertHasMessageReader(readers, forClass(TestBean.class), new MediaType("application", "x-jackson-smile"));
	assertHasMessageReader(readers, forClass(TestBean.class), null);

	WebBindingInitializer bindingInitializer = adapter.getWebBindingInitializer();
	assertNotNull(bindingInitializer);
	WebExchangeDataBinder binder = new WebExchangeDataBinder(new Object());
	bindingInitializer.initBinder(binder);

	name = "webFluxConversionService";
	ConversionService service = context.getBean(name, ConversionService.class);
	assertSame(service, binder.getConversionService());

	name = "webFluxValidator";
	Validator validator = context.getBean(name, Validator.class);
	assertSame(validator, binder.getValidator());
}
 
Example #2
Source File: HandlerMethodInvoker.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer,
		SessionAttributeStore sessionAttributeStore, ParameterNameDiscoverer parameterNameDiscoverer,
		WebArgumentResolver[] customArgumentResolvers, HttpMessageConverter<?>[] messageConverters) {

	this.methodResolver = methodResolver;
	this.bindingInitializer = bindingInitializer;
	this.sessionAttributeStore = sessionAttributeStore;
	this.parameterNameDiscoverer = parameterNameDiscoverer;
	this.customArgumentResolvers = customArgumentResolvers;
	this.messageConverters = messageConverters;
}
 
Example #3
Source File: InitBinderDataBinderFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Create a new InitBinderDataBinderFactory instance.
 * @param binderMethods {@code @InitBinder} methods
 * @param initializer for global data binder initialization
 */
public InitBinderDataBinderFactory(@Nullable List<InvocableHandlerMethod> binderMethods,
		@Nullable WebBindingInitializer initializer) {

	super(initializer);
	this.binderMethods = (binderMethods != null ? binderMethods : Collections.emptyList());
}
 
Example #4
Source File: ModelInitializerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private InitBinderBindingContext getBindingContext(Object controller) {

		List<SyncInvocableHandlerMethod> binderMethods =
				MethodIntrospector.selectMethods(controller.getClass(), BINDER_METHODS)
						.stream()
						.map(method -> new SyncInvocableHandlerMethod(controller, method))
						.collect(Collectors.toList());

		WebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
		return new InitBinderBindingContext(bindingInitializer, binderMethods);
	}
 
Example #5
Source File: InitBinderBindingContext.java    From java-technology-stack with MIT License 5 votes vote down vote up
InitBinderBindingContext(@Nullable WebBindingInitializer initializer,
		List<SyncInvocableHandlerMethod> binderMethods) {

	super(initializer);
	this.binderMethods = binderMethods;
	this.binderMethodContext = new BindingContext(initializer);
}
 
Example #6
Source File: HandlerMethodInvoker.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer,
		SessionAttributeStore sessionAttributeStore, ParameterNameDiscoverer parameterNameDiscoverer,
		WebArgumentResolver[] customArgumentResolvers, HttpMessageConverter<?>[] messageConverters) {

	this.methodResolver = methodResolver;
	this.bindingInitializer = bindingInitializer;
	this.sessionAttributeStore = sessionAttributeStore;
	this.parameterNameDiscoverer = parameterNameDiscoverer;
	this.customArgumentResolvers = customArgumentResolvers;
	this.messageConverters = messageConverters;
}
 
Example #7
Source File: InitBinderDataBinderFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Create a new InitBinderDataBinderFactory instance.
 * @param binderMethods {@code @InitBinder} methods
 * @param initializer for global data binder initialization
 */
public InitBinderDataBinderFactory(@Nullable List<InvocableHandlerMethod> binderMethods,
		@Nullable WebBindingInitializer initializer) {

	super(initializer);
	this.binderMethods = (binderMethods != null ? binderMethods : Collections.emptyList());
}
 
Example #8
Source File: InitBinderBindingContext.java    From spring-analysis-note with MIT License 5 votes vote down vote up
InitBinderBindingContext(@Nullable WebBindingInitializer initializer,
		List<SyncInvocableHandlerMethod> binderMethods) {

	super(initializer);
	this.binderMethods = binderMethods;
	this.binderMethodContext = new BindingContext(initializer);
}
 
Example #9
Source File: ModelInitializerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private InitBinderBindingContext getBindingContext(Object controller) {
	List<SyncInvocableHandlerMethod> binderMethods =
			MethodIntrospector.selectMethods(controller.getClass(), BINDER_METHODS)
					.stream()
					.map(method -> new SyncInvocableHandlerMethod(controller, method))
					.collect(Collectors.toList());

	WebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
	return new InitBinderBindingContext(bindingInitializer, binderMethods);
}
 
Example #10
Source File: WebFluxConfigurationSupportTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void requestMappingHandlerAdapter() throws Exception {
	ApplicationContext context = loadConfig(WebFluxConfig.class);

	String name = "requestMappingHandlerAdapter";
	RequestMappingHandlerAdapter adapter = context.getBean(name, RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);

	List<HttpMessageReader<?>> readers = adapter.getMessageReaders();
	assertEquals(13, readers.size());

	ResolvableType multiValueMapType = forClassWithGenerics(MultiValueMap.class, String.class, String.class);

	assertHasMessageReader(readers, forClass(byte[].class), APPLICATION_OCTET_STREAM);
	assertHasMessageReader(readers, forClass(ByteBuffer.class), APPLICATION_OCTET_STREAM);
	assertHasMessageReader(readers, forClass(String.class), TEXT_PLAIN);
	assertHasMessageReader(readers, forClass(Resource.class), IMAGE_PNG);
	assertHasMessageReader(readers, forClass(Message.class), new MediaType("application", "x-protobuf"));
	assertHasMessageReader(readers, multiValueMapType, APPLICATION_FORM_URLENCODED);
	assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_XML);
	assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_JSON);
	assertHasMessageReader(readers, forClass(TestBean.class), new MediaType("application", "x-jackson-smile"));
	assertHasMessageReader(readers, forClass(TestBean.class), null);

	WebBindingInitializer bindingInitializer = adapter.getWebBindingInitializer();
	assertNotNull(bindingInitializer);
	WebExchangeDataBinder binder = new WebExchangeDataBinder(new Object());
	bindingInitializer.initBinder(binder);

	name = "webFluxConversionService";
	ConversionService service = context.getBean(name, ConversionService.class);
	assertSame(service, binder.getConversionService());

	name = "webFluxValidator";
	Validator validator = context.getBean(name, Validator.class);
	assertSame(validator, binder.getValidator());
}
 
Example #11
Source File: RequestMappingHandlerAdapter.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Return the configured WebBindingInitializer, or {@code null} if none.
 */
@Nullable
public WebBindingInitializer getWebBindingInitializer() {
	return this.webBindingInitializer;
}
 
Example #12
Source File: HandlerMethodInvoker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer) {
	this(methodResolver, bindingInitializer, new DefaultSessionAttributeStore(), null, null, null);
}
 
Example #13
Source File: RequestMappingHandlerAdapter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Return the configured WebBindingInitializer, or {@code null} if none.
 */
public WebBindingInitializer getWebBindingInitializer() {
	return this.webBindingInitializer;
}
 
Example #14
Source File: RequestMappingHandlerAdapter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Return the configured WebBindingInitializer, or {@code null} if none.
 */
public WebBindingInitializer getWebBindingInitializer() {
	return this.webBindingInitializer;
}
 
Example #15
Source File: ServletRequestDataBinderFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Create a new instance.
 * @param binderMethods one or more {@code @InitBinder} methods
 * @param initializer provides global data binder initialization
 */
public ServletRequestDataBinderFactory(@Nullable List<InvocableHandlerMethod> binderMethods,
		@Nullable WebBindingInitializer initializer) {

	super(binderMethods, initializer);
}
 
Example #16
Source File: RequestMappingHandlerAdapter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Return the configured WebBindingInitializer, or {@code null} if none.
 */
@Nullable
public WebBindingInitializer getWebBindingInitializer() {
	return this.webBindingInitializer;
}
 
Example #17
Source File: RequestMappingHandlerAdapter.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Return the configured WebBindingInitializer, or {@code null} if none.
 */
@Nullable
public WebBindingInitializer getWebBindingInitializer() {
	return this.webBindingInitializer;
}
 
Example #18
Source File: HandlerMethodInvoker.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public HandlerMethodInvoker(HandlerMethodResolver methodResolver, WebBindingInitializer bindingInitializer) {
	this(methodResolver, bindingInitializer, new DefaultSessionAttributeStore(), null, null, null);
}
 
Example #19
Source File: ServletRequestDataBinderFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Create a new instance.
 * @param binderMethods one or more {@code @InitBinder} methods
 * @param initializer provides global data binder initialization
 */
public ServletRequestDataBinderFactory(@Nullable List<InvocableHandlerMethod> binderMethods,
		@Nullable WebBindingInitializer initializer) {

	super(binderMethods, initializer);
}
 
Example #20
Source File: RequestMappingHandlerAdapter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Return the configured WebBindingInitializer, or {@code null} if none.
 */
@Nullable
public WebBindingInitializer getWebBindingInitializer() {
	return this.webBindingInitializer;
}
 
Example #21
Source File: Jackson2ServletRequestDataBinderFactory.java    From gvnix with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create a new instance.
 * 
 * @param binderMethods one or more {@code @InitBinder} methods
 * @param initializer provides global data binder initialization
 */
public Jackson2ServletRequestDataBinderFactory(
        List<InvocableHandlerMethod> binderMethods,
        WebBindingInitializer initializer) {
    super(binderMethods, initializer);
}
 
Example #22
Source File: InitBinderDataBinderFactory.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new instance.
 * @param binderMethods {@code @InitBinder} methods, or {@code null}
 * @param initializer for global data binder intialization
 */
public InitBinderDataBinderFactory(List<InvocableHandlerMethod> binderMethods, WebBindingInitializer initializer) {
	super(initializer);
	this.binderMethods = (binderMethods != null) ? binderMethods : new ArrayList<InvocableHandlerMethod>();
}
 
Example #23
Source File: UifServletRequestDataBinderFactory.java    From rice with Educational Community License v2.0 2 votes vote down vote up
/**
 * Create a new instance.
 *
 * @param binderMethods one or more {@code @InitBinder} methods
 * @param initializer provides global data binder initialization
 */
public UifServletRequestDataBinderFactory(List<InvocableHandlerMethod> binderMethods,
        WebBindingInitializer initializer) {
    super(binderMethods, initializer);
}
 
Example #24
Source File: BindingContext.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a new {@code BindingContext} with the given initializer.
 * @param initializer the binding initializer to apply (may be {@code null})
 */
public BindingContext(@Nullable WebBindingInitializer initializer) {
	this.initializer = initializer;
}
 
Example #25
Source File: RequestMappingHandlerAdapter.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Provide a WebBindingInitializer with "global" initialization to apply
 * to every DataBinder instance.
 */
public void setWebBindingInitializer(WebBindingInitializer webBindingInitializer) {
	this.webBindingInitializer = webBindingInitializer;
}
 
Example #26
Source File: ServletRequestDataBinderFactory.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new instance.
 * @param binderMethods one or more {@code @InitBinder} methods
 * @param initializer provides global data binder initialization
 */
public ServletRequestDataBinderFactory(List<InvocableHandlerMethod> binderMethods, WebBindingInitializer initializer) {
	super(binderMethods, initializer);
}
 
Example #27
Source File: MultiActionController.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Return the WebBindingInitializer (if any) which will apply pre-configured
 * configuration to every DataBinder that this controller uses.
 */
public final WebBindingInitializer getWebBindingInitializer() {
	return this.webBindingInitializer;
}
 
Example #28
Source File: MultiActionController.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Specify a WebBindingInitializer which will apply pre-configured
 * configuration to every DataBinder that this controller uses.
 * <p>Allows for factoring out the entire binder configuration
 * to separate objects, as an alternative to {@link #initBinder}.
 */
public final void setWebBindingInitializer(WebBindingInitializer webBindingInitializer) {
	this.webBindingInitializer = webBindingInitializer;
}
 
Example #29
Source File: AnnotationMethodHandlerAdapter.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Specify a WebBindingInitializer which will apply pre-configured
 * configuration to every DataBinder that this controller uses.
 */
public void setWebBindingInitializer(WebBindingInitializer webBindingInitializer) {
	this.webBindingInitializer = webBindingInitializer;
}
 
Example #30
Source File: AnnotationMethodHandlerAdapter.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Specify a WebBindingInitializer which will apply pre-configured
 * configuration to every DataBinder that this controller uses.
 */
public void setWebBindingInitializer(WebBindingInitializer webBindingInitializer) {
	this.webBindingInitializer = webBindingInitializer;
}