1 24 package org.riotfamily.common.web.resource; 25 26 import java.io.FilterReader ; 27 import java.io.Reader ; 28 import java.util.Locale ; 29 30 import javax.servlet.http.HttpServletRequest ; 31 32 import org.riotfamily.common.io.MessageFilterReader; 33 import org.springframework.context.MessageSource; 34 import org.springframework.context.MessageSourceAware; 35 import org.springframework.web.servlet.support.RequestContextUtils; 36 37 public class MessageResourceFilter extends AbstractPathMatchingResourceFilter 38 implements MessageSourceAware { 39 40 private MessageSource messageSource; 41 42 private String prefix; 43 44 public void setMessageSource(MessageSource messageSource) { 45 this.messageSource = messageSource; 46 } 47 48 public void setPrefix(String prefix) { 49 this.prefix = prefix; 50 } 51 52 public FilterReader createFilterReader(Reader in, 53 HttpServletRequest request) { 54 55 Locale locale = RequestContextUtils.getLocale(request); 56 return new MessageFilterReader(in, messageSource, locale, prefix); 57 } 58 59 } 60 | Popular Tags |