class SpringMessageResolver
        extends AbstractMessageResolver 
        implements MessageSourceAware {


    private static final Logger logger = LoggerFactory.getLogger(SpringMessageResolver.class);


    private final StandardMessageResolver standardMessageResolver;
    private MessageSource messageSource;


    public SpringMessageResolver() {
        super();
        this.standardMessageResolver = new StandardMessageResolver();
    }





    /*
     * Check the message source has been set.
     */
    private void checkMessageSourceInitialized() {
        if (this.messageSource == null) {
            throw new ConfigurationException(
                    "Cannot initialize " + SpringMessageResolver.class.getSimpleName() +
                    ": MessageSource has not been set. Either define this object as " +
                    "a Spring bean (which will automatically set the MessageSource) or, " +
                    "if you instance it directly, set the MessageSource manually using its "+
                    "corresponding setter method.");
        }
    }





    /**
     * <p>
     *   Returns the message source ({@link MessageSource}) to be
     *   used for message resolution.
     * </p>
     *
     * @return the message source
     */
    public final MessageSource getMessageSource() {
        return this.messageSource;
    }


    /**
     * <p>
     *   Sets the message source to be used for message resolution
     * </p>
     *
     * @param messageSource the message source
     */
    public final void setMessageSource(final MessageSource messageSource) {
        this.messageSource = messageSource;
    }





    public final String resolveMessage(
            final ITemplateContext context, final Class<?> origin, final String key, final Object[] messageParameters) {<FILL_FUNCTION_BODY>}




    public String createAbsentMessageRepresentation(
            final ITemplateContext context, final Class<?> origin, final String key, final Object[] messageParameters) {
        return this.standardMessageResolver.createAbsentMessageRepresentation(context, origin, key, messageParameters);
    }

}


        Validate.notNull(context.getLocale(), "Locale in context cannot be null");
        Validate.notNull(key, "Message key cannot be null");

        /*
         * FIRST STEP: Look for the message using template-based resolution
         */
        if (context != null) {

            checkMessageSourceInitialized();

            if (logger.isTraceEnabled()) {
                logger.trace(
                        "[THYMELEAF][{}] Resolving message with key \"{}\" for template \"{}\" and locale \"{}\". " +
                        "Messages will be retrieved from Spring's MessageSource infrastructure.",
                        new Object[]{TemplateEngine.threadIndex(), key, context.getTemplateData().getTemplate(), context.getLocale()});
            }

            try {
                return this.messageSource.getMessage(key, messageParameters, context.getLocale());
            } catch (NoSuchMessageException e) {
                // Try other methods
            }

        }

        /*
         * SECOND STEP: Look for the message using origin-based resolution, delegated to the StandardMessageResolver
         */
        if (origin != null) {
            // We will be disabling template-based resolution when delegating in order to use only origin-based
            final String message =
                    this.standardMessageResolver.resolveMessage(context, origin, key, messageParameters, false, true, true);
            if (message != null) {
                return message;
            }
        }


        /*
         * NOT FOUND, return null
         */
        return null;

    
<methods>public final java.lang.String getName() ,public final java.lang.Integer getOrder() ,public void setName(java.lang.String) ,public void setOrder(java.lang.Integer) <variables>private static final org.slf4j.Logger logger,private java.lang.String name,private java.lang.Integer order