Package org.jvnet.hk2.config
Class MessageInterpolatorImpl
java.lang.Object
org.jvnet.hk2.config.MessageInterpolatorImpl
- All Implemented Interfaces:
jakarta.validation.MessageInterpolator
public class MessageInterpolatorImpl
extends Object
implements jakarta.validation.MessageInterpolator
Custom MessageInterpolatorImpl for HK2
This message interpolator is different from the default one in the following
ways:
1. It uses a class specified in the "payload" argument to the annotation to
find the class loader to find the resource bundle for messages. This allows
classes that are in OSGi modules to specify a resource bundle for bean
validation messages.
2. The "LocalStrings" resource bundle within the same package as the payload
class is used to search for messages. If a message is not found, the message
is obtained from the default bean validation resource bundle.
This class borrows heavily from the RI implementation of the ResourcBundleMessageInterpolator
authored by Emmanuel Bernard, Hardy Ferentschik, and Gunnar Morling.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.validation.MessageInterpolator
jakarta.validation.MessageInterpolator.Context -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninterpolate(String message, jakarta.validation.MessageInterpolator.Context context) interpolate(String message, jakarta.validation.MessageInterpolator.Context context, Locale locale) Runs the message interpolation according to algorithm specified in JSR 303.
-
Field Details
-
DEFAULT_VALIDATION_MESSAGES
The name of the default message bundle.- See Also:
-
USER_VALIDATION_MESSAGES
The name of the user-provided message bundle as defined in the specification.- See Also:
-
-
Constructor Details
-
MessageInterpolatorImpl
public MessageInterpolatorImpl()
-
-
Method Details
-
interpolate
- Specified by:
interpolatein interfacejakarta.validation.MessageInterpolator
-
interpolate
public String interpolate(String message, jakarta.validation.MessageInterpolator.Context context, Locale locale) Runs the message interpolation according to algorithm specified in JSR 303.
Note:
Look-ups in user bundles is recursive whereas look-ups in default bundle are not!- Specified by:
interpolatein interfacejakarta.validation.MessageInterpolator- Parameters:
message- the message to interpolatelocale- theLocaleto use for the resource bundle.annotationParameters- the parameters of the annotation for which to interpolate this message- Returns:
- the interpolated message.
-