since 3.0
This commit is contained in:
parent
079b856a6c
commit
42cdeb4302
|
|
@ -23,7 +23,7 @@ import org.springframework.ui.format.Formatter;
|
||||||
/**
|
/**
|
||||||
* Binds user-entered values to properties of a model object.
|
* Binds user-entered values to properties of a model object.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
*
|
* @since 3.0
|
||||||
* @param <M> The kind of model object this binder binds to
|
* @param <M> The kind of model object this binder binds to
|
||||||
* @see #add(BindingConfiguration)
|
* @see #add(BindingConfiguration)
|
||||||
* @see #bind(UserValues)
|
* @see #bind(UserValues)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.springframework.ui.binding;
|
||||||
/**
|
/**
|
||||||
* A binding between a user interface element and a model property.
|
* A binding between a user interface element and a model property.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface Binding {
|
public interface Binding {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import org.springframework.ui.format.Formatter;
|
||||||
/**
|
/**
|
||||||
* Configuration used to create a new {@link Binding} registered with a {@link GenericBinder}.
|
* Configuration used to create a new {@link Binding} registered with a {@link GenericBinder}.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see GenericBinder#add(BindingConfiguration)
|
* @see GenericBinder#add(BindingConfiguration)
|
||||||
*/
|
*/
|
||||||
public class BindingConfiguration {
|
public class BindingConfiguration {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.springframework.ui.binding;
|
||||||
/**
|
/**
|
||||||
* The result of a bind operation.
|
* The result of a bind operation.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see Binder#bind(UserValues)
|
* @see Binder#bind(UserValues)
|
||||||
* @see Binding#setValue(Object)
|
* @see Binding#setValue(Object)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* The results of a bind operation.
|
* The results of a bind operation.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see Binder#bind(UserValues)
|
* @see Binder#bind(UserValues)
|
||||||
*/
|
*/
|
||||||
public interface BindingResults extends Iterable<BindingResult> {
|
public interface BindingResults extends Iterable<BindingResult> {
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ import org.springframework.ui.format.Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A centralized registry of Formatters indexed by property types.
|
* A centralized registry of Formatters indexed by property types.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface FormatterRegistry {
|
public interface FormatterRegistry {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ package org.springframework.ui.binding;
|
||||||
/**
|
/**
|
||||||
* Holds a user-entered value to bind to a model property.
|
* Holds a user-entered value to bind to a model property.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @see Binder#bind(List).
|
* @since 3.0
|
||||||
|
* @see Binder#bind(List)
|
||||||
*/
|
*/
|
||||||
public class UserValue {
|
public class UserValue {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2004-2009 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.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
package org.springframework.ui.binding;
|
package org.springframework.ui.binding;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -6,9 +21,9 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simpler holder for a list of UserValues.
|
* A holder for a list of UserValues.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see Binder#bind(UserValues)
|
* @see Binder#bind(UserValues)
|
||||||
*/
|
*/
|
||||||
public class UserValues implements Iterable<UserValue> {
|
public class UserValues implements Iterable<UserValue> {
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,9 @@ import org.springframework.ui.format.AnnotationFormatterFactory;
|
||||||
import org.springframework.ui.format.Formatter;
|
import org.springframework.ui.format.Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic {@link Binder binder} suitable for use in most binding environments.
|
* A generic {@link Binder binder} suitable for use in most environments.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see #add(BindingConfiguration)
|
* @see #add(BindingConfiguration)
|
||||||
* @see #bind(UserValues)
|
* @see #bind(UserValues)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import org.springframework.ui.format.Formatter;
|
||||||
/**
|
/**
|
||||||
* A generic implementation of {@link FormatterRegistry} suitable for use in most binding environments.
|
* A generic implementation of {@link FormatterRegistry} suitable for use in most binding environments.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see #add(Formatter, Class)
|
* @see #add(Formatter, Class)
|
||||||
* @see #add(AnnotationFormatterFactory)
|
* @see #add(AnnotationFormatterFactory)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import org.springframework.ui.binding.UserValues;
|
||||||
* A binder designed for use in HTTP (web) environments.
|
* A binder designed for use in HTTP (web) environments.
|
||||||
* Suited for binding user-provided HTTP query parameters to model properties.
|
* Suited for binding user-provided HTTP query parameters to model properties.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see #setDefaultPrefix(String)
|
* @see #setDefaultPrefix(String)
|
||||||
* @see #setPresentPrefix(String)
|
* @see #setPresentPrefix(String)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import java.lang.annotation.Annotation;
|
||||||
* A factory that creates {@link Formatter formatters} to format property values on properties annotated with a particular format {@link Annotation}.
|
* A factory that creates {@link Formatter formatters} to format property values on properties annotated with a particular format {@link Annotation}.
|
||||||
* For example, a <code>CurrencyAnnotationFormatterFactory</code> might create a <code>Formatter</code> that formats a <code>BigDecimal</code> value set on a property annotated with <code>@CurrencyFormat</code>.
|
* For example, a <code>CurrencyAnnotationFormatterFactory</code> might create a <code>Formatter</code> that formats a <code>BigDecimal</code> value set on a property annotated with <code>@CurrencyFormat</code>.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @param <A> The type of Annotation this factory uses to create Formatter instances
|
* @param <A> The type of Annotation this factory uses to create Formatter instances
|
||||||
* @param <T> The type of Object Formatters created by this factory format
|
* @param <T> The type of Object Formatters created by this factory format
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import java.util.Locale;
|
||||||
/**
|
/**
|
||||||
* Formats objects of type T for display.
|
* Formats objects of type T for display.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @param <T> the type of object this formatter can format
|
* @param <T> the type of object this formatter can format
|
||||||
*/
|
*/
|
||||||
public interface Formatter<T> {
|
public interface Formatter<T> {
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,9 @@ import org.springframework.ui.format.Formatter;
|
||||||
/**
|
/**
|
||||||
* A formatter for {@link Date} types.
|
* A formatter for {@link Date} types.
|
||||||
* Allows the configuration of an explicit date pattern and locale.
|
* Allows the configuration of an explicit date pattern and locale.
|
||||||
* @see SimpleDateFormat
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
|
* @see SimpleDateFormat
|
||||||
*/
|
*/
|
||||||
public class DateFormatter implements Formatter<Date> {
|
public class DateFormatter implements Formatter<Date> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import org.springframework.ui.format.Formatter;
|
||||||
* Sets the scale of parsed BigDecimal values to {@link NumberFormat#getMaximumFractionDigits()}.
|
* Sets the scale of parsed BigDecimal values to {@link NumberFormat#getMaximumFractionDigits()}.
|
||||||
* Applies {@link RoundingMode#DOWN} to parsed values.
|
* Applies {@link RoundingMode#DOWN} to parsed values.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class CurrencyFormatter implements Formatter<BigDecimal> {
|
public class CurrencyFormatter implements Formatter<BigDecimal> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import java.util.Locale;
|
||||||
/**
|
/**
|
||||||
* Produces NumberFormat instances that format currency values.
|
* Produces NumberFormat instances that format currency values.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see NumberFormat
|
* @see NumberFormat
|
||||||
*/
|
*/
|
||||||
final class CurrencyNumberFormatFactory extends NumberFormatFactory {
|
final class CurrencyNumberFormatFactory extends NumberFormatFactory {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.springframework.ui.format.Formatter;
|
||||||
* Configures BigDecimal parsing so there is no loss in precision.
|
* Configures BigDecimal parsing so there is no loss in precision.
|
||||||
* Allows configuration over the decimal number pattern; see {@link #DecimalFormatter(String)}.
|
* Allows configuration over the decimal number pattern; see {@link #DecimalFormatter(String)}.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class DecimalFormatter implements Formatter<BigDecimal> {
|
public class DecimalFormatter implements Formatter<BigDecimal> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @see NumberFormat
|
* @see NumberFormat
|
||||||
* @see DecimalFormat
|
* @see DecimalFormat
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
class DefaultNumberFormatFactory extends NumberFormatFactory {
|
class DefaultNumberFormatFactory extends NumberFormatFactory {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import org.springframework.ui.format.Formatter;
|
||||||
* A Long formatter for whole integer values.
|
* A Long formatter for whole integer values.
|
||||||
* Delegates to {@link NumberFormat#getIntegerInstance(Locale)}.
|
* Delegates to {@link NumberFormat#getIntegerInstance(Locale)}.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class IntegerFormatter implements Formatter<Long> {
|
public class IntegerFormatter implements Formatter<Long> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import java.util.Locale;
|
||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @see NumberFormat
|
* @see NumberFormat
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class IntegerNumberFormatFactory extends NumberFormatFactory {
|
final class IntegerNumberFormatFactory extends NumberFormatFactory {
|
||||||
public NumberFormat getNumberFormat(Locale locale) {
|
public NumberFormat getNumberFormat(Locale locale) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import java.util.Locale;
|
||||||
* caching number format instances.
|
* caching number format instances.
|
||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
abstract class NumberFormatFactory {
|
abstract class NumberFormatFactory {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import org.springframework.ui.format.Formatter;
|
||||||
* Delegates to {@link NumberFormat#getPercentInstance(Locale)}.
|
* Delegates to {@link NumberFormat#getPercentInstance(Locale)}.
|
||||||
* Configures BigDecimal parsing so there is no loss in precision.
|
* Configures BigDecimal parsing so there is no loss in precision.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class PercentFormatter implements Formatter<BigDecimal> {
|
public class PercentFormatter implements Formatter<BigDecimal> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import java.util.Locale;
|
||||||
*
|
*
|
||||||
* @see NumberFormat
|
* @see NumberFormat
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class PercentNumberFormatFactory extends NumberFormatFactory {
|
final class PercentNumberFormatFactory extends NumberFormatFactory {
|
||||||
public NumberFormat getNumberFormat(Locale locale) {
|
public NumberFormat getNumberFormat(Locale locale) {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import org.springframework.expression.PropertyAccessor;
|
||||||
import org.springframework.expression.TypedValue;
|
import org.springframework.expression.TypedValue;
|
||||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
|
|
||||||
class DefaultMessageResolver implements MessageResolver, MessageSourceResolvable {
|
final class DefaultMessageResolver implements MessageResolver, MessageSourceResolvable {
|
||||||
|
|
||||||
private Severity severity;
|
private Severity severity;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ package org.springframework.ui.message;
|
||||||
* For example, a error message may inform a user of a web application a business rule was violated.
|
* For example, a error message may inform a user of a web application a business rule was violated.
|
||||||
* TODO - should we introduce summary/detail fields instead of just text
|
* TODO - should we introduce summary/detail fields instead of just text
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface Message {
|
public interface Message {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
* mathForm.decimalField=Decimal Field
|
* mathForm.decimalField=Decimal Field
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see MessageContext#add(MessageResolver, String)
|
* @see MessageContext#add(MessageResolver, String)
|
||||||
*/
|
*/
|
||||||
public class MessageBuilder {
|
public class MessageBuilder {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A context for recording and retrieving messages for display in a user interface.
|
* A context for recording and retrieving messages for display in a user interface.
|
||||||
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface MessageContext {
|
public interface MessageContext {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.springframework.ui.message;
|
||||||
/**
|
/**
|
||||||
* Runtime exception thrown by a {@link MessageResolver} if a message resolution fails.
|
* Runtime exception thrown by a {@link MessageResolver} if a message resolution fails.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class MessageResolutionException extends RuntimeException {
|
public class MessageResolutionException extends RuntimeException {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import org.springframework.context.MessageSource;
|
||||||
/**
|
/**
|
||||||
* A factory for a localized Message.
|
* A factory for a localized Message.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see Message
|
* @see Message
|
||||||
* @see MessageSource
|
* @see MessageSource
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ package org.springframework.ui.message;
|
||||||
* Enum exposing supported message severities.
|
* Enum exposing supported message severities.
|
||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @author Jeremy Grelle
|
* @since 3.0
|
||||||
* @see Message
|
* @see Message
|
||||||
*/
|
*/
|
||||||
public enum Severity {
|
public enum Severity {
|
||||||
|
|
|
||||||
|
|
@ -15,56 +15,46 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.ui.message.support;
|
package org.springframework.ui.message.support;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.context.support.AbstractMessageSource;
|
|
||||||
import org.springframework.core.style.ToStringCreator;
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.ui.message.Message;
|
import org.springframework.ui.message.Message;
|
||||||
import org.springframework.ui.message.MessageContext;
|
import org.springframework.ui.message.MessageContext;
|
||||||
import org.springframework.ui.message.MessageResolver;
|
import org.springframework.ui.message.MessageResolver;
|
||||||
import org.springframework.ui.message.Severity;
|
import org.springframework.ui.message.Severity;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CachingMapDecorator;
|
import org.springframework.util.CachingMapDecorator;
|
||||||
|
|
||||||
import edu.emory.mathcs.backport.java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default message context implementation.
|
* The default message context implementation.
|
||||||
* Uses a {@link MessageSource} to resolve messages that are added by callers.
|
* Uses a {@link MessageSource} to resolve messages that are added by callers.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class DefaultMessageContext implements MessageContext {
|
public class DefaultMessageContext implements MessageContext {
|
||||||
|
|
||||||
private MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private Map<String, ArrayList<Message>> messagesByElement = new CachingMapDecorator<String, ArrayList<Message>>(new LinkedHashMap<String, ArrayList<Message>>()) {
|
private Map<String, List<Message>> messagesByElement = new CachingMapDecorator<String, List<Message>>(new LinkedHashMap<String, List<Message>>()) {
|
||||||
protected ArrayList<Message> create(String element) {
|
protected List<Message> create(String element) {
|
||||||
return new ArrayList<Message>();
|
return new ArrayList<Message>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new default message context.
|
|
||||||
* Defaults to a message source that simply resolves default text and cannot resolve localized message codes.
|
|
||||||
*/
|
|
||||||
public DefaultMessageContext() {
|
|
||||||
init(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new default message context.
|
* Creates a new default message context.
|
||||||
* @param messageSource the message source to resolve messages added to this context
|
* @param messageSource the message source to resolve messages added to this context
|
||||||
*/
|
*/
|
||||||
public DefaultMessageContext(MessageSource messageSource) {
|
public DefaultMessageContext(MessageSource messageSource) {
|
||||||
init(messageSource);
|
Assert.notNull(messageSource, "The MessageSource is required");
|
||||||
|
this.messageSource = messageSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,12 +67,10 @@ public class DefaultMessageContext implements MessageContext {
|
||||||
|
|
||||||
// implementing message context
|
// implementing message context
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Map<String, List<Message>> getMessages() {
|
public Map<String, List<Message>> getMessages() {
|
||||||
return Collections.unmodifiableMap(messagesByElement);
|
return Collections.unmodifiableMap(messagesByElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<Message> getMessages(String element) {
|
public List<Message> getMessages(String element) {
|
||||||
List<Message> messages = messagesByElement.get(element);
|
List<Message> messages = messagesByElement.get(element);
|
||||||
if (messages.isEmpty()) {
|
if (messages.isEmpty()) {
|
||||||
|
|
@ -102,23 +90,6 @@ public class DefaultMessageContext implements MessageContext {
|
||||||
|
|
||||||
// internal helpers
|
// internal helpers
|
||||||
|
|
||||||
private void init(MessageSource messageSource) {
|
|
||||||
setMessageSource(messageSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setMessageSource(MessageSource messageSource) {
|
|
||||||
if (messageSource == null) {
|
|
||||||
messageSource = new DefaultTextFallbackMessageSource();
|
|
||||||
}
|
|
||||||
this.messageSource = messageSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DefaultTextFallbackMessageSource extends AbstractMessageSource {
|
|
||||||
protected MessageFormat resolveCode(String code, Locale locale) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ResolvableMessage implements Message {
|
class ResolvableMessage implements Message {
|
||||||
|
|
||||||
private MessageResolver resolver;
|
private MessageResolver resolver;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package org.springframework.ui.validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Document ValidateResults.
|
* TODO Document ValidateResults.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Document Validator.
|
* TODO Document Validator.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
/**
|
/**
|
||||||
* Base class for {@link EmbeddedDatabaseConfigurer} implementations providing common shutdown behaviour.
|
* Base class for {@link EmbeddedDatabaseConfigurer} implementations providing common shutdown behaviour.
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {
|
abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import org.springframework.core.io.support.EncodedResource;
|
||||||
/**
|
/**
|
||||||
* Thrown by {@link ResourceDatabasePopulator} if one of its SQL scripts could
|
* Thrown by {@link ResourceDatabasePopulator} if one of its SQL scripts could
|
||||||
* not be read during population.
|
* not be read during population.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class CannotReadScriptException extends RuntimeException {
|
public class CannotReadScriptException extends RuntimeException {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package org.springframework.jdbc.datasource.embedded;
|
||||||
* DataSourceFactory helper that allows essential JDBC connection properties to be configured consistently,
|
* DataSourceFactory helper that allows essential JDBC connection properties to be configured consistently,
|
||||||
* independent of the actual DataSource implementation.
|
* independent of the actual DataSource implementation.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see DataSourceFactory
|
* @see DataSourceFactory
|
||||||
*/
|
*/
|
||||||
public interface ConnectionProperties {
|
public interface ConnectionProperties {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource;
|
||||||
* Encapsulates the creation of a particular DataSource implementation, such as a {@link SimpleDriverDataSource} or connection pool such as Apache DBCP or c3p0.
|
* Encapsulates the creation of a particular DataSource implementation, such as a {@link SimpleDriverDataSource} or connection pool such as Apache DBCP or c3p0.
|
||||||
* Call {@link #getConnectionProperties()} to configure normalized DataSource properties before calling {@link #getDataSource()} to actually get the configured DataSource instance.
|
* Call {@link #getConnectionProperties()} to configure normalized DataSource properties before calling {@link #getDataSource()} to actually get the configured DataSource instance.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface DataSourceFactory {
|
public interface DataSourceFactory {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import java.sql.SQLException;
|
||||||
/**
|
/**
|
||||||
* Strategy used to populate an embedded database during initialization.
|
* Strategy used to populate an embedded database during initialization.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
* @see ResourceDatabasePopulator
|
* @see ResourceDatabasePopulator
|
||||||
*/
|
*/
|
||||||
public interface DatabasePopulator {
|
public interface DatabasePopulator {
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EmbeddedDatabaseConfigurer} for the Apache Derby database.
|
* {@link EmbeddedDatabaseConfigurer} for the Apache Derby database.
|
||||||
*
|
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {
|
final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import javax.sql.DataSource;
|
||||||
* Is a {@link DataSource}.
|
* Is a {@link DataSource}.
|
||||||
* Adds a shutdown operation so the embedded database instance can be shutdown.
|
* Adds a shutdown operation so the embedded database instance can be shutdown.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface EmbeddedDatabase extends DataSource {
|
public interface EmbeddedDatabase extends DataSource {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||||
* db.shutdown();
|
* db.shutdown();
|
||||||
* </pre>
|
* </pre>
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class EmbeddedDatabaseBuilder {
|
public class EmbeddedDatabaseBuilder {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import javax.sql.DataSource;
|
||||||
* Encapsulates the configuration required to create, connect to, and shutdown a specific type of embedded database such as HSQL or H2.
|
* Encapsulates the configuration required to create, connect to, and shutdown a specific type of embedded database such as HSQL or H2.
|
||||||
* Create a implementation for each database type you wish to support; for example HSQL, H2, or some other type.
|
* Create a implementation for each database type you wish to support; for example HSQL, H2, or some other type.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public interface EmbeddedDatabaseConfigurer {
|
public interface EmbeddedDatabaseConfigurer {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import org.springframework.util.Assert;
|
||||||
* strategies.
|
* strategies.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class EmbeddedDatabaseConfigurerFactory {
|
final class EmbeddedDatabaseConfigurerFactory {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ import org.springframework.util.Assert;
|
||||||
* Call {@link #setDatabasePopulator(DatabasePopulator)} to change the algorithm used to populate the database.<br>
|
* Call {@link #setDatabasePopulator(DatabasePopulator)} to change the algorithm used to populate the database.<br>
|
||||||
* Call {@link #setDataSourceFactory(DataSourceFactory)} to change the type of DataSource used to connect to the database.<br>
|
* Call {@link #setDataSourceFactory(DataSourceFactory)} to change the type of DataSource used to connect to the database.<br>
|
||||||
* Call {@link #getDatabase()} to get the {@link EmbeddedDatabase} instance.<br>
|
* Call {@link #getDatabase()} to get the {@link EmbeddedDatabase} instance.<br>
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class EmbeddedDatabaseFactory {
|
public class EmbeddedDatabaseFactory {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ import org.springframework.beans.factory.InitializingBean;
|
||||||
* Returns the actual {@link DataSource} that provides connectivity to the embedded database to Spring.
|
* Returns the actual {@link DataSource} that provides connectivity to the embedded database to Spring.
|
||||||
* The target DataSource is returned instead of a {@link EmbeddedDatabase} proxy since the FactoryBean will manage the initialization and destruction lifecycle of the database instance.
|
* The target DataSource is returned instead of a {@link EmbeddedDatabase} proxy since the FactoryBean will manage the initialization and destruction lifecycle of the database instance.
|
||||||
* Implements DisposableBean to shutdown the embedded database when the managing Spring container is shutdown.
|
* Implements DisposableBean to shutdown the embedded database when the managing Spring container is shutdown.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class EmbeddedDatabaseFactoryBean extends EmbeddedDatabaseFactory implements FactoryBean<DataSource>, InitializingBean, DisposableBean {
|
public class EmbeddedDatabaseFactoryBean extends EmbeddedDatabaseFactory implements FactoryBean<DataSource>, InitializingBean, DisposableBean {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package org.springframework.jdbc.datasource.embedded;
|
||||||
* A supported embedded database type.
|
* A supported embedded database type.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public enum EmbeddedDatabaseType {
|
public enum EmbeddedDatabaseType {
|
||||||
HSQL, H2, DERBY;
|
HSQL, H2, DERBY;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import org.springframework.util.ClassUtils;
|
||||||
/**
|
/**
|
||||||
* Initializes an H2 embedded database instance.
|
* Initializes an H2 embedded database instance.
|
||||||
* Call {@link #getInstance()} to get the singleton instance of this class.
|
* Call {@link #getInstance()} to get the singleton instance of this class.
|
||||||
*
|
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {
|
final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ import org.springframework.util.ClassUtils;
|
||||||
/**
|
/**
|
||||||
* Initializes an HSQL embedded database instance.
|
* Initializes an HSQL embedded database instance.
|
||||||
* Call {@link #getInstance()} to get the singleton instance of this class.
|
* Call {@link #getInstance()} to get the singleton instance of this class.
|
||||||
*
|
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class HsqlEmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {
|
final class HsqlEmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import org.springframework.jdbc.CannotGetJdbcConnectionException;
|
||||||
* Note there is some duplication here with JdbcUtils in jdbc.support package.
|
* Note there is some duplication here with JdbcUtils in jdbc.support package.
|
||||||
* We may want to consider simply using that at some point.
|
* We may want to consider simply using that at some point.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class JdbcUtils {
|
final class JdbcUtils {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ import org.springframework.util.StringUtils;
|
||||||
* <p>
|
* <p>
|
||||||
* Call {@link #addScript(Resource)} to add a SQL script location.<br>
|
* Call {@link #addScript(Resource)} to add a SQL script location.<br>
|
||||||
* Call {@link #setSqlScriptEncoding(String)} to set the encoding for all added scripts.<br>
|
* Call {@link #setSqlScriptEncoding(String)} to set the encoding for all added scripts.<br>
|
||||||
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class ResourceDatabasePopulator implements DatabasePopulator {
|
public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource;
|
||||||
/**
|
/**
|
||||||
* Creates a {@link SimpleDriverDataSource}.
|
* Creates a {@link SimpleDriverDataSource}.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
final class SimpleDriverDataSourceFactory implements DataSourceFactory {
|
final class SimpleDriverDataSourceFactory implements DataSourceFactory {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue