Polishing

This commit is contained in:
Juergen Hoeller
2015-08-26 00:44:32 +02:00
parent 75187e3a8e
commit a35f71964a
8 changed files with 161 additions and 154 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,14 +30,17 @@ public class DefaultDataBinderFactory implements WebDataBinderFactory {
private final WebBindingInitializer initializer;
/**
* Create new instance.
* @param initializer for global data binder intialization, or {@code null}
* Create a new {@code DefaultDataBinderFactory} instance.
* @param initializer for global data binder initialization
* (or {@code null} if none)
*/
public DefaultDataBinderFactory(WebBindingInitializer initializer) {
this.initializer = initializer;
}
/**
* Create a new {@link WebDataBinder} for the given target object and
* initialize it through a {@link WebBindingInitializer}.
@@ -46,6 +49,7 @@ public class DefaultDataBinderFactory implements WebDataBinderFactory {
@Override
public final WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName)
throws Exception {
WebDataBinder dataBinder = createBinderInstance(target, objectName, webRequest);
if (this.initializer != null) {
this.initializer.initBinder(dataBinder, webRequest);
@@ -64,6 +68,7 @@ public class DefaultDataBinderFactory implements WebDataBinderFactory {
*/
protected WebDataBinder createBinderInstance(Object target, String objectName, NativeWebRequest webRequest)
throws Exception {
return new WebRequestDataBinder(target, objectName);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -125,7 +125,11 @@ public abstract class WebApplicationObjectSupport extends ApplicationObjectSuppo
if (this.servletContext != null) {
return this.servletContext;
}
ServletContext servletContext = getWebApplicationContext().getServletContext();
WebApplicationContext wac = getWebApplicationContext();
if (wac == null) {
return null;
}
ServletContext servletContext = wac.getServletContext();
if (servletContext == null && isContextRequired()) {
throw new IllegalStateException("WebApplicationObjectSupport instance [" + this +
"] does not run within a ServletContext. Make sure the object is fully configured!");