/*
  * (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
 public void setApplicationContext(ApplicationContext appContext) throws BeansException {
   try {
     resourceLoader = appContext;
     generateSchemas(appContext.getResources(getXsdPath() + "/*.xsd"));
   } catch (IOException e) {
     LOG.error("Unable to load schemas", e);
   }
 }
예제 #3
0
  private void importLdifs() throws Exception {
    // Import any ldif files
    Resource[] ldifs;

    if (ctxt == null) {
      // Not running within an app context
      ldifs = new PathMatchingResourcePatternResolver().getResources(ldifResources);
    } else {
      ldifs = ctxt.getResources(ldifResources);
    }

    // Note that we can't just import using the ServerContext returned
    // from starting Apace DS, apparently because of the long-running issue DIRSERVER-169.
    // We need a standard context.
    // DirContext dirContext = contextSource.getReadWriteContext();

    if (ldifs != null && ldifs.length > 0) {
      String ldifFile = ldifs[0].getFile().getAbsolutePath();
      logger.info("Loading LDIF file: " + ldifFile);
      LdifFileLoader loader = new LdifFileLoader(service.getAdminSession(), ldifFile);
      loader.execute();
    }
  }
예제 #4
0
 public Resource[] getResources(String arg0) throws IOException {
   return applicationContext.getResources(arg0);
 }