public void afterPropertiesSet() throws IOException, CacheException {
   log.info("Initializing EHCache CacheManager");
   Configuration config = null;
   if (this.configLocation != null) {
     config = ConfigurationFactory.parseConfiguration(this.configLocation.getInputStream());
     if (this.diskStoreLocation != null) {
       DiskStoreConfiguration dc = new DiskStoreConfiguration();
       dc.setPath(this.diskStoreLocation.getFile().getAbsolutePath());
       try {
         config.addDiskStore(dc);
       } catch (ObjectExistsException e) {
         log.warn(
             "if you want to config distStore in spring,"
                 + " please remove diskStore in config file!",
             e);
       }
     }
   }
   if (config != null) {
     this.cacheManager = new CacheManager(config);
   } else {
     this.cacheManager = new CacheManager();
   }
   if (this.cacheManagerName != null) {
     this.cacheManager.setName(this.cacheManagerName);
   }
 }
Esempio n. 2
0
 /** @return the disk store path, or null if not set. */
 public final String getDiskStorePath() {
   DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
   if (diskStoreConfiguration == null) {
     return null;
   } else {
     return diskStoreConfiguration.getPath();
   }
 }
Esempio n. 3
0
  /**
   * Java is not consistent with trailing file separators, believe it or not!
   * http://www.rationalpi.com/blog/replyToComment.action?entry=1146628709626&comment=1155660875090
   * Can we fix c:\temp\\greg?
   */
  @Test
  public void testWindowsAndSolarisTempDirProblem() throws InterruptedException {

    String originalPath = "c:" + File.separator + "temp" + File.separator + File.separator + "greg";
    // Fix dup separator
    String translatedPath =
        DiskStoreConfiguration.replaceToken(
            File.separator + File.separator, File.separator, originalPath);
    assertEquals("c:" + File.separator + "temp" + File.separator + "greg", translatedPath);
    // Ignore single separators
    translatedPath =
        DiskStoreConfiguration.replaceToken(
            File.separator + File.separator, File.separator, originalPath);
    assertEquals("c:" + File.separator + "temp" + File.separator + "greg", translatedPath);

    Thread.sleep(500);
  }
 private void diskStore(final Config conf) {
   DiskStoreConfiguration diskStore = new DiskStoreConfiguration();
   diskStore.setPath(conf.getString("path"));
   eh.addDiskStore(diskStore);
 }