@Bean(name = "messageSource")
 public ReloadableResourceBundleMessageSource getMessageSource() {
   ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
   resource.setBasename("classpath:messages");
   resource.setDefaultEncoding("UTF-8");
   return resource;
 }
Esempio n. 2
0
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("classpath:/messages");
   return messageSource;
 }
Esempio n. 3
0
 @BeforeClass
 public static void setUpClass() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("classpath:/jp/co/ctc_g/jse/core/message/MessageContextTest");
   MessageSourceLocator.set(messageSource);
 }
 @Bean
 public MessageSource httpErrorMessageSource() {
   ReloadableResourceBundleMessageSource m = new ReloadableResourceBundleMessageSource();
   m.setBasename("classpath:/messages");
   m.setDefaultEncoding("UTF-8");
   return m;
 }
Esempio n. 5
0
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource ret = new ReloadableResourceBundleMessageSource();
   ret.setBasenames(new String[] {"/resources/messages/messages"});
   ret.setDefaultEncoding("UTF-8");
   return ret;
 }
 /*
  * Configure MessageSource to provide internationalized messages
  */
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource bundle = new ReloadableResourceBundleMessageSource();
   bundle.setBasename("messages");
   bundle.setDefaultEncoding(TEMPLATE_RESOLVER_CHAR_ENCODING);
   bundle.setCacheSeconds(5);
   return bundle;
 }
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource bundle = new ReloadableResourceBundleMessageSource();
   bundle.setBasename("/WEB-INF/messages");
   //	bundle.setDefaultEncoding("UTF-8");
   bundle.setCacheSeconds(1);
   return bundle;
 }
Esempio n. 8
0
 @Bean(name = "messageSource")
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename(MESSAGE_SOURCE);
   messageSource.setCacheSeconds(5);
   return messageSource;
 }
Esempio n. 9
0
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("/WEB-INF/messages/messages");
   messageSource.setCacheSeconds(15);
   return messageSource;
 }
Esempio n. 10
0
 @Bean
 public ReloadableResourceBundleMessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageBundle =
       new ReloadableResourceBundleMessageSource();
   messageBundle.setBasename("classpath:messages/messages");
   messageBundle.setDefaultEncoding("UTF-8");
   return messageBundle;
 }
Esempio n. 11
0
 /** Message fájlok elérésének beállítása. */
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("/resource/message/messages");
   messageSource.setFallbackToSystemLocale(false);
   messageSource.setCacheSeconds(0);
   return messageSource;
 }
Esempio n. 12
0
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("classpath:/i18n/messages");
   messageSource.setDefaultEncoding("UTF-8");
   messageSource.setCacheSeconds(propertyResolver.getProperty("cache-seconds", Integer.class, -1));
   return messageSource;
 }
 @Bean
 public ReloadableResourceBundleMessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   String[] resources = {"classpath:/labels", "classpath:/message"};
   messageSource.setBasenames(resources);
   messageSource.setDefaultEncoding("UTF-8");
   return messageSource;
 }
Esempio n. 14
0
  @Bean(name = "messageSource")
  public MessageSource getMessageSources() {
    ReloadableResourceBundleMessageSource messageSource =
        new ReloadableResourceBundleMessageSource();
    messageSource.setBasenames("/WEB-INF/resources/properties/clientMessages");
    messageSource.setCacheSeconds(0);

    return messageSource;
  }
 @Bean(name = "messageSource")
 public MessageSource configureMessageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("classpath:messages");
   messageSource.setCacheSeconds(5);
   messageSource.setDefaultEncoding("UTF-8");
   return messageSource;
 }
 @Bean(name = "messageSource")
 public MessageSource getMessageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setCacheSeconds(1);
   messageSource.setBasenames("file:./resources/messages");
   messageSource.setDefaultEncoding("UTF-8");
   return messageSource;
 }
Esempio n. 17
0
 @Override
 public Validator getValidator() {
   LocalValidatorFactoryBean factory = new LocalValidatorFactoryBean();
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("classpath:messages");
   messageSource.setDefaultEncoding("UTF-8");
   factory.setValidationMessageSource(messageSource);
   return factory;
 }
Esempio n. 18
0
 protected static void initMessageSourceAccessor() {
   String[] basenames = new String[set.size()];
   set.toArray(basenames);
   ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource =
       new ReloadableResourceBundleMessageSource();
   reloadableResourceBundleMessageSource.setBasenames(basenames);
   reloadableResourceBundleMessageSource.setCacheSeconds(5);
   accessor = new MessageSourceAccessor(reloadableResourceBundleMessageSource);
   messageSource = reloadableResourceBundleMessageSource;
 }
Esempio n. 19
0
 @Bean(name = "messageSource")
 public MessageSource configureMessageSource() {
   logger.debug("setting up message source");
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename(MESSAGE_SOURCE);
   messageSource.setCacheSeconds(5);
   messageSource.setDefaultEncoding("UTF-8");
   return messageSource;
 }
 @Bean
 @Description("Spring mail message resolver")
 public MessageSource emailMessageSource() {
   log.info("loading non-reloadable mail messages resources");
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("classpath:/mails/messages/messages");
   messageSource.setDefaultEncoding(CharEncoding.UTF_8);
   return messageSource;
 }
Esempio n. 21
0
 @Bean(name = "messageSource")
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource messageSource =
       new ReloadableResourceBundleMessageSource();
   messageSource.setBasename("classpath:/messages/message");
   messageSource.setDefaultEncoding("UTF-8");
   if (environment.acceptsProfiles("dev")) {
     messageSource.setCacheSeconds(0);
   }
   return messageSource;
 }
Esempio n. 22
0
  /**
   * Validates update candidate biblios (biblios whose <code>update</code> database field is either
   * null or is not equal to 'Y')
   *
   * @return 0 if there are no validation errors; 1 otherwise.
   */
  public int validateUpdateCandidates() {
    String logMsg = messages.getMessage("Biblios.ValidateUpdateCandidates", BEGIN, Locale.UK);
    logger.info(logMsg);

    List<BibliosDAO> bibliosList = bibliosManager.getUpdateCandidateBiblios();
    Map<Integer, BibliosDAO> errorMap = validator.validate(bibliosList);

    logMsg = messages.getMessage("Biblios.ValidateUpdateCandidates", END, Locale.UK);
    logger.info(logMsg);

    return (errorMap.isEmpty() ? 0 : 1);
  }
Esempio n. 23
0
  /**
   * Parameterless method that validates and updates the database with the valid update candidates.
   *
   * @return 0 (typically passed on to the java exec command-line invoker)
   */
  private int update() {
    Object[] parms;
    String logMsg = messages.getMessage("Biblios.Update", BEGIN, Locale.UK);
    logger.info(logMsg);

    int updateCount = validateAndUpdateCandidates();
    parms = new Object[] {updateCount};
    logMsg = messages.getMessage("Biblios.UpdateCount", parms, Locale.UK);
    logger.info(logMsg);

    logMsg = messages.getMessage("Biblios.Update", END, Locale.UK);
    logger.info(logMsg);

    return 0;
  }
 @Bean
 public MessageSource messageSource() {
   ReloadableResourceBundleMessageSource ms = new ReloadableResourceBundleMessageSource();
   ms.setDefaultEncoding("UTF-8");
   ms.setCacheSeconds(600);
   ms.setFallbackToSystemLocale(false);
   ms.setBasenames(
       new String[] {
         "/WEB-INF/i18n/labels",
         "/WEB-INF/i18n/buttons",
         "/WEB-INF/i18n/messages",
         "/WEB-INF/i18n/titles"
       });
   return ms;
 }
Esempio n. 25
0
  /**
   * This method gets the list of update candidates, validates it, removes any failed candidates
   * from the update list, then updates the database with the [validated] update candidate list.
   *
   * @return The number of records updated
   */
  public int validateAndUpdateCandidates() {
    int updateCount = 0;
    List<BibliosDAO> bibliosList =
        bibliosManager.getUpdateCandidateBiblios(); // Get update candidates.
    Map<Integer, BibliosDAO> errorMap = validator.validate(bibliosList); // Validate the list.

    if (!bibliosList.isEmpty()) { // If there are update candidates ...
      if (!errorMap.isEmpty()) { //     If there were validation errors ...
        Iterator<BibliosDAO> iterator = bibliosList.iterator();
        while (iterator.hasNext()) { //     ... remove the failed candidates from the update list.
          BibliosDAO biblio = iterator.next();
          int pk = biblio.getId_biblio();
          if (errorMap.containsKey(pk)) {
            Object[] parms = new Object[] {biblio.getId_biblio()};
            String logMsg = messages.getMessage("Biblios.RemoveFailedCandidate", parms, Locale.UK);
            logger.warn(logMsg);
            iterator.remove();
          }
        }
      }

      bibliosList =
          updateBibliosFromWebService(
              bibliosList); // Update any biblios with valid pubmed_ids from web service.
      updateCount = save(bibliosList); // Save the changes.
    }

    return updateCount;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
  */
 @Override
 public void afterPropertiesSet() throws Exception {
   Set<String> l = new HashSet<String>();
   String i18nPattern = basePath + "/**/*.properties";
   String i18nFileREG = "(" + StringUtils.join(languages, '|') + ").properties$";
   if (defaultLocale != null) {
     Locale.setDefault(this.defaultLocale);
   }
   try {
     Resource[] resources = applicationContext.getResources(i18nPattern);
     for (Resource resource : resources) {
       String path = resource.getURI().toString();
       if (CapString.checkRegularMatch(path, i18nFileREG)) {
         path =
             path.replaceAll(i18nFileREG, "")
                 .replaceAll(".*/i18n/", "classpath:/i18n/")
                 // for windows
                 .replaceAll(".*\\\\i18n\\\\", "classpath:\\\\i18n\\\\")
                 .replaceAll("\\\\", "/");
         if (!l.contains(path)) {
           l.add(path);
           logger.debug("set message path:" + path);
         }
       }
     }
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   super.setBasenames(l.toArray(new String[l.size()]));
 }
 /**
  * Override to obtain a local reference to the basenames.
  *
  * @see
  *     org.springframework.context.support.ReloadableResourceBundleMessageSource#setBasenames(java.lang.String[])
  */
 @Override
 public void setBasenames(String[] basenames) {
   super.setBasenames(basenames);
   if (basenames == null) {
     this.basenames = new String[0];
   } else {
     this.basenames = Arrays.copyOf(basenames, basenames.length);
   }
 }
Esempio n. 28
0
  @Override
  public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
      throws BeansException {
    URL root = this.getClass().getResource(messageRootPath);
    if (root == null) return;

    File dir = new File(root.getFile());
    List<String> basenames = new ArrayList<String>();
    listFiles(dir, basenames);

    String[] names = new String[0];
    messageSource.setBasenames(basenames.toArray(names));
  }
Esempio n. 29
0
  @Bean(name = "messageSource")
  public MessageSource messageSource() {

    ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource =
        new ReloadableResourceBundleMessageSource();
    reloadableResourceBundleMessageSource.setBasenames(
        "classpath:META-INF/i18n/holiday", "classpath:ValidationMessages");
    reloadableResourceBundleMessageSource.setDefaultEncoding("UTF-8");
    reloadableResourceBundleMessageSource.setFallbackToSystemLocale(false);
    reloadableResourceBundleMessageSource.setUseCodeAsDefaultMessage(true);
    reloadableResourceBundleMessageSource.setCacheSeconds(5);
    return reloadableResourceBundleMessageSource;
  }
  @Override
  public void setResourceLoader(ResourceLoader resourceLoader) {
    if (Metadata.getCurrent().isWarDeployed()) {
      this.localResourceLoader = resourceLoader;
    } else {
      // The "settings" may be null in some of the Grails unit tests.
      BuildSettings settings = BuildSettingsHolder.getSettings();
      String location = null;
      if (Environment.getCurrent().isReloadEnabled()) {
        location = Environment.getCurrent().getReloadLocation();
      }
      if (location == null)
        location = settings != null ? settings.getResourcesDir().getPath() : null;

      this.localResourceLoader = new DevelopmentResourceLoader(this.application, location);
    }
    super.setResourceLoader(localResourceLoader);
    this.resourceResolver = new PathMatchingResourcePatternResolver(this.localResourceLoader);
  }