/** * Obtain the ApplicationContext for actual use. * @return the ApplicationContext (never {@code null}) * @throws IllegalStateException in case of no ApplicationContext set */ protected final ApplicationContext obtainApplicationContext() { ApplicationContext applicationContext = getApplicationContext(); Assert.state(applicationContext != null, "No ApplicationContext"); return applicationContext; }
/** * Return the {@link RequestDataValueProcessor} to use. * <p>The default implementation looks in the {@link #getApplicationContext() * Spring configuration} for a {@code RequestDataValueProcessor} bean with * the name {@link #REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME}. * @return the RequestDataValueProcessor, or null if there is none at the * application context. */ @Nullable protected RequestDataValueProcessor getRequestDataValueProcessor() { ApplicationContext context = getApplicationContext(); if (context != null && context.containsBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME)) { return context.getBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME, RequestDataValueProcessor.class); } return null; }
/** * Return the {@link RequestDataValueProcessor} to use. * <p>The default implementation looks in the {@link #getApplicationContext() * Spring configuration} for a {@code RequestDataValueProcessor} bean with * the name {@link #REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME}. */ protected RequestDataValueProcessor getRequestDataValueProcessor() { if (getApplicationContext() != null) { String beanName = REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME; return getApplicationContext().getBean(beanName, RequestDataValueProcessor.class); } return null; }
/** * Create a RequestContext to expose under the specified attribute name. * <p>The default implementation creates a standard RequestContext instance for the * given request and model. Can be overridden in subclasses for custom instances. * @param exchange current exchange * @param model combined output Map (never {@code null}), * with dynamic values taking precedence over static attributes * @return the RequestContext instance * @see #setRequestContextAttribute */ protected RequestContext createRequestContext(ServerWebExchange exchange, Map<String, Object> model) { return new RequestContext(exchange, model, getApplicationContext(), getRequestDataValueProcessor()); }